summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2023-03-15 05:17:35 +0100
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-03-15 05:17:35 +0100
commit2643880e5d0115ab40fdcaaec55e0cf901887a28 (patch)
tree1dcc929da34a589297a3d7f4ba3615717fee8e3c
parentMerge "Require serialno field for brick OTA package on release-key devices" am: 00bfe128f9 am: 421625f458 (diff)
parentMerge "Allow brick OTA package to be sideloaded in recovery" am: aff08259ec (diff)
downloadandroid_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.tar
android_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.tar.gz
android_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.tar.bz2
android_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.tar.lz
android_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.tar.xz
android_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.tar.zst
android_bootable_recovery-2643880e5d0115ab40fdcaaec55e0cf901887a28.zip
-rw-r--r--install/include/install/wipe_device.h1
-rw-r--r--install/install.cpp18
-rw-r--r--install/wipe_device.cpp8
3 files changed, 24 insertions, 3 deletions
diff --git a/install/include/install/wipe_device.h b/install/include/install/wipe_device.h
index 903ddfdcd..19e7c65bf 100644
--- a/install/include/install/wipe_device.h
+++ b/install/include/install/wipe_device.h
@@ -24,6 +24,7 @@
// Wipes the current A/B device, with a secure wipe of all the partitions in RECOVERY_WIPE.
bool WipeAbDevice(Device* device, size_t wipe_package_size);
+bool WipeAbDevice(Device* device, Package* wipe_package);
// Reads the "recovery.wipe" entry in the zip archive returns a list of partitions to wipe.
std::vector<std::string> GetWipePartitionList(Package* wipe_package);
diff --git a/install/install.cpp b/install/install.cpp
index 30ba94c26..a9786cfdf 100644
--- a/install/install.cpp
+++ b/install/install.cpp
@@ -48,6 +48,7 @@
#include "install/spl_check.h"
#include "install/wipe_data.h"
+#include "install/wipe_device.h"
#include "otautil/error_code.h"
#include "otautil/package.h"
#include "otautil/paths.h"
@@ -71,6 +72,8 @@ static constexpr float VERIFICATION_PROGRESS_FRACTION = 0.25;
// The charater used to separate dynamic fingerprints. e.x. sargo|aosp-sargo
static const char* FINGERPRING_SEPARATOR = "|";
static constexpr auto&& RELEASE_KEYS_TAG = "release-keys";
+// If brick packages are smaller than |MEMORY_PACKAGE_LIMIT|, read the entire package into memory
+static constexpr size_t MEMORY_PACKAGE_LIMIT = 1024 * 1024;
static std::condition_variable finish_log_temperature;
static bool isInStringList(const std::string& target_token, const std::string& str_list,
@@ -382,7 +385,20 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
return INSTALL_CORRUPT;
}
- bool package_is_ab = get_value(metadata, "ota-type") == OtaTypeToString(OtaType::AB);
+ const bool package_is_ab = get_value(metadata, "ota-type") == OtaTypeToString(OtaType::AB);
+ const bool package_is_brick = get_value(metadata, "ota-type") == OtaTypeToString(OtaType::BRICK);
+ if (package_is_brick) {
+ LOG(INFO) << "Installing a brick package";
+ if (package->GetType() == PackageType::kFile &&
+ package->GetPackageSize() < MEMORY_PACKAGE_LIMIT) {
+ std::vector<uint8_t> content(package->GetPackageSize());
+ if (package->ReadFullyAtOffset(content.data(), content.size(), 0)) {
+ auto memory_package = Package::CreateMemoryPackage(std::move(content), {});
+ return WipeAbDevice(device, memory_package.get()) ? INSTALL_SUCCESS : INSTALL_ERROR;
+ }
+ }
+ return WipeAbDevice(device, package) ? INSTALL_SUCCESS : INSTALL_ERROR;
+ }
bool device_supports_ab = android::base::GetBoolProperty("ro.build.ab_update", false);
bool ab_device_supports_nonab =
android::base::GetBoolProperty("ro.virtual_ab.allow_non_ab", false);
diff --git a/install/wipe_device.cpp b/install/wipe_device.cpp
index 0a525fa9b..2656580fe 100644
--- a/install/wipe_device.cpp
+++ b/install/wipe_device.cpp
@@ -182,13 +182,17 @@ bool WipeAbDevice(Device* device, size_t wipe_package_size) {
LOG(ERROR) << "Failed to open wipe package";
return false;
}
+ return WipeAbDevice(device, wipe_package.get());
+}
- if (!CheckWipePackage(wipe_package.get(), ui)) {
+bool WipeAbDevice(Device* device, Package* wipe_package) {
+ auto ui = device->GetUI();
+ if (!CheckWipePackage(wipe_package, ui)) {
LOG(ERROR) << "Failed to verify wipe package";
return false;
}
- auto partition_list = GetWipePartitionList(wipe_package.get());
+ auto partition_list = GetWipePartitionList(wipe_package);
if (partition_list.empty()) {
LOG(ERROR) << "Empty wipe ab partition list";
return false;