app: remove legacy isolated denylist entries

Isolated processes are matched by name prefix, and the DenyList now
adds a single "isolated|<process>:" entry per app. Older versions of
the app added one entry per isolated service instead, e.g.
"isolated|com.foo:com.foo.Service". The screen shows the isolated row
as checked if any entry starts with the prefix, but unchecking it only
removed the exact prefix entry, so the old entries stayed and the row
was checked again on the next visit.

When removing an isolated row, remove every isolated entry starting
with its prefix.

Assisted-by: Claude Opus 5.5
This commit is contained in:
topjohnwu
2026-10-24 13:01:45 -07:00
committed by John Wu
parent 8ad2b4a364
commit 9fe92a0fc8
@@ -142,8 +142,7 @@ class DenyListViewModel : AsyncLoadViewModel() {
proc.copy(isEnabled = true)
} else {
if (proc.process.isIsolated && proc.isEnabled) {
val (name, pkg) = proc.process
Shell.cmd("magisk --denylist rm $pkg '$name'").submit()
Shell.cmd(removeCommand(proc.process)).submit()
}
proc.copy(isEnabled = false)
}
@@ -158,9 +157,9 @@ class DenyListViewModel : AsyncLoadViewModel() {
fun toggleProcess(app: DenyAppState, proc: DenyProcessState) {
val newEnabled = !proc.isEnabled
val arg = if (newEnabled) "add" else "rm"
val (name, pkg) = proc.process
Shell.cmd("magisk --denylist $arg $pkg '$name'").submit()
val cmd = if (newEnabled) "magisk --denylist add $pkg '$name'" else removeCommand(proc.process)
Shell.cmd(cmd).submit()
_allApps.update { apps ->
apps.map { currentApp ->
@@ -180,6 +179,16 @@ class DenyListViewModel : AsyncLoadViewModel() {
}
}
private fun removeCommand(proc: ProcessInfo): String {
if (!proc.isIsolated) return "magisk --denylist rm ${proc.packageName} '${proc.name}'"
// Isolated processes are matched by name prefix. Older versions of the app added one
// entry per isolated service (e.g. "com.foo:com.foo.Service") instead of the prefix
// itself, so remove every entry starting with the prefix.
return "magisk --denylist ls | while IFS='|' read -r pkg proc; do " +
"[ \"\$pkg\" = $ISOLATED_MAGIC ] && case \"\$proc\" in '${proc.name}'*) " +
"magisk --denylist rm $ISOLATED_MAGIC \"\$proc\";; esac; done"
}
override suspend fun doLoadWork() {
// Scanning every app is slow and resets the list, so only do it once: this is called
// again whenever the screen is recreated, e.g. on rotation