Make ro.product.cpu.abilist* to be fetched dynamically

Basically, ro.product.cpu.abilist* are defined by
ro.vendor.cpu.abilist*. And they can be overried by
ro.odm.cpu.abilist* and ro.product.cpu.abilist*.
ro.system.cpu.abilist* are for fallback if others are no defined.

Bug: 176520383
Test: check the result by flashing aosp_arm64-userdebug on
Test: aosp_blueline-user and aosp_blueline-user hacked by
Test: 64-bits-only
Change-Id: I01ae01af099a4ec8fe3d4525edecc233a477ff60
This commit is contained in:
SzuWei Lin 2020-12-31 16:52:39 +08:00
parent f3f83ace67
commit 0061d4da01
1 changed files with 64 additions and 0 deletions

View File

@ -890,6 +890,69 @@ static void property_derive_build_fingerprint() {
}
}
// If the ro.product.cpu.abilist* properties have not been explicitly
// set, derive them from ro.${partition}.product.cpu.abilist* properties.
static void property_initialize_ro_cpu_abilist() {
// From high to low priority.
const char* kAbilistSources[] = {
"product",
"odm",
"vendor",
"system",
};
const std::string EMPTY = "";
const char* kAbilistProp = "ro.product.cpu.abilist";
const char* kAbilist32Prop = "ro.product.cpu.abilist32";
const char* kAbilist64Prop = "ro.product.cpu.abilist64";
// If the properties are defined explicitly, just use them.
if (GetProperty(kAbilistProp, EMPTY) != EMPTY) {
return;
}
// Find the first source defining these properties by order.
std::string abilist32_prop_val;
std::string abilist64_prop_val;
for (const auto& source : kAbilistSources) {
const auto abilist32_prop = std::string("ro.") + source + ".product.cpu.abilist32";
const auto abilist64_prop = std::string("ro.") + source + ".product.cpu.abilist64";
abilist32_prop_val = GetProperty(abilist32_prop, EMPTY);
abilist64_prop_val = GetProperty(abilist64_prop, EMPTY);
// The properties could be empty on 32-bit-only or 64-bit-only devices,
// but we cannot identify a property is empty or undefined by GetProperty().
// So, we assume both of these 2 properties are empty as undefined.
if (abilist32_prop_val != EMPTY || abilist64_prop_val != EMPTY) {
break;
}
}
// Merge ABI lists for ro.product.cpu.abilist
auto abilist_prop_val = abilist64_prop_val;
if (abilist32_prop_val != EMPTY) {
if (abilist_prop_val != EMPTY) {
abilist_prop_val += ",";
}
abilist_prop_val += abilist32_prop_val;
}
// Set these properties
const std::pair<const char*, const std::string&> set_prop_list[] = {
{kAbilistProp, abilist_prop_val},
{kAbilist32Prop, abilist32_prop_val},
{kAbilist64Prop, abilist64_prop_val},
};
for (const auto& [prop, prop_val] : set_prop_list) {
LOG(INFO) << "Setting property '" << prop << "' to '" << prop_val << "'";
std::string error;
uint32_t res = PropertySet(prop, prop_val, &error);
if (res != PROP_SUCCESS) {
LOG(ERROR) << "Error setting property '" << prop << "': err=" << res << " (" << error
<< ")";
}
}
}
void PropertyLoadBootDefaults() {
// We read the properties and their values into a map, in order to always allow properties
// loaded in the later property files to override the properties in loaded in the earlier
@ -974,6 +1037,7 @@ void PropertyLoadBootDefaults() {
property_initialize_ro_product_props();
property_derive_build_fingerprint();
property_initialize_ro_cpu_abilist();
update_sys_usb_config();
}