diff --git a/Android.mk b/Android.mk index c5b1f2cd..167ad4ff 100755 --- a/Android.mk +++ b/Android.mk @@ -166,6 +166,10 @@ ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) endif endif +ifneq ($(TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS),) + LOCAL_CFLAGS += -DTW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS='"$(TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS)"' +endif + ifeq ($(TW_USES_VENDOR_LIBS),true) LOCAL_CFLAGS += -DUSE_VENDOR_LIBS=1 endif diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 06619170..a53ccc02 100755 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -855,20 +855,22 @@ string TWFunc::Get_Current_Date() { } string TWFunc::System_Property_Get(string Prop_Name) { - return System_Property_Get(Prop_Name, PartitionManager, PartitionManager.Get_Android_Root_Path()); + return System_Property_Get(Prop_Name, PartitionManager, PartitionManager.Get_Android_Root_Path(), ""); } -string TWFunc::System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point) { +string TWFunc::System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point, string prop_file_name) { bool mount_state = PartitionManager.Is_Mounted_By_Path(Mount_Point); std::vector buildprop; string propvalue; if (!PartitionManager.Mount_By_Path(Mount_Point, true)) return propvalue; - string prop_file = Mount_Point + "/build.prop"; - if (!TWFunc::Path_Exists(prop_file)) - prop_file = Mount_Point + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel) + string prop_file = Mount_Point + "/system/" + prop_file_name; + if (!TWFunc::Path_Exists(prop_file)) { + LOGINFO("Unable to locate file: %s\n", prop_file.c_str()); + return propvalue; + } if (TWFunc::read_file(prop_file, buildprop) != 0) { - LOGINFO("Unable to open build.prop for getting '%s'.\n", Prop_Name.c_str()); + LOGINFO("Unable to open %s for getting '%s'.\n", prop_file_name.c_str(), Prop_Name.c_str()); DataManager::SetValue(TW_BACKUP_NAME, Get_Current_Date()); if (!mount_state) PartitionManager.UnMount_By_Path(Mount_Point, false); diff --git a/twrp-functions.hpp b/twrp-functions.hpp index 89311a2b..01afb7aa 100755 --- a/twrp-functions.hpp +++ b/twrp-functions.hpp @@ -96,7 +96,7 @@ public: static bool write_to_file(const string& fn, const std::vector lines); // write vector of strings line by line with newlines static bool Try_Decrypting_Backup(string Restore_Path, string Password); // true for success, false for failed to decrypt static string System_Property_Get(string Prop_Name); // Returns value of Prop_Name from reading /system/build.prop - static string System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point); // Returns value of Prop_Name from reading /system/build.prop + static string System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point, string prop_file_name); // Returns value of Prop_Name from reading provided prop file static string Get_Current_Date(void); // Returns the current date in ccyy-m-dd--hh-nn-ss format static void Auto_Generate_Backup_Name(); // Populates TW_BACKUP_NAME with a backup name based on current date and ro.build.display.id from /system/build.prop static void Fixup_Time_On_Boot(const string& time_paths = ""); // Fixes time on devices which need it (time_paths is a space separated list of paths to check for ats_* files) diff --git a/twrp.cpp b/twrp.cpp index aa09e2cd..4a7a3373 100644 --- a/twrp.cpp +++ b/twrp.cpp @@ -174,6 +174,11 @@ static void process_recovery_mode(twrpAdbBuFifo* adb_bu_fifo, bool skip_decrypti } else { stringstream override_props(EXPAND(TW_OVERRIDE_SYSTEM_PROPS)); string current_prop; + std::vector build_prop_list = {"build.prop"}; +#ifdef TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS + std::vector additional_build_prop_list = TWFunc::Split_String(TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS, ";"); + build_prop_list.insert(build_prop_list.end(), additional_build_prop_list.begin(), additional_build_prop_list.end()); +#endif while (getline(override_props, current_prop, ';')) { string other_prop; if (current_prop.find("=") != string::npos) { @@ -184,15 +189,19 @@ static void process_recovery_mode(twrpAdbBuFifo* adb_bu_fifo, bool skip_decrypti } other_prop = android::base::Trim(other_prop); current_prop = android::base::Trim(current_prop); - string sys_val = TWFunc::System_Property_Get(other_prop, PartitionManager, PartitionManager.Get_Android_Root_Path().c_str()); - 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); + + for (auto&& prop_file:build_prop_list) { + string sys_val = TWFunc::System_Property_Get(other_prop, PartitionManager, PartitionManager.Get_Android_Root_Path().c_str(), prop_file); + if (!sys_val.empty()) { + LOGINFO("Overriding %s with value: \"%s\" from system property %s from %s\n", current_prop.c_str(), sys_val.c_str(), other_prop.c_str(), prop_file.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); + } + break; + } else { + LOGINFO("Not overriding %s with empty value from system property %s from %s\n", current_prop.c_str(), other_prop.c_str(), prop_file.c_str()); } - } else { - LOGINFO("Not overriding %s with empty value from system property %s\n", current_prop.c_str(), other_prop.c_str()); } } PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);