diff options
-rw-r--r-- | Android.mk | 2 | ||||
-rw-r--r-- | applypatch/imgdiff.cpp | 6 | ||||
-rw-r--r-- | edify/include/edify/expr.h | 2 | ||||
-rw-r--r-- | otautil/include/otautil/sysutil.h | 2 | ||||
-rw-r--r-- | otautil/sysutil.cpp | 8 | ||||
-rw-r--r-- | recovery.cpp | 8 | ||||
-rw-r--r-- | recovery_ui/screen_ui.cpp | 4 | ||||
-rw-r--r-- | recovery_ui/ui.cpp | 3 | ||||
-rw-r--r-- | tests/Android.bp | 19 | ||||
-rw-r--r-- | tests/testdata/recovery.img | bin | 529707 -> 0 bytes | |||
-rw-r--r-- | tests/testdata/recovery_body | bin | 0 -> 1293568 bytes | |||
-rw-r--r-- | tests/testdata/recovery_head | bin | 0 -> 45056 bytes | |||
-rw-r--r-- | tests/testdata/recovery_tail | bin | 0 -> 5191 bytes | |||
-rw-r--r-- | updater/Android.bp | 1 | ||||
-rw-r--r-- | updater/Android.mk | 1 | ||||
-rw-r--r-- | updater/include/private/commands.h | 2 | ||||
-rw-r--r-- | updater/install.cpp | 1 |
17 files changed, 37 insertions, 22 deletions
diff --git a/Android.mk b/Android.mk index 9806d1091..d727ca2af 100644 --- a/Android.mk +++ b/Android.mk @@ -56,12 +56,10 @@ include $(CLEAR_VARS) LOCAL_MODULE := recovery_deps ifeq ($(TARGET_USERIMAGES_USE_F2FS),true) -ifeq ($(HOST_OS),linux) LOCAL_REQUIRED_MODULES += \ make_f2fs.recovery \ sload_f2fs.recovery 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 diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp index 6ad4a6105..91007ac3b 100644 --- a/applypatch/imgdiff.cpp +++ b/applypatch/imgdiff.cpp @@ -965,7 +965,7 @@ bool ZipModeImage::SplitZipModeImageWithLimit(const ZipModeImage& tgt_image, used_src_ranges.Insert(src_ranges); split_src_ranges->push_back(std::move(src_ranges)); } - src_ranges.Clear(); + src_ranges = {}; // We don't have enough space for the current chunk; start a new split image and handle // this chunk there. @@ -1035,7 +1035,7 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, } ZipModeImage split_tgt_image(false); - split_tgt_image.Initialize(std::move(aligned_tgt_chunks), {}); + split_tgt_image.Initialize(aligned_tgt_chunks, {}); split_tgt_image.MergeAdjacentNormalChunks(); // Construct the dummy source file based on the src_ranges. @@ -1051,7 +1051,7 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, CHECK(!src_content.empty()); ZipModeImage split_src_image(true); - split_src_image.Initialize(split_src_chunks, std::move(src_content)); + split_src_image.Initialize(split_src_chunks, src_content); split_tgt_images->push_back(std::move(split_tgt_image)); split_src_images->push_back(std::move(split_src_image)); diff --git a/edify/include/edify/expr.h b/edify/include/edify/expr.h index cd9c70120..3ddf7f5fe 100644 --- a/edify/include/edify/expr.h +++ b/edify/include/edify/expr.h @@ -60,7 +60,7 @@ struct Value { BLOB = 2, }; - Value(Type type, const std::string& str) : type(type), data(str) {} + Value(Type type, std::string str) : type(type), data(std::move(str)) {} Type type; std::string data; diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h index 326db8644..d0d2e67d7 100644 --- a/otautil/include/otautil/sysutil.h +++ b/otautil/include/otautil/sysutil.h @@ -103,7 +103,7 @@ class MemMapping { // Reboots the device into the specified target, by additionally handling quiescent reboot mode. // All unknown targets reboot into Android. -bool Reboot(std::string_view target); +[[noreturn]] void Reboot(std::string_view target); // Triggers a shutdown. bool Shutdown(std::string_view target); diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp index 6cd46c6a9..b3ead9736 100644 --- a/otautil/sysutil.cpp +++ b/otautil/sysutil.cpp @@ -219,14 +219,18 @@ MemMapping::~MemMapping() { ranges_.clear(); } -bool Reboot(std::string_view target) { +void Reboot(std::string_view target) { std::string cmd = "reboot," + std::string(target); // Honor the quiescent mode if applicable. if (target != "bootloader" && target != "fastboot" && android::base::GetBoolProperty("ro.boot.quiescent", false)) { cmd += ",quiescent"; } - return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd); + if (!android::base::SetProperty(ANDROID_RB_PROPERTY, cmd)) { + LOG(FATAL) << "Reboot failed"; + } + + while (true) pause(); } bool Shutdown(std::string_view target) { diff --git a/recovery.cpp b/recovery.cpp index 0382697ab..7675121d4 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -781,13 +781,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri ui->Print("Retry attempt %d\n", retry_count); // Reboot back into recovery to retry the update. - if (!Reboot("recovery")) { - ui->Print("Reboot failed\n"); - } else { - while (true) { - pause(); - } - } + Reboot("recovery"); } // If this is an eng or userdebug build, then automatically // turn the text display on if the script fails so the error diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp index 087fc0e84..6dcb161fa 100644 --- a/recovery_ui/screen_ui.cpp +++ b/recovery_ui/screen_ui.cpp @@ -448,7 +448,9 @@ void ScreenRecoveryUI::draw_foreground_locked() { int frame_height = gr_get_height(frame); int frame_x = (ScreenWidth() - frame_width) / 2; int frame_y = GetAnimationBaseline(); - DrawSurface(frame, 0, 0, frame_width, frame_height, frame_x, frame_y); + if (frame_x >= 0 && frame_y >= 0 && (frame_x + frame_width) < ScreenWidth() && + (frame_y + frame_height) < ScreenHeight()) + DrawSurface(frame, 0, 0, frame_width, frame_height, frame_x, frame_y); } if (progressBarType != EMPTY) { diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp index 6f5cbbca6..330721773 100644 --- a/recovery_ui/ui.cpp +++ b/recovery_ui/ui.cpp @@ -375,9 +375,6 @@ void RecoveryUI::ProcessKey(int key_code, int updown) { case RecoveryUI::REBOOT: if (reboot_enabled) { Reboot("userrequested,recovery,ui"); - while (true) { - pause(); - } } break; diff --git a/tests/Android.bp b/tests/Android.bp index 4c23255ad..a9a088a32 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -95,6 +95,24 @@ librecovery_static_libs = [ "libc++fs", ] +// recovery image for unittests. +// ======================================================== +genrule { + name: "recovery_image", + cmd: "cat $(location testdata/recovery_head) <(cat $(location testdata/recovery_body) | $(location minigzip)) $(location testdata/recovery_tail) > $(out)", + srcs: [ + "testdata/recovery_head", + "testdata/recovery_body", + "testdata/recovery_tail", + ], + tools: [ + "minigzip", + ], + out: [ + "testdata/recovery.img", + ], +} + cc_test { name: "recovery_unit_test", isolated: true, @@ -128,6 +146,7 @@ cc_test { data: [ "testdata/*", + ":recovery_image", ":res-testdata", ], } diff --git a/tests/testdata/recovery.img b/tests/testdata/recovery.img Binary files differdeleted file mode 100644 index b862e6f0c..000000000 --- a/tests/testdata/recovery.img +++ /dev/null diff --git a/tests/testdata/recovery_body b/tests/testdata/recovery_body Binary files differnew file mode 100644 index 000000000..48d7c10a5 --- /dev/null +++ b/tests/testdata/recovery_body diff --git a/tests/testdata/recovery_head b/tests/testdata/recovery_head Binary files differnew file mode 100644 index 000000000..7f494d098 --- /dev/null +++ b/tests/testdata/recovery_head diff --git a/tests/testdata/recovery_tail b/tests/testdata/recovery_tail Binary files differnew file mode 100644 index 000000000..7fe2c6ce8 --- /dev/null +++ b/tests/testdata/recovery_tail diff --git a/updater/Android.bp b/updater/Android.bp index cbef43099..f00a192b9 100644 --- a/updater/Android.bp +++ b/updater/Android.bp @@ -25,6 +25,7 @@ cc_defaults { "libdm", "libfec", "libfec_rs", + "libavb", "libverity_tree", "libgtest_prod", "liblog", diff --git a/updater/Android.mk b/updater/Android.mk index 8a4cd86d9..46300d974 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -32,6 +32,7 @@ updater_common_static_libraries := \ libdm \ libfec \ libfec_rs \ + libavb \ libverity_tree \ libgtest_prod \ liblog \ diff --git a/updater/include/private/commands.h b/updater/include/private/commands.h index 79f915434..7a23bb78b 100644 --- a/updater/include/private/commands.h +++ b/updater/include/private/commands.h @@ -307,7 +307,7 @@ class Command { : type_(type), index_(index), cmdline_(std::move(cmdline)), - patch_(std::move(patch)), + patch_(patch), target_(std::move(target)), source_(std::move(source)), stash_(std::move(stash)) {} diff --git a/updater/install.cpp b/updater/install.cpp index 62ff87e76..7608dc3cd 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -733,7 +733,6 @@ Value* RebootNowFn(const char* name, State* state, const std::vector<std::unique Reboot(property); - sleep(5); return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name); } |