From d34e6bc44b0e58a3261cd7070a1525099932f205 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 13 Jul 2018 13:11:09 -0700 Subject: applypatch: Change applypatch command-line arguments. This applies to the standalone applypatch executable (/system/bin/applypatch on device). This executable is only used when installing (via patching or flashing) a recovery image on non-A/B device. This CL removes the support for patching non-eMMC targets from applypatch that has been deprecated as part of file-based OTA. For patching eMMC targets, it also drops the support for accepting multiple patches (not useful, since the source file must be fixed). This CL needs the matching change in the same topic, which writes the script of "/system/bin/install-recovery.sh". Note that this CL doesn't chanage the applypatch API signatures, in order to minimize the CL size. *BEFORE* usage: /system/bin/applypatch [-b ] [: ...] or /system/bin/applypatch -c [ ...] or /system/bin/applypatch -l Filenames may be of the form EMMC::::::... to specify reading from or writing to an EMMC partition. *AFTER* Usage: check mode applypatch --check EMMC::: flash mode applypatch --flash --target EMMC::: patch mode applypatch [--bonus ] --patch --target EMMC::: --source EMMC::: show license applypatch --license Bug: 110106408 Test: Run recovery_component_test and recovery_unit_test on marlin. Test: Build a non-A/B target that has /system/bin/install-recovery.sh. Verify that it installs recovery image successfully. Test: Build a non-A/B target that has /system/bin/install-recovery.sh in flashing mode. Verify that it installs recovery image successfully. Change-Id: I71f9a71fb457e6f663e0b5511946949e65b4b78c --- applypatch/applypatch.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'applypatch/applypatch.cpp') diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 12e139930..b1aefa49b 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -495,19 +495,15 @@ int applypatch_flash(const char* source_filename, const char* target_filename, return 1; } - std::string target_str(target_filename); - std::vector pieces = android::base::Split(target_str, ":"); - if (pieces.size() != 2 || pieces[0] != "EMMC") { + std::vector pieces = android::base::Split(target_filename, ":"); + if (pieces.size() != 4 || pieces[0] != "EMMC") { LOG(ERROR) << "Invalid target name \"" << target_filename << "\""; return 1; } // Load the target into the source_file object to see if already applied. - pieces.push_back(std::to_string(target_size)); - pieces.push_back(target_sha1_str); - std::string fullname = android::base::Join(pieces, ':'); FileContents source_file; - if (LoadPartitionContents(fullname, &source_file) == 0 && + if (LoadPartitionContents(target_filename, &source_file) == 0 && memcmp(source_file.sha1, target_sha1, SHA_DIGEST_LENGTH) == 0) { // The early-exit case: the image was already applied, this partition has the desired hash, // nothing for us to do. -- cgit v1.2.3