Skip to content

Commit 19dffe4

Browse files
author
yang.bai
committed
1.getInstalledPackages api security call
1 parent 100a1d2 commit 19dffe4

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/AppListCollector.kt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.pm.ApplicationInfo
55
import android.content.pm.PackageInfo
66
import android.content.pm.PackageManager
77
import android.text.TextUtils
8+
import cn.tongdun.mobrisk.core.tools.executeSafe
89

910
/**
1011
* @description: App List
@@ -23,23 +24,24 @@ class AppListCollector(packageManager: PackageManager) : AppListDataInterface {
2324
private val systemAppList: MutableList<String?> = ArrayList()
2425

2526
init {
26-
packageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES)
27-
.filter {
28-
isSystemApp(it)
29-
}.map {
30-
appList.add(it.packageName)
27+
executeSafe {
28+
packageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES)
29+
.filter {
30+
isSystemApp(it)
31+
}.map {
32+
appList.add(it.packageName)
33+
}
34+
packageManager.getInstalledPackages(PackageManager.GET_META_DATA).fold(
35+
Pair(systemAppList, appList)
36+
) { (systemList, appList), packageInfo ->
37+
if (isSystemApp(packageInfo)) {
38+
systemList.add(packageInfo.packageName)
39+
} else {
40+
appList.add(packageInfo.packageName)
41+
}
42+
Pair(systemList, appList)
3143
}
32-
packageManager.getInstalledPackages(PackageManager.GET_META_DATA).fold(
33-
Pair(systemAppList, appList)
34-
) { (systemList, appList), packageInfo ->
35-
if (isSystemApp(packageInfo)) {
36-
systemList.add(packageInfo.packageName)
37-
} else {
38-
appList.add(packageInfo.packageName)
39-
}
40-
Pair(systemList, appList)
4144
}
42-
4345
}
4446

4547
@SuppressLint("QueryPermissionsNeeded")

0 commit comments

Comments
 (0)