Merge AOSP android-9.0.0_r3
Fix conflicts and make it build in 5.1, 6.0, 7.1, 8.1, and 9.0 Change-Id: Ida0a64c29ff27d339b7f42a18d820930964ac6e4
This commit is contained in:
29
install.cpp
29
install.cpp
@@ -49,9 +49,9 @@
|
||||
#include <ziparchive/zip_archive.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "error_code.h"
|
||||
#include "otautil/SysUtil.h"
|
||||
#include "otautil/ThermalUtil.h"
|
||||
#include "otautil/error_code.h"
|
||||
#include "private/install.h"
|
||||
#include "roots.h"
|
||||
#include "ui.h"
|
||||
@@ -148,13 +148,23 @@ static int check_newer_ab_build(ZipArchiveHandle zip) {
|
||||
return INSTALL_ERROR;
|
||||
}
|
||||
|
||||
// We allow the package to not have any serialno, but if it has a non-empty
|
||||
// value it should match.
|
||||
// We allow the package to not have any serialno; and we also allow it to carry multiple serial
|
||||
// numbers split by "|"; e.g. serialno=serialno1|serialno2|serialno3 ... We will fail the
|
||||
// verification if the device's serialno doesn't match any of these carried numbers.
|
||||
value = android::base::GetProperty("ro.serialno", "");
|
||||
const std::string& pkg_serial_no = metadata["serialno"];
|
||||
if (!pkg_serial_no.empty() && pkg_serial_no != value) {
|
||||
LOG(ERROR) << "Package is for serial " << pkg_serial_no;
|
||||
return INSTALL_ERROR;
|
||||
if (!pkg_serial_no.empty()) {
|
||||
bool match = false;
|
||||
for (const std::string& number : android::base::Split(pkg_serial_no, "|")) {
|
||||
if (value == android::base::Trim(number)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
LOG(ERROR) << "Package is for serial " << pkg_serial_no;
|
||||
return INSTALL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata["ota-type"] != "AB") {
|
||||
@@ -258,7 +268,7 @@ int update_binary_command(const std::string& package, ZipArchiveHandle zip,
|
||||
|
||||
*cmd = {
|
||||
binary_path,
|
||||
EXPAND(RECOVERY_API_VERSION), // defined in Android.mk
|
||||
std::to_string(kRecoveryApiVersion),
|
||||
std::to_string(status_fd),
|
||||
package,
|
||||
};
|
||||
@@ -299,6 +309,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
|
||||
if (ret) {
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
log_buffer->push_back(android::base::StringPrintf("error: %d", kUpdateBinaryCommandFailure));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -363,6 +374,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
PLOG(ERROR) << "Failed to fork update binary";
|
||||
log_buffer->push_back(android::base::StringPrintf("error: %d", kForkUpdateBinaryFailure));
|
||||
return INSTALL_ERROR;
|
||||
}
|
||||
|
||||
@@ -551,6 +563,7 @@ static int really_install_package(const std::string& path, bool* wipe_cache, boo
|
||||
MemMapping map;
|
||||
if (!map.MapFile(path)) {
|
||||
LOG(ERROR) << "failed to map file";
|
||||
log_buffer->push_back(android::base::StringPrintf("error: %d", kMapFileFailure));
|
||||
return INSTALL_CORRUPT;
|
||||
}
|
||||
|
||||
@@ -618,7 +631,7 @@ int install_package(const std::string& path, bool* wipe_cache, const std::string
|
||||
std::chrono::duration<double> duration = std::chrono::system_clock::now() - start;
|
||||
int time_total = static_cast<int>(duration.count());
|
||||
|
||||
bool has_cache = volume_for_path("/cache") != nullptr;
|
||||
bool has_cache = volume_for_mount_point("/cache") != nullptr;
|
||||
// Skip logging the uncrypt_status on devices without /cache.
|
||||
if (has_cache) {
|
||||
static constexpr const char* UNCRYPT_STATUS = "/cache/recovery/uncrypt_status";
|
||||
|
||||
Reference in New Issue
Block a user