From 0c324685f389e0e432471916a3b0aa6f79a9e7b8 Mon Sep 17 00:00:00 2001 From: Smooth E Date: Fri, 10 Nov 2023 23:30:45 +0300 Subject: [PATCH] fix(permissions activity): Start permissions request activity in single top new task mode --- .idea/deploymentTargetDropDown.xml | 17 ----------------- .../wirelessDebuggingSwitch/IUserService.aidl | 1 + .../GrantPermissionsActivity.kt | 14 ++++++++++---- .../wirelessDebuggingSwitch/SettingsActivity.kt | 7 ++++++- app/src/main/res/values/keys.xml | 2 +- .../res/xml/preferences_kde_integration.xml | 1 + app/src/main/res/xml/preferences_prefixing.xml | 1 + 7 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index d41deaf..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/aidl/com/smoothie/wirelessDebuggingSwitch/IUserService.aidl b/app/src/main/aidl/com/smoothie/wirelessDebuggingSwitch/IUserService.aidl index 51592cb..2700253 100644 --- a/app/src/main/aidl/com/smoothie/wirelessDebuggingSwitch/IUserService.aidl +++ b/app/src/main/aidl/com/smoothie/wirelessDebuggingSwitch/IUserService.aidl @@ -20,4 +20,5 @@ interface IUserService { /** Returns Wireless ADB port number or -1 if Wireless ADB is disabled */ int getWirelessAdbPort() = 1; + } diff --git a/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/GrantPermissionsActivity.kt b/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/GrantPermissionsActivity.kt index 026ecfe..6a64b58 100644 --- a/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/GrantPermissionsActivity.kt +++ b/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/GrantPermissionsActivity.kt @@ -208,13 +208,19 @@ class GrantPermissionsActivity : CollapsingToolbarActivity( private fun restartAppForRootAccessRefresh() { val manager = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager val time = System.currentTimeMillis() + 100 - val intent = PendingIntent.getActivity( + val intent = requireActivity().intent + intent.flags = + Intent.FLAG_ACTIVITY_CLEAR_TOP or + Intent.FLAG_ACTIVITY_SINGLE_TOP or + Intent.FLAG_ACTIVITY_NEW_TASK + + val pendingIntent = PendingIntent.getActivity( requireActivity().baseContext, 0, - requireActivity().intent, - requireActivity().intent.flags + intent, + PendingIntent.FLAG_IMMUTABLE ) - manager.set(AlarmManager.RTC, time, intent) + manager.set(AlarmManager.RTC, time, pendingIntent) Process.killProcess(Process.myPid()) } diff --git a/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/SettingsActivity.kt b/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/SettingsActivity.kt index 1974da5..ba61df7 100644 --- a/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/SettingsActivity.kt +++ b/app/src/main/java/com/smoothie/wirelessDebuggingSwitch/SettingsActivity.kt @@ -4,6 +4,7 @@ import android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.content.Intent +import android.os.Bundle import android.widget.Toast import androidx.preference.Preference import androidx.preference.Preference.OnPreferenceClickListener @@ -68,9 +69,13 @@ class SettingsActivity : ApplicationPreferenceActivity( preferencePrefixData.forceUpdate() } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + GrantPermissionsActivity.startIfNeeded(this) + } + override fun onPreferencesCreated(preferenceFragment: PreferenceFragment) { super.onPreferencesCreated(preferenceFragment) - GrantPermissionsActivity.startIfNeeded(this) val kdeConnectInstalled = KdeConnect.isInstalled(this) var preferenceKey: String diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 99c4bed..96f6433 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -1,6 +1,6 @@ - asked_shizuku_permission + skip_permissions_activity enable_kde_connect prefix_connection_data connection_data_prefix diff --git a/app/src/main/res/xml/preferences_kde_integration.xml b/app/src/main/res/xml/preferences_kde_integration.xml index c65a192..cf51a7d 100644 --- a/app/src/main/res/xml/preferences_kde_integration.xml +++ b/app/src/main/res/xml/preferences_kde_integration.xml @@ -5,6 +5,7 @@