summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2018-08-24 18:17:36 +0200
committerEthan Yonker <dees_troy@teamw.in>2018-08-24 18:17:39 +0200
commit58f2132bc3954fc704787d477500a209eedb8e29 (patch)
treeeb0f79aacd68724b0c0c091018384ef924380f47 /install.cpp
parentRemove remaining pieces of supersu (diff)
parentSnap for 4745538 from 723056a83f8c8b15af02d9c302862dbb2304ea8c to pi-release (diff)
downloadandroid_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.gz
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.bz2
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.lz
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.xz
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.zst
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.zip
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/install.cpp b/install.cpp
index 4848755ab..5d7bda73c 100644
--- a/install.cpp
+++ b/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";