mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 01:07:55 +00:00
Uninstalled app su requests should still show in logs
This commit is contained in:
parent
0ad0ef485c
commit
6b67902d53
@ -3,7 +3,6 @@ package com.topjohnwu.magisk.core.magiskdb
|
|||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import com.topjohnwu.magisk.core.Const
|
import com.topjohnwu.magisk.core.Const
|
||||||
import com.topjohnwu.magisk.core.model.su.SuPolicy
|
import com.topjohnwu.magisk.core.model.su.SuPolicy
|
||||||
import com.topjohnwu.magisk.core.model.su.toMap
|
|
||||||
import com.topjohnwu.magisk.core.model.su.toPolicy
|
import com.topjohnwu.magisk.core.model.su.toPolicy
|
||||||
import com.topjohnwu.magisk.di.AppContext
|
import com.topjohnwu.magisk.di.AppContext
|
||||||
import com.topjohnwu.magisk.ktx.now
|
import com.topjohnwu.magisk.ktx.now
|
||||||
|
@ -3,8 +3,6 @@ package com.topjohnwu.magisk.core.model.su
|
|||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.Ignore
|
import androidx.room.Ignore
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.ALLOW
|
|
||||||
import com.topjohnwu.magisk.ktx.now
|
|
||||||
import com.topjohnwu.magisk.ktx.timeFormatTime
|
import com.topjohnwu.magisk.ktx.timeFormatTime
|
||||||
import com.topjohnwu.magisk.ktx.toTime
|
import com.topjohnwu.magisk.ktx.toTime
|
||||||
|
|
||||||
@ -22,9 +20,3 @@ data class SuLog(
|
|||||||
@PrimaryKey(autoGenerate = true) var id: Int = 0
|
@PrimaryKey(autoGenerate = true) var id: Int = 0
|
||||||
@Ignore val timeString = time.toTime(timeFormatTime)
|
@Ignore val timeString = time.toTime(timeFormatTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SuPolicy.toLog(
|
|
||||||
toUid: Int,
|
|
||||||
fromPid: Int,
|
|
||||||
command: String
|
|
||||||
) = SuLog(uid, toUid, fromPid, packageName, appName, command, policy == ALLOW, now)
|
|
||||||
|
@ -25,16 +25,20 @@ data class SuPolicy(
|
|||||||
const val ALLOW = 2
|
const val ALLOW = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
fun toLog(toUid: Int, fromPid: Int, command: String) = SuLog(
|
||||||
|
uid, toUid, fromPid, packageName, appName,
|
||||||
|
command, policy == ALLOW, System.currentTimeMillis()
|
||||||
|
)
|
||||||
|
|
||||||
fun SuPolicy.toMap() = mapOf(
|
fun toMap() = mapOf(
|
||||||
"uid" to uid,
|
"uid" to uid,
|
||||||
"package_name" to packageName,
|
"package_name" to packageName,
|
||||||
"policy" to policy,
|
"policy" to policy,
|
||||||
"until" to until,
|
"until" to until,
|
||||||
"logging" to logging,
|
"logging" to logging,
|
||||||
"notification" to notification
|
"notification" to notification
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Throws(PackageManager.NameNotFoundException::class)
|
@Throws(PackageManager.NameNotFoundException::class)
|
||||||
fun Map<String, String>.toPolicy(pm: PackageManager): SuPolicy {
|
fun Map<String, String>.toPolicy(pm: PackageManager): SuPolicy {
|
||||||
@ -70,3 +74,13 @@ fun Int.toPolicy(pm: PackageManager, policy: Int = INTERACTIVE): SuPolicy {
|
|||||||
policy = policy
|
policy = policy
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Int.toUidPolicy(pm: PackageManager, policy: Int): SuPolicy {
|
||||||
|
return SuPolicy(
|
||||||
|
uid = this,
|
||||||
|
packageName = "[UID] $this",
|
||||||
|
appName = "[UID] $this",
|
||||||
|
icon = pm.defaultActivityIcon,
|
||||||
|
policy = policy
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -8,8 +8,8 @@ import com.topjohnwu.magisk.BuildConfig
|
|||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.core.Config
|
import com.topjohnwu.magisk.core.Config
|
||||||
import com.topjohnwu.magisk.core.model.su.SuPolicy
|
import com.topjohnwu.magisk.core.model.su.SuPolicy
|
||||||
import com.topjohnwu.magisk.core.model.su.toLog
|
|
||||||
import com.topjohnwu.magisk.core.model.su.toPolicy
|
import com.topjohnwu.magisk.core.model.su.toPolicy
|
||||||
|
import com.topjohnwu.magisk.core.model.su.toUidPolicy
|
||||||
import com.topjohnwu.magisk.di.ServiceLocator
|
import com.topjohnwu.magisk.di.ServiceLocator
|
||||||
import com.topjohnwu.magisk.utils.Utils
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@ -58,7 +58,11 @@ object SuCallbackHandler {
|
|||||||
val notify = data.getBoolean("notify", true)
|
val notify = data.getBoolean("notify", true)
|
||||||
val allow = data["policy"].toInt() ?: return
|
val allow = data["policy"].toInt() ?: return
|
||||||
|
|
||||||
val policy = runCatching { fromUid.toPolicy(pm, allow) }.getOrElse { return }
|
val policy = runCatching {
|
||||||
|
fromUid.toPolicy(pm, allow)
|
||||||
|
}.getOrElse {
|
||||||
|
fromUid.toUidPolicy(pm, allow)
|
||||||
|
}
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
notify(context, policy)
|
notify(context, policy)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user