From 6ef6635ad3d5e8f6440e9ac2b67f1db8589e77b5 Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Thu, 21 Feb 2013 08:26:57 -0600 Subject: Check for root and root perms and offer to install/fix Also fix sort order for file selector by date and file sizes Change-Id: Idff9fe4232c19d4ed1082e78fabe6f921aa0a114 --- gui/action.cpp | 58 ++++++++++----- gui/devices/1024x600/res/ui.xml | 156 +++++++++++++++++++++++++++++++++++++-- gui/devices/1024x768/res/ui.xml | 144 ++++++++++++++++++++++++++++++++++++ gui/devices/1280x800/res/ui.xml | 144 ++++++++++++++++++++++++++++++++++++ gui/devices/1920x1200/res/ui.xml | 144 ++++++++++++++++++++++++++++++++++++ gui/devices/2560x1600/res/ui.xml | 144 ++++++++++++++++++++++++++++++++++++ gui/devices/320x480/res/ui.xml | 150 +++++++++++++++++++++++++++++++++++++ gui/devices/480x800/res/ui.xml | 150 +++++++++++++++++++++++++++++++++++++ gui/devices/480x854/res/ui.xml | 150 +++++++++++++++++++++++++++++++++++++ gui/devices/720x1280/res/ui.xml | 150 +++++++++++++++++++++++++++++++++++++ gui/devices/800x1280/res/ui.xml | 150 +++++++++++++++++++++++++++++++++++++ gui/devices/800x480/res/ui.xml | 144 ++++++++++++++++++++++++++++++++++++ gui/fileselector.cpp | 8 +- gui/gui.cpp | 4 + 14 files changed, 1665 insertions(+), 31 deletions(-) (limited to 'gui') diff --git a/gui/action.cpp b/gui/action.cpp index f1dac1c9b..ca968d088 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -341,26 +341,16 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */) DataManager::GetValue(TW_SIMULATE_ACTIONS, simulate); - if (function == "reboot") - { - //curtainClose(); this sometimes causes a crash - - sync(); - - if (arg == "recovery") - TWFunc::tw_reboot(rb_recovery); - else if (arg == "poweroff") - TWFunc::tw_reboot(rb_poweroff); - else if (arg == "bootloader") - TWFunc::tw_reboot(rb_bootloader); - else if (arg == "download") - TWFunc::tw_reboot(rb_download); - else - TWFunc::tw_reboot(rb_system); + if (function == "reboot") + { + //curtainClose(); this sometimes causes a crash - // This should never occur - return -1; - } + sync(); + DataManager::SetValue("tw_gui_done", 1); + DataManager::SetValue("tw_reboot_arg", arg); + + return 0; + } if (function == "home") { PageManager::SelectPackage("TWRP"); @@ -1143,6 +1133,36 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */) } } } + if (function == "installsu") + { + int op_status = 0; + + operation_start("Install SuperSU"); + if (simulate) { + simulate_progress_bar(); + } else { + if (!TWFunc::Install_SuperSU()) + op_status = 1; + } + + operation_end(op_status, simulate); + return 0; + } + if (function == "fixsu") + { + int op_status = 0; + + operation_start("Fixing Superuser Permissions"); + if (simulate) { + simulate_progress_bar(); + } else { + if (!TWFunc::Fix_su_Perms()) + op_status = 1; + } + + operation_end(op_status, simulate); + return 0; + } } else { diff --git a/gui/devices/1024x600/res/ui.xml b/gui/devices/1024x600/res/ui.xml index fbdf14e93..383774e12 100755 --- a/gui/devices/1024x600/res/ui.xml +++ b/gui/devices/1024x600/res/ui.xml @@ -649,14 +649,6 @@ - - - - Force MD5 check on all zips? - - - - @@ -975,6 +967,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -2682,6 +2716,7 @@ echo %tw_brightness_25% > "%tw_brightness_file%" tw_brightness_display=25% + tw_brightness=%tw_brightness_25% @@ -2694,6 +2729,7 @@ echo %tw_brightness_50% > "%tw_brightness_file%" tw_brightness_display=50% + tw_brightness=%tw_brightness_50% @@ -2706,6 +2742,7 @@ echo %tw_brightness_75% > "%tw_brightness_file%" tw_brightness_display=75% + tw_brightness=%tw_brightness_75% @@ -2718,6 +2755,7 @@ echo %tw_brightness_100% > "%tw_brightness_file%" tw_brightness_display=100% + tw_brightness=%tw_brightness_100% @@ -3891,5 +3929,107 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/1024x768/res/ui.xml b/gui/devices/1024x768/res/ui.xml index 025362a15..6395c7443 100644 --- a/gui/devices/1024x768/res/ui.xml +++ b/gui/devices/1024x768/res/ui.xml @@ -967,6 +967,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3887,5 +3929,107 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/1280x800/res/ui.xml b/gui/devices/1280x800/res/ui.xml index 9529d1107..c806b8517 100644 --- a/gui/devices/1280x800/res/ui.xml +++ b/gui/devices/1280x800/res/ui.xml @@ -967,6 +967,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3887,5 +3929,107 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/1920x1200/res/ui.xml b/gui/devices/1920x1200/res/ui.xml index 5fe7fd525..1947ffa69 100644 --- a/gui/devices/1920x1200/res/ui.xml +++ b/gui/devices/1920x1200/res/ui.xml @@ -967,6 +967,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3888,5 +3930,107 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/2560x1600/res/ui.xml b/gui/devices/2560x1600/res/ui.xml index 6d0e40558..e26bdb902 100644 --- a/gui/devices/2560x1600/res/ui.xml +++ b/gui/devices/2560x1600/res/ui.xml @@ -967,6 +967,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3887,5 +3929,107 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/320x480/res/ui.xml b/gui/devices/320x480/res/ui.xml index 38e7b1d34..58147d2aa 100644 --- a/gui/devices/320x480/res/ui.xml +++ b/gui/devices/320x480/res/ui.xml @@ -938,6 +938,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3830,5 +3872,113 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? + + + + + + This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/480x800/res/ui.xml b/gui/devices/480x800/res/ui.xml index 60ad8280c..572d1b92b 100644 --- a/gui/devices/480x800/res/ui.xml +++ b/gui/devices/480x800/res/ui.xml @@ -937,6 +937,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3829,5 +3871,113 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? + + + + + + This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml index a570faf72..09df8037c 100644 --- a/gui/devices/480x854/res/ui.xml +++ b/gui/devices/480x854/res/ui.xml @@ -936,6 +936,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3828,5 +3870,113 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? + + + + + + This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/720x1280/res/ui.xml b/gui/devices/720x1280/res/ui.xml index 79de4ca86..6d9f061c4 100644 --- a/gui/devices/720x1280/res/ui.xml +++ b/gui/devices/720x1280/res/ui.xml @@ -950,6 +950,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3842,5 +3884,113 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? + + + + + + This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/800x1280/res/ui.xml b/gui/devices/800x1280/res/ui.xml index 07ffec4e2..03e4e7001 100755 --- a/gui/devices/800x1280/res/ui.xml +++ b/gui/devices/800x1280/res/ui.xml @@ -938,6 +938,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3830,5 +3872,113 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? + + + + + + This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/devices/800x480/res/ui.xml b/gui/devices/800x480/res/ui.xml index f12c242e4..9501ad899 100755 --- a/gui/devices/800x480/res/ui.xml +++ b/gui/devices/800x480/res/ui.xml @@ -975,6 +975,48 @@ + + + + + + + %tw_action_text1% + + + + + + %tw_action_text2% + + + + + + + + + + tw_page_done=1 + + + + + + + %tw_action_param% + + + + + + + %tw_action_param% + %tw_action2_param% + + + + @@ -3895,5 +3937,107 @@ + + + + + + + + Install SuperSU? + + + + + + Your device does not appear to be rooted. + + + + + + Install SuperSU now? This will root your device. + + + + + + + Do Not Install + + tw_page_done=1 + + + + + + + tw_action=installsu + tw_action_text1=Installing SuperSU + tw_action_text2= + singleaction_page + + + + + + + Swipe to Install + + + + + + + + + + Fix Superuser Permissions? + + + + + + Root permissions appear to be lost. + + + + + + Fix root permissions now? + + + + + + (Fixes permissions on su binary & app) + + + + + + + Do Not Fix + + tw_page_done=1 + + + + + + + tw_action=fixsu + tw_action_text1=Fixing Root Permissions + tw_action_text2= + singleaction_page + + + + + + + Swipe to Fix Root + + diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index 66bf80f78..bc10f917d 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -790,19 +790,19 @@ bool GUIFileSelector::fileSort(FileData d1, FileData d2) case 3: // by size largest first if (d1.fileSize == d2.fileSize || d1.fileType == DT_DIR) // some directories report a different size than others - but this is not the size of the files inside the directory, so we just sort by name on directories return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) < 0); - return d1.fileSize > d2.fileSize; + return d1.fileSize < d2.fileSize; case -3: // by size smallest first if (d1.fileSize == d2.fileSize || d1.fileType == DT_DIR) // some directories report a different size than others - but this is not the size of the files inside the directory, so we just sort by name on directories return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) > 0); - return d1.fileSize < d2.fileSize; + return d1.fileSize > d2.fileSize; case 2: // by last modified date newest first if (d1.lastModified == d2.lastModified) return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) < 0); - return d1.lastModified > d2.lastModified; + return d1.lastModified < d2.lastModified; case -2: // by date oldest first if (d1.lastModified == d2.lastModified) return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) > 0); - return d1.lastModified < d2.lastModified; + return d1.lastModified > d2.lastModified; case -1: // by name descending return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) > 0); default: // should be a 1 - sort by name ascending diff --git a/gui/gui.cpp b/gui/gui.cpp index 7fd474a35..4788fe0df 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -423,6 +423,10 @@ runPages (void) PageManager::Render (); flip (); } + if (DataManager::GetIntValue("tw_gui_done") != 0) + { + break; + } } gGuiRunning = 0; -- cgit v1.2.3