recovery: Allow separating device asserts with a colon too

* android::base::Split already supports multiple separators

* Make FINGERPRING_SEPARATOR a #define so that we can easily
  append the other separator. Why even was it ever a char* ?

  Note that we cannot directly make FINGERPRINT_SEPARATOR use ':'
  as a separator because, as the name suggests, it's also used to
  split build fingerprints which include ':' as a valid character.

Change-Id: I101e394d8e9fd7f2cbfcf01314e9bda38146c7d5
This commit is contained in:
Alessandro Astone 2021-11-01 17:47:07 +01:00 committed by zlewchan
parent 88a154d769
commit d1d96d7d72

View file

@ -71,7 +71,7 @@ static_assert(kRecoveryApiVersion == RECOVERY_API_VERSION, "Mismatching recovery
static constexpr int VERIFICATION_PROGRESS_TIME = 60;
static constexpr float VERIFICATION_PROGRESS_FRACTION = 0.25;
// The charater used to separate dynamic fingerprints. e.x. sargo|aosp-sargo
static const char* FINGERPRING_SEPARATOR = "|";
#define FINGERPRING_SEPARATOR "|"
static constexpr auto&& RELEASE_KEYS_TAG = "release-keys";
// If brick packages are smaller than |MEMORY_PACKAGE_LIMIT|, read the entire package into memory
static constexpr size_t MEMORY_PACKAGE_LIMIT = 1024 * 1024;
@ -221,7 +221,7 @@ bool CheckPackageMetadata(const std::map<std::string, std::string>& metadata, Ot
auto device = android::base::GetProperty("ro.product.device", "");
auto pkg_device = get_value(metadata, "pre-device");
// device name can be a | separated list, so need to check
if (pkg_device.empty() || !isInStringList(device, pkg_device, FINGERPRING_SEPARATOR)) {
if (pkg_device.empty() || !isInStringList(device, pkg_device, FINGERPRING_SEPARATOR ":")) {
LOG(ERROR) << "Package is for product " << pkg_device << " but expected " << device;
return false;
}