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
This commit is contained in:
Chaosmaster
2020-05-10 15:43:55 -04:00
committed by bigbiff
parent 3b3b634365
commit ff4f958182
7 changed files with 25 additions and 1 deletions
+1
View File
@@ -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");
+3
View File
@@ -2937,6 +2937,9 @@
<condition var1="tw_no_sha2" var2="0"/>
<data variable="tw_use_sha2"/>
</listitem>
<listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
<data variable="tw_unmount_system"/>
</listitem>
</listbox>
<checkbox>
+3
View File
@@ -719,5 +719,8 @@
<string name="include_kernel_log">Include Kernel Log</string>
<string name="sha2_chk">Use SHA2 for hashing</string>
<string name="unable_set_boot_slot">Error changing bootloader boot slot to {1}</string>
<string name="unmount_sys_install">Unmount System before installing a ZIP</string>
<string name="unmount_system">Unmounting System...</string>
<string name="unmount_system_err">Failed unmounting System</string>
</resources>
</language>
+3
View File
@@ -3150,6 +3150,9 @@
<condition var1="tw_no_sha2" var2="0"/>
<data variable="tw_use_sha2"/>
</listitem>
<listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
<data variable="tw_unmount_system"/>
</listitem>
</listbox>
<button style="main_button_half_height">
+3
View File
@@ -3640,6 +3640,9 @@
<condition var1="tw_no_sha2" var2="0"/>
<data variable="tw_use_sha2"/>
</listitem>
<listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
<data variable="tw_unmount_system"/>
</listitem>
</listbox>
<action>
+11 -1
View File
@@ -339,7 +339,7 @@ static int Run_Update_Binary(const char *path, ZipWrap *Zip, int* wipe_cache, zi
}
int TWinstall_zip(const char* path, int* wipe_cache) {
int ret_val, zip_verify = 1;
int ret_val, zip_verify = 1, unmount_system = 1;
if (strcmp(path, "error") == 0) {
LOGERR("Failed to get adb sideload file: '%s'\n", path);
@@ -359,6 +359,8 @@ int TWinstall_zip(const char* path, int* wipe_cache) {
}
}
DataManager::GetValue(TW_UNMOUNT_SYSTEM, unmount_system);
#ifndef TW_OEM_BUILD
DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
#endif
@@ -410,6 +412,14 @@ int TWinstall_zip(const char* path, int* wipe_cache) {
return INSTALL_CORRUPT;
}
if (unmount_system) {
gui_msg("unmount_system=Unmounting System...");
if(!PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), true)) {
gui_err("unmount_system_err=Failed unmounting System");
return -1;
}
}
time_t start, stop;
time(&start);
if (Zip.EntryExists(ASSUMED_UPDATE_BINARY_NAME)) {
+1
View File
@@ -140,6 +140,7 @@
#define TW_MILITARY_TIME "tw_military_time"
#define TW_USE_SHA2 "tw_use_sha2"
#define TW_NO_SHA2 "tw_no_sha2"
#define TW_UNMOUNT_SYSTEM "tw_unmount_system"
// Also used:
// tw_boot_is_mountable