Skip to content

Commit 6b64414

Browse files
committed
feat: Expand critical/protected apps list, improve running detection with dumpsys
1 parent 107d3f1 commit 6b64414

File tree

2 files changed

+134
-15
lines changed

2 files changed

+134
-15
lines changed

app/src/main/java/com/appcontrolx/service/AppFetcher.kt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,29 @@ class AppFetcher(private val context: Context) {
4646
private fun getRunningPackages(): Set<String> {
4747
val running = mutableSetOf<String>()
4848

49-
// Method 1: Try root command first (most accurate)
49+
// Method 1: Try root command (most accurate on Android 10+)
5050
try {
5151
if (Shell.isAppGrantedRoot() == true) {
52-
val result = Shell.cmd("ps -A -o NAME").exec()
53-
if (result.isSuccess) {
52+
// Use dumpsys to get running apps - more reliable than ps
53+
val result = Shell.cmd("dumpsys activity processes | grep 'app=' | cut -d'=' -f2 | cut -d'/' -f1").exec()
54+
if (result.isSuccess && result.out.isNotEmpty()) {
5455
result.out.forEach { line ->
55-
val processName = line.trim()
56-
if (processName.isNotEmpty() && processName.contains(".")) {
57-
running.add(processName)
56+
val pkg = line.trim()
57+
if (pkg.isNotEmpty() && pkg.contains(".")) {
58+
running.add(pkg)
59+
}
60+
}
61+
}
62+
63+
// Fallback: also check with cmd package list
64+
if (running.isEmpty()) {
65+
val result2 = Shell.cmd("cmd activity get-current-user; for pid in /proc/[0-9]*; do cat \$pid/cmdline 2>/dev/null | tr '\\0' '\\n' | head -1; done | grep '\\.' | sort -u").exec()
66+
if (result2.isSuccess) {
67+
result2.out.forEach { line ->
68+
val pkg = line.trim()
69+
if (pkg.isNotEmpty() && pkg.contains(".") && !pkg.startsWith("/")) {
70+
running.add(pkg)
71+
}
5872
}
5973
}
6074
}

app/src/main/java/com/appcontrolx/utils/SafetyValidator.kt

Lines changed: 114 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package com.appcontrolx.utils
33
object SafetyValidator {
44

55
// Apps yang TIDAK BOLEH disentuh sama sekali
6+
// Source: AOSP, OEM docs, community lists (github.com/AuroraOSS/AppWarden, etc)
67
private val CRITICAL_PACKAGES = setOf(
78
// Self-protection
89
"com.appcontrolx",
9-
// Android Core System
10+
11+
// === AOSP Core System ===
1012
"android",
1113
"com.android.systemui",
1214
"com.android.settings",
@@ -16,7 +18,9 @@ object SafetyValidator {
1618
"com.android.providers.contacts",
1719
"com.android.providers.telephony",
1820
"com.android.providers.media",
21+
"com.android.providers.media.module",
1922
"com.android.providers.downloads",
23+
"com.android.providers.calendar",
2024
"com.android.inputmethod.latin",
2125
"com.android.launcher3",
2226
"com.android.packageinstaller",
@@ -26,35 +30,136 @@ object SafetyValidator {
2630
"com.android.nfc",
2731
"com.android.bluetooth",
2832
"com.android.wifi",
29-
// Google Core
33+
"com.android.networkstack",
34+
"com.android.networkstack.tethering",
35+
"com.android.captiveportallogin",
36+
"com.android.localtransport",
37+
"com.android.location.fused",
38+
"com.android.keychain",
39+
"com.android.certinstaller",
40+
"com.android.webview",
41+
"com.android.dynsystem",
42+
"com.android.ons",
43+
"com.android.sdm.plugins.connmo",
44+
"com.android.emergency",
45+
"com.android.incallui",
46+
"com.android.stk",
47+
"com.android.cellbroadcastreceiver",
48+
49+
// === Google Core Services ===
3050
"com.google.android.gms",
3151
"com.google.android.gsf",
52+
"com.google.android.gsf.login",
3253
"com.android.vending",
3354
"com.google.android.packageinstaller",
34-
// Root/Shizuku
55+
"com.google.android.ext.services",
56+
"com.google.android.ext.shared",
57+
"com.google.android.onetimeinitializer",
58+
"com.google.android.partnersetup",
59+
"com.google.android.setupwizard",
60+
"com.google.android.configupdater",
61+
"com.google.android.providers.media.module",
62+
"com.google.android.webview",
63+
"com.google.android.trichromelibrary",
64+
"com.google.android.overlay.modules.permissioncontroller",
65+
66+
// === Xiaomi/MIUI/HyperOS Core ===
67+
"com.miui.system",
68+
"com.miui.rom",
69+
"com.miui.core",
70+
"com.miui.securitycore",
71+
"com.miui.contentcatcher",
72+
"com.miui.systemAdSolution",
73+
"com.xiaomi.xmsf",
74+
"com.xiaomi.account",
75+
"com.xiaomi.simactivate.service",
76+
"com.xiaomi.xmsfkeeper",
77+
"com.xiaomi.joyose",
78+
"com.xiaomi.mi_connect_service",
79+
80+
// === Samsung Core ===
81+
"com.samsung.android.providers.context",
82+
"com.samsung.android.incallui",
83+
"com.samsung.android.telecom",
84+
"com.samsung.android.app.telephonyui",
85+
"com.samsung.android.server.wifi.softap.resources",
86+
"com.samsung.android.networkstack",
87+
"com.samsung.android.wifi.resources",
88+
"com.sec.android.app.launcher",
89+
"com.sec.android.provider.badge",
90+
"com.sec.android.inputmethod",
91+
92+
// === OPPO/ColorOS/Realme Core ===
93+
"com.coloros.providers.downloads",
94+
"com.coloros.systemui",
95+
"com.coloros.phonemanager",
96+
"com.oplus.battery",
97+
"com.oplus.athena",
98+
99+
// === OnePlus/OxygenOS Core ===
100+
"com.oneplus.config",
101+
"net.oneplus.provider.appsettings",
102+
103+
// === Root/Shizuku/Tools ===
35104
"com.topjohnwu.magisk",
105+
"io.github.vvb2060.magisk",
36106
"rikka.shizuku",
37-
"moe.shizuku.privileged.api"
107+
"moe.shizuku.privileged.api",
108+
"eu.chainfire.supersu",
109+
"me.weishu.kernelsu"
38110
)
39111

40112
// Apps yang HANYA BOLEH di-force stop (tidak boleh freeze/uninstall/disable)
41113
private val FORCE_STOP_ONLY_PACKAGES = setOf(
42-
// Xiaomi Security Apps
114+
// === Xiaomi/MIUI/HyperOS Security & Power ===
43115
"com.miui.securitycenter",
44116
"com.miui.securityadd",
45117
"com.miui.guardprovider",
46118
"com.miui.antispam",
47119
"com.xiaomi.finddevice",
48-
// Xiaomi System Apps
49120
"com.miui.powerkeeper",
50121
"com.miui.analytics",
51122
"com.miui.daemon",
52-
"com.miui.core",
53-
// Other OEM Security
123+
"com.miui.notification",
124+
"com.miui.hybrid",
125+
"com.miui.hybrid.accessory",
126+
"com.miui.mishare.connectivity",
127+
"com.miui.voiceassist",
128+
"com.miui.personalassistant",
129+
130+
// === Samsung Security & Optimization ===
54131
"com.samsung.android.lool",
55132
"com.samsung.android.sm",
133+
"com.samsung.android.sm.devicesecurity",
134+
"com.samsung.android.sm.policy",
135+
"com.samsung.android.forest",
136+
"com.samsung.android.app.smartcapture",
137+
"com.samsung.android.fmm",
138+
"com.samsung.android.bixby.agent",
139+
"com.samsung.android.visionintelligence",
140+
141+
// === OPPO/ColorOS/Realme Security ===
56142
"com.coloros.safecenter",
57-
"com.oppo.safe"
143+
"com.oppo.safe",
144+
"com.coloros.oppoguardelf",
145+
"com.coloros.phonemanager",
146+
"com.heytap.cloud",
147+
"com.heytap.openid",
148+
149+
// === OnePlus ===
150+
"com.oneplus.security",
151+
152+
// === Huawei/HarmonyOS ===
153+
"com.huawei.systemmanager",
154+
"com.huawei.powergenie",
155+
"com.huawei.hicloud",
156+
157+
// === Vivo/FuntouchOS ===
158+
"com.vivo.permissionmanager",
159+
"com.iqoo.secure",
160+
161+
// === Google Find My Device ===
162+
"com.google.android.apps.adm"
58163
)
59164

60165
// Apps yang perlu warning sebelum action

0 commit comments

Comments
 (0)