summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-05-13 21:18:02 +0200
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-13 21:18:02 +0200
commitdc04d803d3e153055a284756cc4a54e70502b4d8 (patch)
tree3491c3edf7618023242408108ee36a7adbd77e15 /install
parentMerge "Allos IsUsbConnected() to be overridden" am: 54e28fed8a am: bc3a63e4a4 am: adb1ed5a95 am: 5589ec0b3b am: bbba1b700a (diff)
parentMerge changes from topic "nonab_on_vab_r" into rvc-dev am: b62ff1abe3 am: fbe98bb122 am: b4be26a02c (diff)
downloadandroid_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.tar
android_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.tar.gz
android_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.tar.bz2
android_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.tar.lz
android_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.tar.xz
android_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.tar.zst
android_bootable_recovery-dc04d803d3e153055a284756cc4a54e70502b4d8.zip
Diffstat (limited to 'install')
-rw-r--r--install/install.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/install/install.cpp b/install/install.cpp
index 1c9bf2fd2..d404997dc 100644
--- a/install/install.cpp
+++ b/install/install.cpp
@@ -331,15 +331,25 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
return INSTALL_CORRUPT;
}
- bool is_ab = android::base::GetBoolProperty("ro.build.ab_update", false);
- if (is_ab) {
+ bool package_is_ab = get_value(metadata, "ota-type") == OtaTypeToString(OtaType::AB);
+ 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);
+ bool device_only_supports_ab = device_supports_ab && !ab_device_supports_nonab;
+
+ if (package_is_ab) {
CHECK(package->GetType() == PackageType::kFile);
}
- // Verify against the metadata in the package first.
- if (is_ab && !CheckPackageMetadata(metadata, OtaType::AB)) {
- log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
- return INSTALL_ERROR;
+ // Verify against the metadata in the package first. Expects A/B metadata if:
+ // Package declares itself as an A/B package
+ // Package does not declare itself as an A/B package, but device only supports A/B;
+ // still calls CheckPackageMetadata to get a meaningful error message.
+ if (package_is_ab || device_only_supports_ab) {
+ if (!CheckPackageMetadata(metadata, OtaType::AB)) {
+ log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
+ return INSTALL_ERROR;
+ }
}
ReadSourceTargetBuild(metadata, log_buffer);
@@ -389,8 +399,9 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
std::vector<std::string> args;
if (auto setup_result =
- is_ab ? SetUpAbUpdateCommands(package_path, zip, pipe_write.get(), &args)
- : SetUpNonAbUpdateCommands(package_path, zip, retry_count, pipe_write.get(), &args);
+ package_is_ab
+ ? SetUpAbUpdateCommands(package_path, zip, pipe_write.get(), &args)
+ : SetUpNonAbUpdateCommands(package_path, zip, retry_count, pipe_write.get(), &args);
!setup_result) {
log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
return INSTALL_CORRUPT;