From e6859ff56d8e73d4627b00ad40cd7261f32dee0f Mon Sep 17 00:00:00 2001 From: kr328 Date: Thu, 12 May 2022 20:15:00 +0800 Subject: [PATCH] Fix: use package if only single app in sharedUid group --- .../service/clash/module/AppListCacheModule.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt index 97697594..04c96b24 100644 --- a/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt @@ -15,7 +15,19 @@ class AppListCacheModule(service: Service) : Module(service) { private fun reload() { val packages = service.packageManager.getInstalledPackages(0) - .map { it.applicationInfo.uid to it.uniqueUidName() } + .groupBy { it.uniqueUidName() } + .map { (_, v) -> + val info = v[0] + + if (v.size == 1) { + // Force use package name if only one app in a single sharedUid group + // Example: firefox + + info.applicationInfo.uid to info.packageName + } else { + info.applicationInfo.uid to info.uniqueUidName() + } + } Clash.notifyInstalledAppsChanged(packages)