aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2017-08-17 18:42:57 -0500
committerTianjie Xu2017-08-22 14:05:52 -0500
commit69b9649e9bfafc2ddb5aa4dd609895b1fc097364 (patch)
treedd4d2446f55e23c77ff671317d66784986b88bda /install.cpp
parentb4bc57ed39b4ae2e44cf7a1a1e716711a4f9af14 (diff)
downloadplatform-bootable-recovery-69b9649e9bfafc2ddb5aa4dd609895b1fc097364.tar.gz
platform-bootable-recovery-69b9649e9bfafc2ddb5aa4dd609895b1fc097364.tar.xz
platform-bootable-recovery-69b9649e9bfafc2ddb5aa4dd609895b1fc097364.zip
Allow comparison against multi serial nums for A/B package
The metadata file now can have multiple serial numbers in the format: serialno=serialno1|serialno2|serialno3 ... Verifier will pass the check if the device serial number matches any of these numbers. Bug: 64802465 Test: Create a metadata file with 1000 numbers and sideload in sailfish. The checker detects both match and mismatch cases. Change-Id: I3f12b75e15f4179df260778e37f4563d65db0fa8
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/install.cpp b/install.cpp
index 7fbf5c01..1220c6ab 100644
--- a/install.cpp
+++ b/install.cpp
@@ -148,13 +148,23 @@ static int check_newer_ab_build(ZipArchiveHandle zip) {
148 return INSTALL_ERROR; 148 return INSTALL_ERROR;
149 } 149 }
150 150
151 // We allow the package to not have any serialno, but if it has a non-empty 151 // We allow the package to not have any serialno; and we also allow it to carry multiple serial
152 // value it should match. 152 // numbers split by "|"; e.g. serialno=serialno1|serialno2|serialno3 ... We will fail the
153 // verification if the device's serialno doesn't match any of these carried numbers.
153 value = android::base::GetProperty("ro.serialno", ""); 154 value = android::base::GetProperty("ro.serialno", "");
154 const std::string& pkg_serial_no = metadata["serialno"]; 155 const std::string& pkg_serial_no = metadata["serialno"];
155 if (!pkg_serial_no.empty() && pkg_serial_no != value) { 156 if (!pkg_serial_no.empty()) {
156 LOG(ERROR) << "Package is for serial " << pkg_serial_no; 157 bool match = false;
157 return INSTALL_ERROR; 158 for (const std::string& number : android::base::Split(pkg_serial_no, "|")) {
159 if (value == android::base::Trim(number)) {
160 match = true;
161 break;
162 }
163 }
164 if (!match) {
165 LOG(ERROR) << "Package is for serial " << pkg_serial_no;
166 return INSTALL_ERROR;
167 }
158 } 168 }
159 169
160 if (metadata["ota-type"] != "AB") { 170 if (metadata["ota-type"] != "AB") {