mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-20 03:11:29 +00:00
Use UID_REMOVED action for multi-user and shared user id compatibility
This commit is contained in:
parent
122a73e086
commit
ee0ec3fbfa
@ -15,6 +15,7 @@
|
|||||||
<!-- Splash -->
|
<!-- Splash -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".core.SplashActivity"
|
android:name=".core.SplashActivity"
|
||||||
|
android:exported="true"
|
||||||
android:theme="@style/SplashTheme">
|
android:theme="@style/SplashTheme">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -52,7 +53,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
|
<action android:name="android.intent.action.UID_REMOVED" />
|
||||||
|
|
||||||
<data android:scheme="package" />
|
<data android:scheme="package" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.topjohnwu.magisk.core
|
package com.topjohnwu.magisk.core
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.ContextWrapper
|
import android.content.ContextWrapper
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.topjohnwu.magisk.core.base.BaseReceiver
|
import com.topjohnwu.magisk.core.base.BaseReceiver
|
||||||
import com.topjohnwu.magisk.core.magiskdb.PolicyDao
|
import com.topjohnwu.magisk.core.magiskdb.PolicyDao
|
||||||
import com.topjohnwu.magisk.core.su.SuCallbackHandler
|
|
||||||
import com.topjohnwu.magisk.view.Shortcuts
|
import com.topjohnwu.magisk.view.Shortcuts
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@ -15,30 +15,33 @@ open class Receiver : BaseReceiver() {
|
|||||||
|
|
||||||
private val policyDB: PolicyDao by inject()
|
private val policyDB: PolicyDao by inject()
|
||||||
|
|
||||||
private fun getPkg(intent: Intent): String {
|
@SuppressLint("InlinedApi")
|
||||||
return intent.data?.encodedSchemeSpecificPart.orEmpty()
|
private fun getPkg(intent: Intent): String? {
|
||||||
|
val pkg = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME)
|
||||||
|
return pkg ?: intent.data?.schemeSpecificPart
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getUid(intent: Intent): Int? {
|
||||||
|
val uid = intent.getIntExtra(Intent.EXTRA_UID, -1)
|
||||||
|
return if (uid == -1) null else uid
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReceive(context: ContextWrapper, intent: Intent?) {
|
override fun onReceive(context: ContextWrapper, intent: Intent?) {
|
||||||
intent ?: return
|
intent ?: return
|
||||||
|
|
||||||
fun rmPolicy(pkg: String) = GlobalScope.launch {
|
fun rmPolicy(uid: Int) = GlobalScope.launch {
|
||||||
policyDB.delete(pkg)
|
policyDB.delete(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
when (intent.action ?: return) {
|
when (intent.action ?: return) {
|
||||||
Intent.ACTION_REBOOT -> {
|
|
||||||
SuCallbackHandler(context, intent.getStringExtra("action"), intent.extras)
|
|
||||||
}
|
|
||||||
Intent.ACTION_PACKAGE_REPLACED -> {
|
Intent.ACTION_PACKAGE_REPLACED -> {
|
||||||
// This will only work pre-O
|
// This will only work pre-O
|
||||||
if (Config.suReAuth)
|
if (Config.suReAuth)
|
||||||
rmPolicy(getPkg(intent))
|
getUid(intent)?.let { rmPolicy(it) }
|
||||||
}
|
}
|
||||||
Intent.ACTION_PACKAGE_FULLY_REMOVED -> {
|
Intent.ACTION_UID_REMOVED -> {
|
||||||
val pkg = getPkg(intent)
|
getUid(intent)?.let { rmPolicy(it) }
|
||||||
rmPolicy(pkg)
|
getPkg(intent)?.let { Shell.su("magiskhide rm $it").submit() }
|
||||||
Shell.su("magiskhide --rm $pkg").submit()
|
|
||||||
}
|
}
|
||||||
Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setupDynamic(context)
|
Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setupDynamic(context)
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,6 @@ class PolicyDao(
|
|||||||
}
|
}
|
||||||
}.commit()
|
}.commit()
|
||||||
|
|
||||||
suspend fun delete(packageName: String) = buildQuery<Delete> {
|
|
||||||
condition {
|
|
||||||
equals("package_name", packageName)
|
|
||||||
}
|
|
||||||
}.commit()
|
|
||||||
|
|
||||||
suspend fun delete(uid: Int) = buildQuery<Delete> {
|
suspend fun delete(uid: Int) = buildQuery<Delete> {
|
||||||
condition {
|
condition {
|
||||||
equals("uid", uid)
|
equals("uid", uid)
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
tools:ignore="GoogleAppIndexingWarning,MissingApplicationIcon,UnusedAttribute">
|
tools:ignore="GoogleAppIndexingWarning,MissingApplicationIcon,UnusedAttribute">
|
||||||
|
|
||||||
<!-- Splash -->
|
<!-- Splash -->
|
||||||
<activity android:name="f.u7">
|
<activity
|
||||||
|
android:name="f.u7"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
@ -51,7 +53,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
|
<action android:name="android.intent.action.UID_REMOVED" />
|
||||||
|
|
||||||
<data android:scheme="package" />
|
<data android:scheme="package" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user