diff options
-rw-r--r-- | Android.bp | 4 | ||||
-rw-r--r-- | Android.mk | 8 | ||||
-rw-r--r-- | bootloader_message/bootloader_message.cpp | 3 | ||||
-rw-r--r-- | recovery-persist.cpp | 4 | ||||
-rw-r--r-- | roots.cpp | 9 | ||||
-rw-r--r-- | roots.h | 4 | ||||
-rw-r--r-- | screen_ui.cpp | 4 | ||||
-rw-r--r-- | tests/Android.bp | 1 | ||||
-rw-r--r-- | tests/component/install_test.cpp | 4 | ||||
-rw-r--r-- | uncrypt/uncrypt.cpp | 3 | ||||
-rw-r--r-- | update_verifier/Android.bp | 5 | ||||
-rw-r--r-- | update_verifier/update_verifier.cpp | 32 | ||||
-rw-r--r-- | updater/blockimg.cpp | 8 |
13 files changed, 61 insertions, 28 deletions
diff --git a/Android.bp b/Android.bp index 41075d23a..afa033716 100644 --- a/Android.bp +++ b/Android.bp @@ -45,6 +45,7 @@ cc_library { static_libs: [ "libminui", "libotautil", + "libfstab", ], shared_libs: [ @@ -157,6 +158,7 @@ cc_defaults { "libhealthhalutils", "libvintf_recovery", "libvintf", + "libfstab", ], } @@ -260,6 +262,7 @@ cc_binary { static_libs: [ "libotautil", + "libfstab", ], init_rc: [ @@ -287,6 +290,7 @@ cc_binary { static_libs: [ "libotautil", + "libfstab", ], init_rc: [ diff --git a/Android.mk b/Android.mk index 429c52dbf..9806d1091 100644 --- a/Android.mk +++ b/Android.mk @@ -63,14 +63,6 @@ LOCAL_REQUIRED_MODULES += \ endif endif -# e2fsck is needed for adb remount -R. -ifeq ($(BOARD_EXT4_SHARE_DUP_BLOCKS),true) -ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) -LOCAL_REQUIRED_MODULES += \ - e2fsck_static -endif -endif - # On A/B devices recovery-persist reads the recovery related file from the persist storage and # copies them into /data/misc/recovery. Then, for both A/B and non-A/B devices, recovery-persist # parses the last_install file and reports the embedded update metrics. Also, the last_install file diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index b933cbf8e..8c1d63bdd 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -29,6 +29,9 @@ #include <android-base/unique_fd.h> #include <fstab/fstab.h> +using android::fs_mgr::Fstab; +using android::fs_mgr::ReadDefaultFstab; + static std::string get_misc_blk_device(std::string* err) { Fstab fstab; if (!ReadDefaultFstab(&fstab)) { diff --git a/recovery-persist.cpp b/recovery-persist.cpp index ebb42d223..e2a6699f6 100644 --- a/recovery-persist.cpp +++ b/recovery-persist.cpp @@ -158,7 +158,7 @@ int main(int argc, char **argv) { // Collects and reports the non-a/b update metrics from last_install; and removes the file // to avoid duplicate report. report_metrics_from_last_install(LAST_INSTALL_FILE_IN_CACHE); - if (unlink(LAST_INSTALL_FILE_IN_CACHE) == -1) { + if (access(LAST_INSTALL_FILE_IN_CACHE, F_OK) && unlink(LAST_INSTALL_FILE_IN_CACHE) == -1) { PLOG(ERROR) << "Failed to unlink " << LAST_INSTALL_FILE_IN_CACHE; } @@ -182,7 +182,7 @@ int main(int argc, char **argv) { // /data/misc/recovery from pmsg. Looks for the sideload history only. if (!has_cache) { report_metrics_from_last_install(LAST_INSTALL_FILE); - if (unlink(LAST_INSTALL_FILE) == -1) { + if (access(LAST_INSTALL_FILE, F_OK) && unlink(LAST_INSTALL_FILE) == -1) { PLOG(ERROR) << "Failed to unlink " << LAST_INSTALL_FILE; } } @@ -45,6 +45,10 @@ #include "otautil/mounts.h" #include "otautil/sysutil.h" +using android::fs_mgr::Fstab; +using android::fs_mgr::FstabEntry; +using android::fs_mgr::ReadDefaultFstab; + static Fstab fstab; extern struct selabel_handle* sehandle; @@ -69,10 +73,7 @@ void load_volume_table() { } Volume* volume_for_mount_point(const std::string& mount_point) { - auto it = std::find_if(fstab.begin(), fstab.end(), [&mount_point](const auto& entry) { - return entry.mount_point == mount_point; - }); - return it == fstab.end() ? nullptr : &*it; + return android::fs_mgr::GetEntryForMountPoint(&fstab, mount_point); } // Mount the volume specified by path at the given mount_point. @@ -19,7 +19,9 @@ #include <string> -typedef struct FstabEntry Volume; +#include <fstab/fstab.h> + +using Volume = android::fs_mgr::FstabEntry; // Load and parse volume data from /etc/recovery.fstab. void load_volume_table(); diff --git a/screen_ui.cpp b/screen_ui.cpp index 7fa41c4e4..6c00a2235 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -278,12 +278,12 @@ bool GraphicMenu::Validate(size_t max_width, size_t max_height, const GRSurface* bool GraphicMenu::ValidateGraphicSurface(size_t max_width, size_t max_height, int y, const GRSurface* surface) { if (!surface) { - fprintf(stderr, "Graphic surface can not be null"); + fprintf(stderr, "Graphic surface can not be null\n"); return false; } if (surface->pixel_bytes != 1 || surface->width != surface->row_bytes) { - fprintf(stderr, "Invalid graphic surface, pixel bytes: %zu, width: %zu row_bytes: %zu", + fprintf(stderr, "Invalid graphic surface, pixel bytes: %zu, width: %zu row_bytes: %zu\n", surface->pixel_bytes, surface->width, surface->row_bytes); return false; } diff --git a/tests/Android.bp b/tests/Android.bp index 1d6a056f6..898ed7d60 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -29,6 +29,7 @@ cc_defaults { "libcutils", "liblog", "libpng", + "libprocessgroup", "libselinux", "libz", "libziparchive", diff --git a/tests/component/install_test.cpp b/tests/component/install_test.cpp index 27a01cb32..47a54714c 100644 --- a/tests/component/install_test.cpp +++ b/tests/component/install_test.cpp @@ -439,8 +439,8 @@ TEST(InstallTest, CheckPackageMetadata_multiple_serial_number) { std::vector<std::string> serial_numbers; // Creates a dummy serial number string. - for (size_t c = 'a'; c <= 'z'; c++) { - serial_numbers.emplace_back(c, serialno.size()); + for (char c = 'a'; c <= 'z'; c++) { + serial_numbers.emplace_back(serialno.size(), c); } // No matched serialno found. diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp index 75595ac2c..f1f4f69f0 100644 --- a/uncrypt/uncrypt.cpp +++ b/uncrypt/uncrypt.cpp @@ -119,6 +119,9 @@ #include "otautil/error_code.h" +using android::fs_mgr::Fstab; +using android::fs_mgr::ReadDefaultFstab; + static constexpr int WINDOW_SIZE = 5; static constexpr int FIBMAP_RETRY_LIMIT = 3; diff --git a/update_verifier/Android.bp b/update_verifier/Android.bp index 1b84619af..f6567137e 100644 --- a/update_verifier/Android.bp +++ b/update_verifier/Android.bp @@ -42,12 +42,15 @@ cc_library_static { static_libs: [ "libotautil", + "libvold_binder", ], shared_libs: [ "android.hardware.boot@1.0", "libbase", "libcutils", + "libbinder", + "libutils", ], proto: { @@ -70,6 +73,7 @@ cc_binary { static_libs: [ "libupdate_verifier", "libotautil", + "libvold_binder", ], shared_libs: [ @@ -80,6 +84,7 @@ cc_binary { "libhidlbase", "liblog", "libprotobuf-cpp-lite", + "libbinder", "libutils", ], diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp index d7cd061e2..5e5eac7ab 100644 --- a/update_verifier/update_verifier.cpp +++ b/update_verifier/update_verifier.cpp @@ -38,6 +38,7 @@ */ #include "update_verifier/update_verifier.h" +#include <android/os/IVold.h> #include <dirent.h> #include <errno.h> @@ -56,6 +57,8 @@ #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/hardware/boot/1.0/IBootControl.h> +#include <binder/BinderService.h> +#include <binder/Status.h> #include <cutils/android_reboot.h> #include "care_map.pb.h" @@ -376,13 +379,30 @@ int update_verifier(int argc, char** argv) { } } - CommandResult cr; - module->markBootSuccessful([&cr](CommandResult result) { cr = result; }); - if (!cr.success) { - LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg; - return reboot_device(); + bool supports_checkpoint = false; + auto sm = android::defaultServiceManager(); + android::sp<android::IBinder> binder = sm->getService(android::String16("vold")); + if (binder) { + auto vold = android::interface_cast<android::os::IVold>(binder); + android::binder::Status status = vold->supportsCheckpoint(&supports_checkpoint); + if (!status.isOk()) { + LOG(ERROR) << "Failed to check if checkpoints supported. Continuing"; + } + } else { + LOG(ERROR) << "Failed to obtain vold Binder. Continuing"; + } + + if (!supports_checkpoint) { + CommandResult cr; + module->markBootSuccessful([&cr](CommandResult result) { cr = result; }); + if (!cr.success) { + LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg; + return reboot_device(); + } + LOG(INFO) << "Marked slot " << current_slot << " as booted successfully."; + } else { + LOG(INFO) << "Deferred marking slot " << current_slot << " as booted successfully."; } - LOG(INFO) << "Marked slot " << current_slot << " as booted successfully."; } LOG(INFO) << "Leaving update_verifier."; diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index 6e5d5bb55..07c3c7b52 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1525,7 +1525,7 @@ static int PerformCommandComputeHashTree(CommandParameters& params) { // Starts the hash_tree computation. HashTreeBuilder builder(BLOCKSIZE, hash_function); - if (!builder.Initialize(source_ranges.blocks() * BLOCKSIZE, salt)) { + if (!builder.Initialize(static_cast<int64_t>(source_ranges.blocks()) * BLOCKSIZE, salt)) { LOG(ERROR) << "Failed to initialize hash tree computation, source " << source_ranges.ToString() << ", salt " << salt_hex; return -1; @@ -1915,8 +1915,10 @@ pbiudone: const char* partition = strrchr(blockdev_filename->data.c_str(), '/'); if (partition != nullptr && *(partition + 1) != 0) { - fprintf(cmd_pipe, "log bytes_written_%s: %zu\n", partition + 1, params.written * BLOCKSIZE); - fprintf(cmd_pipe, "log bytes_stashed_%s: %zu\n", partition + 1, params.stashed * BLOCKSIZE); + fprintf(cmd_pipe, "log bytes_written_%s: %" PRIu64 "\n", partition + 1, + static_cast<uint64_t>(params.written) * BLOCKSIZE); + fprintf(cmd_pipe, "log bytes_stashed_%s: %" PRIu64 "\n", partition + 1, + static_cast<uint64_t>(params.stashed) * BLOCKSIZE); fflush(cmd_pipe); } // Delete stash only after successfully completing the update, as it may contain blocks needed |