mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Delete outdated policies
This commit is contained in:
parent
358538717c
commit
68db366696
@ -55,11 +55,16 @@ class SuperuserViewModel(
|
|||||||
state = State.LOADING
|
state = State.LOADING
|
||||||
val (policies, diff) = withContext(Dispatchers.IO) {
|
val (policies, diff) = withContext(Dispatchers.IO) {
|
||||||
db.deleteOutdated()
|
db.deleteOutdated()
|
||||||
|
db.delete(AppContext.applicationInfo.uid)
|
||||||
val policies = ArrayList<PolicyRvItem>()
|
val policies = ArrayList<PolicyRvItem>()
|
||||||
val pm = AppContext.packageManager
|
val pm = AppContext.packageManager
|
||||||
for (policy in db.fetchAll()) {
|
for (policy in db.fetchAll()) {
|
||||||
val pkgs = pm.getPackagesForUid(policy.uid) ?: continue
|
val pkgs = pm.getPackagesForUid(policy.uid)
|
||||||
policies.addAll(pkgs.mapNotNull { pkg ->
|
if (pkgs == null) {
|
||||||
|
db.delete(policy.uid)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val map = pkgs.mapNotNull { pkg ->
|
||||||
try {
|
try {
|
||||||
val info = pm.getPackageInfo(pkg, MATCH_UNINSTALLED_PACKAGES)
|
val info = pm.getPackageInfo(pkg, MATCH_UNINSTALLED_PACKAGES)
|
||||||
PolicyRvItem(
|
PolicyRvItem(
|
||||||
@ -72,7 +77,12 @@ class SuperuserViewModel(
|
|||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
if (map.isEmpty()) {
|
||||||
|
db.delete(policy.uid)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
policies.addAll(map)
|
||||||
}
|
}
|
||||||
policies.sortWith(compareBy(
|
policies.sortWith(compareBy(
|
||||||
{ it.appName.lowercase(currentLocale) },
|
{ it.appName.lowercase(currentLocale) },
|
||||||
|
Loading…
Reference in New Issue
Block a user