Add flag for overwriting properties with system values
This adds the flag TW_OVERRIDE_SYSTEM_PROPS which can contain a ";" separated list of properties that should be overriden. A different source property can be defined by separating target and source using "=" Example: TW_OVERRIDE_SYSTEM_PROPS := "ro.build.product;ro.build.fingerprint=ro.system.build.fingerprint" This will override ro.build.product with the value of ro.build.product from system/build.prop. And also override ro.build.fingerprint with the value of ro.system.build.fingerprint. with their corresponding values from the system partition. Change-Id: Ibcd3e6ed51fa7f7195ad524e606a2b9542687e55
This commit is contained in:
26
twrp.cpp
26
twrp.cpp
@@ -147,6 +147,32 @@ int main(int argc, char **argv) {
|
||||
LOGINFO("SAR-DETECT: No build.prop found, falling back to %s\n", fallback_sar ? "SAR" : "Non-SAR");
|
||||
property_set("ro.twrp.sar", fallback_sar ? "1" : "0");
|
||||
}
|
||||
|
||||
// We are doing this here during SAR-detection, since we are mounting the system-partition anyway
|
||||
// This way we don't need to remount it later, just for overriding properties
|
||||
#if defined(TW_INCLUDE_LIBRESETPROP) && defined(TW_OVERRIDE_SYSTEM_PROPS)
|
||||
stringstream override_props(EXPAND(TW_OVERRIDE_SYSTEM_PROPS));
|
||||
string current_prop;
|
||||
while (getline(override_props, current_prop, ';')) {
|
||||
string other_prop;
|
||||
if (current_prop.find("=") != string::npos) {
|
||||
other_prop = current_prop.substr(current_prop.find("=") + 1);
|
||||
current_prop = current_prop.substr(0, current_prop.find("="));
|
||||
} else {
|
||||
other_prop = current_prop;
|
||||
}
|
||||
string sys_val = TWFunc::System_Property_Get(other_prop, SarPartitionManager, "/s");
|
||||
if (!sys_val.empty()) {
|
||||
LOGINFO("Overriding %s with value: \"%s\" from system property %s\n", current_prop.c_str(), sys_val.c_str(), other_prop.c_str());
|
||||
int error = TWFunc::Property_Override(current_prop, sys_val);
|
||||
if (error) {
|
||||
LOGERR("Failed overriding property %s, error_code: %d\n", current_prop.c_str(), error);
|
||||
}
|
||||
} else {
|
||||
LOGINFO("Not overriding %s with empty value from system property %s\n", current_prop.c_str(), other_prop.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SarPartitionManager.UnMount_By_Path("/s", false);
|
||||
} else {
|
||||
LOGINFO("SAR-DETECT: Could not mount system partition, falling back to %s\n", fallback_sar ? "SAR":"Non-SAR");
|
||||
|
||||
Reference in New Issue
Block a user