diff options
Diffstat (limited to 'gui')
-rwxr-xr-x | gui/action.cpp | 70 | ||||
-rw-r--r-- | gui/objects.hpp | 1 | ||||
-rwxr-xr-x | gui/theme/common/landscape.xml | 12 | ||||
-rwxr-xr-x | gui/theme/common/languages/en.xml | 4 | ||||
-rwxr-xr-x | gui/theme/common/portrait.xml | 12 | ||||
-rwxr-xr-x | gui/theme/common/watch.xml | 12 |
6 files changed, 98 insertions, 13 deletions
diff --git a/gui/action.cpp b/gui/action.cpp index c4e78cf26..ccb7e344e 100755 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -231,6 +231,7 @@ GUIAction::GUIAction(xml_node<>* node) ADD_ACTION(twcmd); ADD_ACTION(setbootslot); ADD_ACTION(installapp); + ADD_ACTION(uninstalltwrpsystemapp); ADD_ACTION(repackimage); ADD_ACTION(fixabrecoverybootloop); } @@ -1919,19 +1920,9 @@ int GUIAction::checkforapp(std::string arg __unused) DataManager::SetValue("tw_app_install_status", 1); // 0 = no status, 1 = not installed, 2 = already installed or do not install goto exit; } - if (PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), false)) { - string base_path = PartitionManager.Get_Android_Root_Path(); - if (TWFunc::Path_Exists(PartitionManager.Get_Android_Root_Path() + "/system")) - base_path += "/system"; // For devices with system as a root file system (e.g. Pixel) - string install_path = base_path + "/priv-app"; - if (!TWFunc::Path_Exists(install_path)) - install_path = base_path + "/app"; - install_path += "/twrpapp"; - if (TWFunc::Path_Exists(install_path)) { - LOGINFO("App found at '%s'\n", install_path.c_str()); - DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install - goto exit; - } + if (TWFunc::Is_TWRP_App_In_System()) { + DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed or do not install + goto exit; } if (PartitionManager.Mount_By_Path("/data", false)) { const char parent_path[] = "/data/app"; @@ -2058,6 +2049,59 @@ exit: return 0; } +int GUIAction::uninstalltwrpsystemapp(std::string arg __unused) +{ + int op_status = 1; + operation_start("Uninstall TWRP System App"); + if (!simulate) + { + int Mount_System_RO = DataManager::GetIntValue("tw_mount_system_ro"); + TWPartition* Part = PartitionManager.Find_Partition_By_Path(PartitionManager.Get_Android_Root_Path()); + if (!Part) { + LOGERR("Unabled to find system partition.\n"); + goto exit; + } + if (!Part->UnMount(true)) { + goto exit; + } + if (Mount_System_RO > 0) { + DataManager::SetValue("tw_mount_system_ro", 0); + Part->Change_Mount_Read_Only(false); + } + if (Part->Mount(true)) { + string base_path = PartitionManager.Get_Android_Root_Path(); + if (TWFunc::Path_Exists(PartitionManager.Get_Android_Root_Path() + "/system")) + base_path += "/system"; // For devices with system as a root file system (e.g. Pixel) + string uninstall_path = base_path + "/priv-app"; + if (!TWFunc::Path_Exists(uninstall_path)) + uninstall_path = base_path + "/app"; + uninstall_path += "/twrpapp"; + if (TWFunc::Path_Exists(uninstall_path)) { + LOGINFO("Uninstalling TWRP App from '%s'\n", uninstall_path.c_str()); + if (TWFunc::removeDir(uninstall_path, false) == 0) { + sync(); + op_status = 0; + DataManager::SetValue("tw_app_installed_in_system", 0); + DataManager::SetValue("tw_app_install_status", 0); + } else { + LOGERR("Unable to remove TWRP app from system.\n"); + } + } else { + LOGINFO("didn't find TWRP app in '%s'\n", uninstall_path.c_str()); + } + } + Part->UnMount(true); + if (Mount_System_RO > 0) { + DataManager::SetValue("tw_mount_system_ro", Mount_System_RO); + Part->Change_Mount_Read_Only(true); + } + } else + simulate_progress_bar(); +exit: + operation_end(0); + return 0; +} + int GUIAction::repackimage(std::string arg __unused) { int op_status = 1; diff --git a/gui/objects.hpp b/gui/objects.hpp index 2e306e0f7..3f7241831 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -367,6 +367,7 @@ protected: int twcmd(std::string arg); int setbootslot(std::string arg); int installapp(std::string arg); + int uninstalltwrpsystemapp(std::string arg); int repackimage(std::string arg); int fixabrecoverybootloop(std::string arg); diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml index bb9878fd6..8244c461e 100755 --- a/gui/theme/common/landscape.xml +++ b/gui/theme/common/landscape.xml @@ -3433,6 +3433,18 @@ <action function="page">confirm_action</action> </actions> </listitem> + <listitem name="{@uninstall_twrp_system_app=Uninstall TWRP App from System}"> + <condition var1="tw_app_installed_in_system" var2="1"/> + <actions> + <action function="set">tw_back=advanced</action> + <action function="set">tw_action=uninstalltwrpsystemapp</action> + <action function="set">tw_text1={@uninstall_twrp_system_app_confirm=Uninstall TWRP App from System?}</action> + <action function="set">tw_action_text1={@uninstalling_twrp_system_app=Uninstalling TWRP App from System...}</action> + <action function="set">tw_complete_text1={@uninstall_twrp_system_app_complete=Uninstall TWRP App from System Complete}</action> + <action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action> + <action function="page">confirm_action</action> + </actions> + </listitem> </listbox> <action> diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml index 9b525f063..4a0ac7fdc 100755 --- a/gui/theme/common/languages/en.xml +++ b/gui/theme/common/languages/en.xml @@ -126,6 +126,10 @@ <string name="reboot_install_app_system">Install as a System App</string> <string name="reboot_installing_app">Installing App...</string> <string name="swipe_to_install_app">Swipe to Install TWRP App</string> + <string name="uninstall_twrp_system_app">Uninstall TWRP App from System</string> + <string name="uninstall_twrp_system_app_confirm">Uninstall TWRP App from System?</string> + <string name="uninstalling_twrp_system_app">Uninstalling TWRP App from System...</string> + <string name="uninstall_twrp_system_app_complete">Uninstall TWRP App from System Complete</string> <string name="swipe_flash">Swipe to confirm Flash</string> <string name="confirm_action">Confirm Action</string> <string name="back_cancel">Press back button to cancel.</string> diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml index 86b211132..e014cc53a 100755 --- a/gui/theme/common/portrait.xml +++ b/gui/theme/common/portrait.xml @@ -3594,6 +3594,18 @@ <action function="page">confirm_action</action> </actions> </listitem> + <listitem name="{@uninstall_twrp_system_app=Uninstall TWRP App from System}"> + <condition var1="tw_app_installed_in_system" var2="1"/> + <actions> + <action function="set">tw_back=advanced</action> + <action function="set">tw_action=uninstalltwrpsystemapp</action> + <action function="set">tw_text1={@uninstall_twrp_system_app_confirm=Uninstall TWRP App from System?}</action> + <action function="set">tw_action_text1={@uninstalling_twrp_system_app=Uninstalling TWRP App from System...}</action> + <action function="set">tw_complete_text1={@uninstall_twrp_system_app_complete=Uninstall TWRP App from System Complete}</action> + <action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action> + <action function="page">confirm_action</action> + </actions> + </listitem> </listbox> <action> diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml index fcb00bccf..f5d32228d 100755 --- a/gui/theme/common/watch.xml +++ b/gui/theme/common/watch.xml @@ -4205,6 +4205,18 @@ <action function="page">confirm_action</action> </actions> </listitem> + <listitem name="{@uninstall_twrp_system_app=Uninstall TWRP App from System}"> + <condition var1="tw_app_installed_in_system" var2="1"/> + <actions> + <action function="set">tw_back=advanced</action> + <action function="set">tw_action=uninstalltwrpsystemapp</action> + <action function="set">tw_text1={@uninstall_twrp_system_app_confirm=Uninstall TWRP App from System?}</action> + <action function="set">tw_action_text1={@uninstalling_twrp_system_app=Uninstalling TWRP App from System...}</action> + <action function="set">tw_complete_text1={@uninstall_twrp_system_app_complete=Uninstall TWRP App from System Complete}</action> + <action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action> + <action function="page">confirm_action</action> + </actions> + </listitem> </listbox> <button> |