From 2934ec1718e50f2afb39f13e39395c11ca15f080 Mon Sep 17 00:00:00 2001 From: tiann Date: Wed, 14 Dec 2022 16:31:46 +0800 Subject: [PATCH] manager: add all apps in superuser list --- .../me/weishu/kernelsu/ui/screen/SuperUser.kt | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt index aa1e8cc9..4ce8becf 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt @@ -101,16 +101,8 @@ private fun getAppList(context: Context): List { } } - val defaultDenyList = denyList.toMutableList() - - val shellUid = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) android.os.Process.SHELL_UID else 2000; - if (!allowList.contains(shellUid) && !denyList.contains(shellUid)) { - // shell uid is not in allow list, add it to default deny list - defaultDenyList.add(shellUid) - } - // add deny list - for (uid in defaultDenyList) { + for (uid in denyList) { val packagesForUid = pm.getPackagesForUid(uid) if (packagesForUid == null || packagesForUid.isEmpty()) { result.add(SuperUserData("Unknown", "Unknown", @@ -132,6 +124,24 @@ private fun getAppList(context: Context): List { } } + // todo: use root to get all uids if possible + val apps = pm.getInstalledApplications(0) + // add other apps + for (app in apps) { + if (allowList.contains(app.uid) || denyList.contains(app.uid)) { + continue + } + result.add( + SuperUserData( + name = app.loadLabel(pm), + description = app.packageName, + icon = app.loadIcon(pm), + uid = app.uid, + initialChecked = false + ) + ) + } + return result }