mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
fix AI code
This commit is contained in:
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk.core.su
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import com.topjohnwu.magisk.core.AppContext
|
||||
import com.topjohnwu.magisk.core.BuildConfig
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.R
|
||||
@@ -71,12 +70,11 @@ object SuCallbackHandler {
|
||||
}
|
||||
}.getOrNull() ?: createSuLog(fromUid, toUid, pid, command, policy, target, seContext, gids)
|
||||
|
||||
runBlocking { ServiceLocator.logRepo.insert(log) }
|
||||
|
||||
if (notify || Config.suNotification == Config.Value.NOTIFICATION_STATUS_BAR)
|
||||
if (notify)
|
||||
notify(context, log.action >= SuPolicy.ALLOW, log.appName)
|
||||
|
||||
runBlocking { ServiceLocator.logRepo.insert(log) }
|
||||
SuEvents.notifyLogUpdated()
|
||||
SuEvents.notifyPolicyChanged()
|
||||
}
|
||||
|
||||
private fun handleNotify(context: Context, data: Bundle) {
|
||||
@@ -91,19 +89,6 @@ object SuCallbackHandler {
|
||||
}.getOrNull() ?: "[UID] $uid"
|
||||
|
||||
notify(context, policy >= SuPolicy.ALLOW, appName)
|
||||
SuEvents.notifyPolicyChanged()
|
||||
}
|
||||
|
||||
fun notify(granted: Boolean, appName: String) {
|
||||
when (Config.suNotification) {
|
||||
Config.Value.NOTIFICATION_TOAST -> {
|
||||
val resId = if (granted) R.string.su_allow_toast else R.string.su_deny_toast
|
||||
AppContext.toast(AppContext.getString(resId, appName), Toast.LENGTH_SHORT)
|
||||
}
|
||||
Config.Value.NOTIFICATION_STATUS_BAR -> {
|
||||
Notifications.suNotification(granted, appName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun notify(context: Context, granted: Boolean, appName: String) {
|
||||
|
||||
@@ -29,7 +29,6 @@ class SuRequestHandler(
|
||||
|
||||
private lateinit var output: File
|
||||
private lateinit var policy: SuPolicy
|
||||
private var pid: Int = -1
|
||||
lateinit var pkgInfo: PackageInfo
|
||||
private set
|
||||
|
||||
@@ -60,7 +59,7 @@ class SuRequestHandler(
|
||||
|
||||
private suspend fun init(intent: Intent): Boolean {
|
||||
val uid = intent.getIntExtra("uid", -1)
|
||||
pid = intent.getIntExtra("pid", -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}]")
|
||||
@@ -109,32 +108,7 @@ class SuRequestHandler(
|
||||
}
|
||||
if (time >= 0) {
|
||||
policyDB.update(policy)
|
||||
|
||||
val appInfo = pkgInfo.applicationInfo
|
||||
val appName = appInfo?.getLabel(pm)
|
||||
?: pkgInfo.sharedUserId ?: "[UID] ${policy.uid}"
|
||||
val packageName = appInfo?.let { pm.getNameForUid(it.uid) }
|
||||
?: pkgInfo.sharedUserId ?: "[UID] ${policy.uid}"
|
||||
|
||||
val log = SuLog(
|
||||
fromUid = policy.uid,
|
||||
toUid = 0,
|
||||
fromPid = pid,
|
||||
packageName = packageName,
|
||||
appName = appName,
|
||||
command = "",
|
||||
action = policy.policy,
|
||||
target = -1,
|
||||
context = "",
|
||||
gids = "",
|
||||
)
|
||||
ServiceLocator.logRepo.insert(log)
|
||||
|
||||
val granted = policy.policy >= SuPolicy.ALLOW
|
||||
SuCallbackHandler.notify(granted, appName)
|
||||
|
||||
SuEvents.notifyPolicyChanged()
|
||||
SuEvents.notifyLogUpdated()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user