dre: init: only process props for carrier devices

Change-Id: Ia32508c4c03ea6fd48bc82d60f702cae1e127bde
This commit is contained in:
Nick Reuter 2023-04-19 23:14:55 -05:00 committed by Albert Tang
parent 7e05eef029
commit 16981a495a
2 changed files with 44 additions and 7 deletions

View file

@ -43,6 +43,9 @@ TARGET_2ND_CPU_ABI2 := armeabi
TARGET_2ND_CPU_VARIANT := generic
TARGET_2ND_CPU_VARIANT_RUNTIME := kryo385
# Assert
TARGET_OTA_ASSERT_DEVICE := OnePlusN200,OnePlusN200TMO,dre
# Audio
AUDIO_FEATURE_ENABLED_DLKM := true
AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT := true

View file

@ -11,6 +11,22 @@
using android::base::GetProperty;
constexpr const char* BUILD_DESCRIPTION = "OnePlusN200TMO-user 12 SKQ1.210216.001 202304041604 release-keys";
constexpr const char* BUILD_FINGERPRINT = "OnePlus/OnePlusN200TMO/OnePlusN200TMO:12/SKQ1.210216.001/R.202304041604:user/release-keys";
constexpr const char* RO_PROP_SOURCES[] = {
nullptr,
"bootimage.",
"odm.",
"odm_dlkm.",
"product.",
"system.",
"system_dlkm.",
"system_ext.",
"vendor.",
"vendor_dlkm.",
};
/*
* SetProperty does not allow updating read only properties and as a result
* does not work for our use case. Write "OverrideProperty" to do practically
@ -27,6 +43,28 @@ void OverrideProperty(const char* name, const char* value) {
}
}
void OverrideCarrierProperties() {
const auto ro_prop_override = [](const char* source, const char* prop, const char* value,
bool product) {
std::string prop_name = "ro.";
if (product) prop_name += "product.";
if (source != nullptr) prop_name += source;
if (!product) prop_name += "build.";
prop_name += prop;
OverrideProperty(prop_name.c_str(), value);
};
for (const auto& source : RO_PROP_SOURCES) {
ro_prop_override(source, "model", "DE2118", true);
ro_prop_override(source, "device", "OnePlusN200TMO", true);
ro_prop_override(source, "fingerprint", BUILD_FINGERPRINT, false);
}
ro_prop_override(nullptr, "product", "OnePlusN200TMO", false);
ro_prop_override(nullptr, "description", BUILD_DESCRIPTION, false);
}
/*
* Only for read-only properties. Properties that can be wrote to more
* than once should be set in a typical init script (e.g. init.oplus.hw.rc)
@ -36,11 +74,7 @@ void vendor_load_properties() {
//auto device = GetProperty("ro.product.product.device", "");
auto prj_codename = GetProperty("ro.boot.project_codename", "");
if (prj_codename == "dre9") // Unlocked
OverrideProperty("ro.product.product.model", "DE2117");
else { // T-Mobile (dre8t) or Metro by T-Mobile (dre8m)
OverrideProperty("ro.product.product.model", "DE2118");
OverrideProperty("ro.product.product.device", "OnePlusN200TMO");
OverrideProperty("ro.product.product.name", "OnePlusN200TMO");
}
// T-Mobile (dre8t) or Metro by T-Mobile (dre8m)
if (prj_codename != "dre9")
OverrideCarrierProperties();
}