Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 961d20e0 authored by Ethan Yonker's avatar Ethan Yonker Committed by Dees Troy
Browse files

Make system read only show no matter what on first TWRP boot

Initial value for tw_mount_system_ro is now 2. If the value of
tw_mount_system_ro is 2 during boot, then we will show the system
read only prompt and ignore the value from the lifetime writes
check.

Note: Changed the value of FILE_VERSION which will trigger the
data manager to throw out previous settings and start with default
values so that existing TWRP users will get the prompt at least
once.

Change-Id: I447767b64617f855156a19a5dc15c4ece6dff7b8
parent ec009e8c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ extern "C"
	void gui_notifyVarChange(const char *name, const char* value);
}

#define FILE_VERSION 0x00010001
#define FILE_VERSION 0x00010010

using namespace std;

@@ -881,7 +881,7 @@ void DataManager::SetDefaultValues()
	mConstValues.insert(make_pair("tw_has_mtp", "0"));
	mConstValues.insert(make_pair("tw_mtp_enabled", "0"));
#endif
	mValues.insert(make_pair("tw_mount_system_ro", make_pair("1", 1)));
	mValues.insert(make_pair("tw_mount_system_ro", make_pair("2", 1)));
	mValues.insert(make_pair("tw_never_show_system_ro_page", make_pair("0", 1)));

	pthread_mutex_unlock(&m_valuesLock);
+1 −1
Original line number Diff line number Diff line
@@ -3664,7 +3664,7 @@

			<object type="text">
				<placement x="%center_x%" y="%row1_text_y%" placement="5" />
				<text>TWRP has detected an unmodified system partition.</text>
				<text>Keep System Read Only?</text>
			</object>

			<object type="text">
+1 −1
Original line number Diff line number Diff line
@@ -3675,7 +3675,7 @@

			<object type="text">
				<placement x="%center_x%" y="%row1_header_y%" placement="5" />
				<text>TWRP has detected an unmodified system partition.</text>
				<text>Keep System Read Only?</text>
			</object>

			<object type="text">
+1 −1
Original line number Diff line number Diff line
@@ -3664,7 +3664,7 @@

			<object type="text">
				<placement x="%center_x%" y="%row1_header_y%" placement="5" />
				<text>TWRP has detected an unmodified system partition.</text>
				<text>Keep System Read Only?</text>
			</object>

			<object type="text">
+8 −9
Original line number Diff line number Diff line
@@ -335,18 +335,17 @@ int main(int argc, char **argv) {
	// Check if system has never been changed
	TWPartition* sys = PartitionManager.Find_Partition_By_Path("/system");
	if (sys) {
		if (DataManager::GetIntValue("tw_mount_system_ro") != 0) {
			if (sys->Check_Lifetime_Writes() == 0) {
		if ((DataManager::GetIntValue("tw_mount_system_ro") == 0 && sys->Check_Lifetime_Writes() == 0) || DataManager::GetIntValue("tw_mount_system_ro") == 2) {
			if (DataManager::GetIntValue("tw_never_show_system_ro_page") == 0) {
				DataManager::SetValue("tw_back", "main");
				if (gui_startPage("system_readonly", 1, 1) != 0) {
					LOGERR("Failed to start system_readonly GUI page.\n");
				}
				}
			} else {
				DataManager::SetValue("tw_mount_system_ro", 0);
			} else if (DataManager::GetIntValue("tw_mount_system_ro") == 0) {
				sys->Change_Mount_Read_Only(false);
			}
		} else if (DataManager::GetIntValue("tw_mount_system_ro") == 1) {
			// Do nothing, user selected to leave system read only
		} else {
			sys->Change_Mount_Read_Only(false);
		}