app: remove interactive su request components

Following the removal of reactive interactive su prompting in magiskd,
remove the corresponding request activity and obsolete settings from
the app.

- Remove SuRequestActivity, SuRequestScreen, SuRequestViewModel, and
  SuRequestHandler.
- Remove tapjack protection, auto response, and request timeout
  settings and resources.
- Update Stub.kt manifest generator to drop the unexported activity
  placeholder.
- Simplify DynLoad activity mapping now that both stub and app declare
  a single activity.
- Bump magisk.stubVersion to 41.

Assisted-by: Gemini 3.8 Flash
This commit is contained in:
topjohnwu
2026-10-05 01:38:20 -07:00
committed by John Wu
parent a1cf051ac7
commit f093f847bb
18 changed files with 6 additions and 814 deletions
@@ -29,11 +29,8 @@ object Config : PreferenceConfig, DBConfig {
const val KEYSTORE = "keystore"
// prefs
const val SU_REQUEST_TIMEOUT = "su_request_timeout"
const val SU_AUTO_RESPONSE = "su_auto_response"
const val SU_NOTIFICATION = "su_notification"
const val SU_REAUTH = "su_reauth"
const val SU_TAPJACK = "su_tapjack"
const val SU_RESTRICT = "su_restrict"
const val CHECK_UPDATES = "check_update"
const val RELEASE_CHANNEL = "release_channel"
@@ -48,8 +45,7 @@ object Config : PreferenceConfig, DBConfig {
const val DOH = "doh"
const val RAND_NAME = "rand_name"
val NO_MIGRATION = setOf(ASKED_HOME, SU_REQUEST_TIMEOUT,
SU_AUTO_RESPONSE, SU_REAUTH, SU_TAPJACK)
val NO_MIGRATION = setOf(ASKED_HOME, SU_REAUTH)
}
object OldValue {
@@ -90,14 +86,6 @@ object Config : PreferenceConfig, DBConfig {
const val NO_NOTIFICATION = 0
const val NOTIFICATION_TOAST = 1
const val NOTIFICATION_STATUS_BAR = 2
// su auto response
const val SU_PROMPT = 0
const val SU_AUTO_DENY = 1
const val SU_AUTO_ALLOW = 2
// su timeout
val TIMEOUT_LIST = longArrayOf(0, -1, 10, 20, 30, 60)
}
@JvmField var keepVerity = false
@@ -143,9 +131,6 @@ object Config : PreferenceConfig, DBConfig {
var zygisk by dbSettings(Key.ZYGISK, Info.isEmulator)
var suManager by dbStrings(Key.SU_MANAGER, "", true)
var keyStoreRaw by dbStrings(Key.KEYSTORE, "", true)
var suDefaultTimeout by preferenceStrInt(Key.SU_REQUEST_TIMEOUT, 10)
var suAutoResponse by preferenceStrInt(Key.SU_AUTO_RESPONSE, Value.SU_PROMPT)
var suNotification by preferenceStrInt(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST)
var rootMode by dbSettings(Key.ROOT_ACCESS, Value.ROOT_ACCESS_APPS_AND_ADB)
var suMntNamespaceMode by dbSettings(Key.SU_MNT_NS, Value.NAMESPACE_MODE_REQUESTER)
@@ -157,7 +142,6 @@ object Config : PreferenceConfig, DBConfig {
suBiometric = value
}
var suReAuth by preference(Key.SU_REAUTH, false)
var suTapjack by preference(Key.SU_TAPJACK, true)
var suRestrict by preference(Key.SU_RESTRICT, false)
private const val SU_FINGERPRINT = "su_fingerprint"
@@ -51,5 +51,4 @@ val shouldKeepResources = listOf(
R.string.app_changelog,
R.string.home_item_source,
R.drawable.ic_more,
R.array.allow_timeout,
)
@@ -20,7 +20,6 @@ import io.noties.markwon.utils.NoCopySpannableFactory
object ServiceLocator {
val deContext by lazy { AppContext.deviceProtectedContext }
val timeoutPrefs by lazy { deContext.getSharedPreferences("su_timeout", 0) }
// Database
val policyDB = PolicyDao()
@@ -4,7 +4,7 @@ import com.topjohnwu.magisk.core.data.magiskdb.MagiskDB
class SuPolicy(
val uid: Int,
var policy: Int = QUERY,
var policy: Int = DENY,
var remain: Long = -1L,
var logging: Boolean = true,
var notification: Boolean = true,
@@ -18,7 +18,6 @@ import timber.log.Timber
object SuCallbackHandler {
const val REQUEST = "request"
const val LOG = "log"
const val NOTIFY = "notify"
@@ -1,115 +0,0 @@
package com.topjohnwu.magisk.core.su
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import com.topjohnwu.magisk.core.BuildConfig
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.data.magiskdb.PolicyDao
import com.topjohnwu.magisk.core.di.ServiceLocator
import com.topjohnwu.magisk.core.ktx.getLabel
import com.topjohnwu.magisk.core.ktx.getPackageInfo
import com.topjohnwu.magisk.core.model.su.SuLog
import com.topjohnwu.magisk.core.model.su.SuPolicy
import com.topjohnwu.magisk.view.Notifications
import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.DataOutputStream
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.util.concurrent.TimeUnit
class SuRequestHandler(
val pm: PackageManager,
private val policyDB: PolicyDao
) {
private lateinit var output: File
private lateinit var policy: SuPolicy
lateinit var pkgInfo: PackageInfo
private set
// Return true to indicate undetermined policy, require user interaction
suspend fun start(intent: Intent): Boolean {
if (!init(intent))
return false
// Never allow com.topjohnwu.magisk (could be malware)
if (pkgInfo.packageName == BuildConfig.APP_PACKAGE_NAME) {
Shell.cmd("(pm uninstall ${BuildConfig.APP_PACKAGE_NAME} >/dev/null 2>&1)&").exec()
return false
}
when (Config.suAutoResponse) {
Config.Value.SU_AUTO_DENY -> {
respond(SuPolicy.DENY, 0)
return false
}
Config.Value.SU_AUTO_ALLOW -> {
respond(SuPolicy.ALLOW, 0)
return false
}
}
return true
}
private suspend fun init(intent: Intent): Boolean {
val uid = intent.getIntExtra("uid", -1)
val pid = intent.getIntExtra("pid", -1)
val fifo = intent.getStringExtra("fifo")
if (uid <= 0 || pid <= 0 || fifo == null) {
Timber.e("Unexpected extras: uid=[${uid}], pid=[${pid}], fifo=[${fifo}]")
return false
}
output = File(fifo)
policy = policyDB.fetch(uid) ?: SuPolicy(uid)
try {
pkgInfo = pm.getPackageInfo(uid, pid) ?: PackageInfo().apply {
val name = pm.getNameForUid(uid) ?: throw PackageManager.NameNotFoundException()
// We only fill in sharedUserId and leave other fields uninitialized
sharedUserId = name.split(":")[0]
}
} catch (e: PackageManager.NameNotFoundException) {
Timber.e(e)
respond(SuPolicy.DENY, -1)
return false
}
if (!output.canWrite()) {
Timber.e("Cannot write to $output")
return false
}
return true
}
suspend fun respond(action: Int, time: Long) {
if (action == SuPolicy.ALLOW && Config.suRestrict) {
policy.policy = SuPolicy.RESTRICT
} else {
policy.policy = action
}
if (time >= 0) {
policy.remain = TimeUnit.MINUTES.toSeconds(time)
} else {
policy.remain = time
}
withContext(Dispatchers.IO) {
try {
DataOutputStream(FileOutputStream(output)).use {
it.writeInt(policy.policy)
it.flush()
}
} catch (e: IOException) {
Timber.e(e)
}
if (time >= 0) {
policyDB.update(policy)
SuEvents.notifyPolicyChanged()
}
}
}
}
-24
View File
@@ -1,14 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="allow_timeout">
<item>@string/forever</item>
<item>@string/once</item>
<item>@string/tenmin</item>
<item>@string/twentymin</item>
<item>@string/thirtymin</item>
<item>@string/sixtymin</item>
</string-array>
<string-array name="su_access">
<item>@string/settings_su_disable</item>
<item>@string/settings_su_app</item>
@@ -16,21 +7,6 @@
<item>@string/settings_su_app_adb</item>
</string-array>
<string-array name="request_timeout">
<item>@string/settings_su_request_10</item>
<item>@string/settings_su_request_15</item>
<item>@string/settings_su_request_20</item>
<item>@string/settings_su_request_30</item>
<item>@string/settings_su_request_45</item>
<item>@string/settings_su_request_60</item>
</string-array>
<string-array name="auto_response">
<item>@string/prompt</item>
<item>@string/deny</item>
<item>@string/grant</item>
</string-array>
<string-array name="su_notification">
<item>@string/none</item>
<item>@string/toast</item>
-20
View File
@@ -54,20 +54,10 @@
<string name="flash_screen_title">Installation</string>
<!--Superuser-->
<string name="su_request_title">Superuser request</string>
<string name="touch_filtered_warning">Because an app is obscuring a Superuser request, Magisk can\'t verify your response.</string>
<string name="deny">Deny</string>
<string name="prompt">Prompt</string>
<string name="restrict">Restrict</string>
<string name="grant">Grant</string>
<string name="superuser_grant">Grant Superuser</string>
<string name="su_warning">Grants full access to your device.\nDeny if you\'re not sure!</string>
<string name="forever">Forever</string>
<string name="once">Once</string>
<string name="tenmin">10 mins</string>
<string name="twentymin">20 mins</string>
<string name="thirtymin">30 mins</string>
<string name="sixtymin">60 mins</string>
<string name="su_allow_toast">%1$s was granted Superuser rights</string>
<string name="su_deny_toast">%1$s was denied Superuser rights</string>
<string name="su_snack_grant">Superuser rights of %1$s are granted</string>
@@ -170,20 +160,10 @@
<string name="settings_su_app">Apps only</string>
<string name="settings_su_adb">ADB only</string>
<string name="settings_su_disable">Disabled</string>
<string name="settings_su_request_10">10 seconds</string>
<string name="settings_su_request_15">15 seconds</string>
<string name="settings_su_request_20">20 seconds</string>
<string name="settings_su_request_30">30 seconds</string>
<string name="settings_su_request_45">45 seconds</string>
<string name="settings_su_request_60">60 seconds</string>
<string name="superuser_access">Superuser access</string>
<string name="auto_response">Automatic response</string>
<string name="request_timeout">Request timeout</string>
<string name="superuser_notification">Superuser notification</string>
<string name="settings_su_reauth_title">Reauthenticate after upgrade</string>
<string name="settings_su_reauth_summary">Ask for Superuser permissions again after upgrading apps</string>
<string name="settings_su_tapjack_title">Tapjacking protection</string>
<string name="settings_su_tapjack_summary">The Superuser prompt dialog won\'t respond to input while obscured by any other window or overlay</string>
<string name="settings_su_auth_title">User authentication</string>
<string name="settings_su_auth_summary">Ask for user authentication during Superuser requests</string>
<string name="settings_su_auth_insecure">No authentication method is configured on the device</string>