std::vector<std::string> GetWipePartitionList(Package* wipe_package) {
ZipArchiveHandle zip = wipe_package->GetZipArchiveHandle(); if (!zip) {
LOG(ERROR) << "Failed to get ZipArchiveHandle"; return {};
}
std::vector<std::string> result; auto lines = android::base::Split(partition_list_content, "\n"); for (constauto& line : lines) { auto partition = android::base::Trim(line); // Ignore '#' comment or empty lines. if (android::base::StartsWith(partition, "#") || partition.empty()) { continue;
}
result.push_back(line);
}
return result;
}
// Secure-wipes a given partition. It uses BLKSECDISCARD, if supported. Otherwise, it goes with // BLKDISCARD (if device supports BLKDISCARDZEROES) or BLKZEROOUT. staticbool SecureWipePartition(const std::string& partition) {
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(partition.c_str(), O_WRONLY))); if (fd == -1) {
PLOG(ERROR) << "Failed to open \"" << partition << "\""; returnfalse;
}
uint64_t range[2] = { 0, 0 }; if (ioctl(fd, BLKGETSIZE64, &range[1]) == -1 || range[1] == 0) {
PLOG(ERROR) << "Failed to get partition size"; returnfalse;
}
LOG(INFO) << "Secure-wiping \"" << partition << "\" from " << range[0] << " to " << range[1];
// Checks if the wipe package matches expectation. If the check passes, reads the list of // partitions to wipe from the package. Checks include // 1. verify the package. // 2. check metadata (ota-type, pre-device and serial number if having one). staticbool CheckWipePackage(Package* wipe_package, RecoveryUI* ui) { if (!verify_package(wipe_package, ui)) {
LOG(ERROR) << "Failed to verify package"; returnfalse;
}
ZipArchiveHandle zip = wipe_package->GetZipArchiveHandle(); if (!zip) {
LOG(ERROR) << "Failed to get ZipArchiveHandle"; returnfalse;
}
std::map<std::string, std::string> metadata; if (!ReadMetadataFromPackage(zip, &metadata)) {
LOG(ERROR) << "Failed to parse metadata in the zip file"; returnfalse;
}
auto wipe_package = ReadWipePackage(wipe_package_size); if (!wipe_package) {
LOG(ERROR) << "Failed to open wipe package"; returnfalse;
} return WipeAbDevice(device, wipe_package.get());
}
bool WipeAbDevice(Device* device, Package* wipe_package) { auto ui = device->GetUI(); if (!CheckWipePackage(wipe_package, ui)) {
LOG(ERROR) << "Failed to verify wipe package"; returnfalse;
}
auto partition_list = GetWipePartitionList(wipe_package); if (partition_list.empty()) {
LOG(ERROR) << "Empty wipe ab partition list"; returnfalse;
}
for (constauto& partition : partition_list) { // Proceed anyway even if it fails to wipe some partition.
SecureWipePartition(partition);
} returntrue;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet am 2026-07-01)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.