From 42606efe56ae804076614de5a970bf007970d28b Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Thu, 9 Jun 2022 19:39:43 +0800 Subject: [PATCH] Always remove task --- app/src/main/AndroidManifest.xml | 1 + .../magisk/ui/surequest/SuRequestActivity.kt | 14 +++++++------- buildSrc/src/main/java/Codegen.kt | 1 + native/jni/su/connect.cpp | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8183790db..50c347b15 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,6 +27,7 @@ android:name=".ui.surequest.SuRequestActivity" android:directBootAware="true" android:exported="false" + android:taskAffinity="" tools:ignore="AppLinkUrlError"> diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt index 332f86ab4..fc9213a36 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt @@ -24,13 +24,9 @@ open class SuRequestActivity : UIActivity() { override val layoutRes: Int = R.layout.activity_request override val viewModel: SuRequestViewModel by viewModel() - override fun onBackPressed() { - viewModel.denyPressed() - } - override fun onCreate(savedInstanceState: Bundle?) { supportRequestWindowFeature(Window.FEATURE_NO_TITLE) - lockOrientation() + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window.addFlags(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { @@ -62,7 +58,11 @@ open class SuRequestActivity : UIActivity() { return theme } - private fun lockOrientation() { - requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED + override fun onBackPressed() { + viewModel.denyPressed() + } + + override fun finish() { + super.finishAndRemoveTask() } } diff --git a/buildSrc/src/main/java/Codegen.kt b/buildSrc/src/main/java/Codegen.kt index e6630b13a..7e9eae7bc 100644 --- a/buildSrc/src/main/java/Codegen.kt +++ b/buildSrc/src/main/java/Codegen.kt @@ -127,6 +127,7 @@ fun genStubManifest(srcDir: File, outDir: File): String { | android:name="%s" | android:directBootAware="true" | android:exported="false" + | android:taskAffinity="" | tools:ignore="AppLinkUrlError"> | | diff --git a/native/jni/su/connect.cpp b/native/jni/su/connect.cpp index 211e3e3ab..d782e21e1 100644 --- a/native/jni/su/connect.cpp +++ b/native/jni/su/connect.cpp @@ -17,10 +17,11 @@ exe, "/system/bin", "com.android.commands.content.Content", \ #define START_ACTIVITY \ exe, "/system/bin", "com.android.commands.am.Am", \ "start", "-p", target, "--user", user, "-a", "android.intent.action.VIEW", \ -"-f", "0x58000020", "--es", "action", action +"-f", "0x58800020", "--es", "action", action -// 0x58000020 = FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_MULTIPLE_TASK| -// FLAG_ACTIVITY_NO_HISTORY|FLAG_INCLUDE_STOPPED_PACKAGES +// 0x58800020 = FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_MULTIPLE_TASK| +// FLAG_ACTIVITY_NO_HISTORY|FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS| +// FLAG_INCLUDE_STOPPED_PACKAGES #define get_cmd(to) \ ((to).command.empty() ? \