From 915bbd225ed6df57ce1b99fbf207c2abbe9e493d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 6 Mar 2020 22:30:07 +0100 Subject: [PATCH 01/16] Fix building libuuid libuuid uses flock() which requires . Change-Id: I230a5d08ce90088d14db2f89a0843bf43029b3c7 --- libblkid/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libblkid/Android.mk b/libblkid/Android.mk index 42762e4e..38a192f9 100644 --- a/libblkid/Android.mk +++ b/libblkid/Android.mk @@ -44,7 +44,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libuuid LOCAL_MODULE_TAGS := optional #LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin -LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC +LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC -DHAVE_SYS_FILE_H LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-format -Wno-pointer-arith LOCAL_SRC_FILES = libuuid/src/clear.c \ libuuid/src/copy.c \ From ec350e9d0d9959e22647845011d7b2dc8075589d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 11 Mar 2020 19:19:12 +0100 Subject: [PATCH 02/16] init: ueventd already needs /acct Change-Id: Ifae7078aedc1a520ee003160fb17c8893041cb09 --- etc/init.rc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etc/init.rc b/etc/init.rc index e0889c44..fc32bb89 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -17,6 +17,10 @@ on early-init # Set the security context of /postinstall if present. restorecon /postinstall + # ueventd wants to write to /acct + mount cgroup none /acct cpuacct + mkdir /acct/uid + start ueventd service set_permissive /sbin/permissive.sh @@ -31,9 +35,6 @@ on init export ANDROID_DATA /data export EXTERNAL_STORAGE /sdcard - mount cgroup none /acct cpuacct - mkdir /acct/uid - mkdir /system mkdir /data mkdir /cache From 77a31917f2817d3f147dc6e727f52d537e11fe4d Mon Sep 17 00:00:00 2001 From: Mohd Faraz Date: Tue, 21 Apr 2020 18:56:44 +0530 Subject: [PATCH 03/16] partitionmanager: Unmount all directories mounted to same block * Like Xiaomi's some older devices uses cust as vendor and also mounts cust & vendor simultanously * This patch will unmount all directories mounted to same block Change-Id: Ic242e267a470b4d82098d847f74b807a461605c4 Signed-off-by: Mohd Faraz --- partitionmanager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index b2654698..3c2b1c65 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1285,6 +1285,7 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) { int TWPartitionManager::Wipe_By_Path(string Path) { std::vector::iterator iter; + std::vector < TWPartition * >::iterator iter1; int ret = false; bool found = false; string Local_Path = TWFunc::Get_Root_Path(Path); @@ -1292,6 +1293,14 @@ int TWPartitionManager::Wipe_By_Path(string Path) { // Iterate through all partitions for (iter = Partitions.begin(); iter != Partitions.end(); iter++) { if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path)) { + // iterate through all partitions since some legacy devices uses other partitions as vendor causes issues while wiping + (*iter)->Find_Actual_Block_Device(); + for (iter1 = Partitions.begin (); iter1 != Partitions.end (); iter1++) + { + (*iter1)->Find_Actual_Block_Device(); + if ((*iter)->Actual_Block_Device == (*iter1)->Actual_Block_Device && (*iter)->Mount_Point != (*iter1)->Mount_Point) + (*iter1)->UnMount(false); + } if (Path == "/and-sec") ret = (*iter)->Wipe_AndSec(); else From 76ef9f3c0492e1601a2b4dd4de38eff672ca2274 Mon Sep 17 00:00:00 2001 From: mauronofrio Date: Mon, 23 Dec 2019 20:29:24 +0100 Subject: [PATCH 04/16] Create a flag to include resetprop in the TWRP The flag is: TW_INCLUDE_RESETPROP := true Change-Id: I4d4d25a6d5bbd2330efd7f184d0f878a8cf0346e --- prebuilt/Android.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index d3307999..872deaa6 100644 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -577,9 +577,9 @@ ifeq ($(TW_INCLUDE_CRYPTO), true) endif endif -ifeq ($(TW_INCLUDE_REPACKTOOLS), true) +ifneq (,$(filter $(TW_INCLUDE_REPACKTOOLS) $(TW_INCLUDE_RESETPROP), true)) ifeq ($(wildcard external/magisk-prebuilt/Android.mk),) - $(warning Magisk repacking tools not found!) + $(warning Magisk prebuilt tools not found!) $(warning Please place https://github.com/TeamWin/external_magisk-prebuilt) $(warning into external/magisk-prebuilt) $(error magiskboot prebuilts not present; exiting) From 58f1a63767497a269fc616cc40582801b63c71c6 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Thu, 16 Jan 2020 23:03:56 +0800 Subject: [PATCH 05/16] Properly detect system-as-root ANDROID_ROOT environment variable is also used by other Android components thus it should ALWAYS be /system in order not to break other tools. On the other hand, AOSP does have a system property to indicate system-as-root, just make use of it. Change-Id: I7fc58a78db7abd05fac9000910169c370f5de62d --- partitionmanager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 3c2b1c65..141576f5 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -2840,10 +2840,9 @@ string TWPartitionManager::Get_Active_Slot_Display() { } string TWPartitionManager::Get_Android_Root_Path() { - std::string Android_Root = getenv("ANDROID_ROOT"); - if (Android_Root == "") - Android_Root = "/system"; - return Android_Root; + if (property_get_bool("ro.build.system_root_image", false)) + return "/system_root"; + return "/system"; } void TWPartitionManager::Remove_Uevent_Devices(const string& Mount_Point) { From 3b6827372e4313ebc1304597472f3235deda01d5 Mon Sep 17 00:00:00 2001 From: Chaosmaster Date: Sat, 25 Jan 2020 21:09:28 +0100 Subject: [PATCH 06/16] Set system-partition mount point to proper location This sets the system mount point to either /system_root or /system depending on whether SAR is detected or not irregardless of what is specified in fstab. This removes the need to edit fstab for SAR-builds and simplifies building unified (SAR/non-SAR) builds. Change-Id: I154fd76f842702be9e5d09005463c8e5f1d289a4 --- partition.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/partition.cpp b/partition.cpp index beb4a81d..9012d497 100644 --- a/partition.cpp +++ b/partition.cpp @@ -436,7 +436,10 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error, } else if (Is_File_System(Fstab_File_System)) { Find_Actual_Block_Device(); Setup_File_System(Display_Error); - if (Mount_Point == PartitionManager.Get_Android_Root_Path()) { + if (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root") { + Mount_Point = PartitionManager.Get_Android_Root_Path(); + Backup_Path = Mount_Point; + Storage_Path = Mount_Point; Display_Name = "System"; Backup_Display_Name = Display_Name; Storage_Name = Display_Name; From 3b3b634365f907bb94c0bcd72aac7013ee2eb0e8 Mon Sep 17 00:00:00 2001 From: Chaosmaster Date: Sat, 25 Jan 2020 22:51:54 +0100 Subject: [PATCH 07/16] ORS Make mount/unmount system mount system_root on SAR Change-Id: Ibf8d4d61e6cbb132786f5f9aa23ec91b49bcab89 --- openrecoveryscript.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp index 1de08707..6d762986 100755 --- a/openrecoveryscript.cpp +++ b/openrecoveryscript.cpp @@ -301,6 +301,8 @@ int OpenRecoveryScript::run_script_file(void) { strcat(mount, value); } else strcpy(mount, value); + if (!strcmp(mount, "/system")) + strcpy(mount, PartitionManager.Get_Android_Root_Path().c_str()); if (PartitionManager.Mount_By_Path(mount, true)) gui_msg(Msg("mounted=Mounted '{1}'")(mount)); } else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) { @@ -311,6 +313,8 @@ int OpenRecoveryScript::run_script_file(void) { strcat(mount, value); } else strcpy(mount, value); + if (!strcmp(mount, "/system")) + strcpy(mount, PartitionManager.Get_Android_Root_Path().c_str()); if (PartitionManager.UnMount_By_Path(mount, true)) gui_msg(Msg("unmounted=Unounted '{1}'")(mount)); } else if (strcmp(command, "set") == 0) { From ff4f958182e710c64143d876b8ccc40259d2bea8 Mon Sep 17 00:00:00 2001 From: Chaosmaster Date: Sun, 26 Jan 2020 15:38:11 +0100 Subject: [PATCH 08/16] Add option to automatically unmount system before installing ZIP This adds the option to automatically unmount the system partition before installing a ZIP-file. This option is enabled by default, This is usefull on SAR-devices where system is mounted as system_root and ZIPs (i.e. Magisk) try to unmount system instead of system_root and fail to install. Change-Id: Id94ae658964679e23aa7fa137e07edf74ee073df --- data.cpp | 1 + gui/theme/common/landscape.xml | 3 +++ gui/theme/common/languages/en.xml | 3 +++ gui/theme/common/portrait.xml | 3 +++ gui/theme/common/watch.xml | 3 +++ twinstall.cpp | 12 +++++++++++- variables.h | 1 + 7 files changed, 25 insertions(+), 1 deletion(-) diff --git a/data.cpp b/data.cpp index 088dbda6..b1e8404b 100755 --- a/data.cpp +++ b/data.cpp @@ -783,6 +783,7 @@ void DataManager::SetDefaultValues() #else mPersist.SetValue(TW_NO_SHA2, "1"); #endif + mPersist.SetValue(TW_UNMOUNT_SYSTEM, "1"); #ifdef TW_NO_SCREEN_TIMEOUT mConst.SetValue("tw_screen_timeout_secs", "0"); diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml index 8244c461..230b72f7 100755 --- a/gui/theme/common/landscape.xml +++ b/gui/theme/common/landscape.xml @@ -2937,6 +2937,9 @@ + + + diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml index 4a0ac7fd..3769da50 100755 --- a/gui/theme/common/languages/en.xml +++ b/gui/theme/common/languages/en.xml @@ -719,5 +719,8 @@ Include Kernel Log Use SHA2 for hashing Error changing bootloader boot slot to {1} + Unmount System before installing a ZIP + Unmounting System... + Failed unmounting System diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml index e014cc53..83704146 100755 --- a/gui/theme/common/portrait.xml +++ b/gui/theme/common/portrait.xml @@ -3150,6 +3150,9 @@ + + +