Detect non-A/B vs. A/B packages correctly.
Check the package metadata to determine whether this is an
A/B or non-A/B update package. This is more accurate.
Also checks ro.virtual_ab.allow_non_ab flag. This is useful for
continuously supporting (and testing) non-A/B.
Bug: 153581609
Test: apply non-A/B update on cuttlefish
Change-Id: I629a533a67966d46d9cd87a59c6b9af26daf1667
(cherry picked from commit 2a4afd29a1
)
Merged-In: I629a533a67966d46d9cd87a59c6b9af26daf1667
This commit is contained in:
parent
4577dff5a0
commit
f2af5629d2
1 changed files with 19 additions and 8 deletions
|
@ -330,16 +330,26 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
|
||||||
return INSTALL_CORRUPT;
|
return INSTALL_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_ab = android::base::GetBoolProperty("ro.build.ab_update", false);
|
bool package_is_ab = get_value(metadata, "ota-type") == OtaTypeToString(OtaType::AB);
|
||||||
if (is_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);
|
CHECK(package->GetType() == PackageType::kFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify against the metadata in the package first.
|
// Verify against the metadata in the package first. Expects A/B metadata if:
|
||||||
if (is_ab && !CheckPackageMetadata(metadata, OtaType::AB)) {
|
// 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));
|
log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
|
||||||
return INSTALL_ERROR;
|
return INSTALL_ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ReadSourceTargetBuild(metadata, log_buffer);
|
ReadSourceTargetBuild(metadata, log_buffer);
|
||||||
|
|
||||||
|
@ -388,7 +398,8 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
|
||||||
|
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
if (auto setup_result =
|
if (auto setup_result =
|
||||||
is_ab ? SetUpAbUpdateCommands(package_path, zip, 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);
|
: SetUpNonAbUpdateCommands(package_path, zip, retry_count, pipe_write.get(), &args);
|
||||||
!setup_result) {
|
!setup_result) {
|
||||||
log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
|
log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
|
||||||
|
|
Loading…
Reference in a new issue