@@ -18,6 +18,7 @@ import android.content.pm.PackageManager
18
18
import android.content.pm.PackageManager.GET_INSTRUMENTATION
19
19
import android.content.pm.PackageManager.GET_SIGNING_CERTIFICATES
20
20
import android.content.pm.PackageManager.MATCH_SYSTEM_ONLY
21
+ import android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES
21
22
import android.content.pm.ResolveInfo
22
23
import android.os.RemoteException
23
24
import android.util.Log
@@ -49,7 +50,7 @@ internal class PackageService(
49
50
@WorkerThread
50
51
@Throws(RemoteException ::class )
51
52
get() {
52
- val packages = packageManager.getInstalledPackages(0 )
53
+ val packages = packageManager.getInstalledPackages(MATCH_UNINSTALLED_PACKAGES )
53
54
.map { packageInfo -> packageInfo.packageName }
54
55
.sorted()
55
56
@@ -81,7 +82,8 @@ internal class PackageService(
81
82
get() {
82
83
// We need the GET_SIGNING_CERTIFICATES flag here,
83
84
// because the package info is used by [ApkBackup] which needs signing info.
84
- return packageManager.getInstalledPackages(GET_SIGNING_CERTIFICATES )
85
+ val flags = GET_SIGNING_CERTIFICATES or MATCH_UNINSTALLED_PACKAGES
86
+ return packageManager.getInstalledPackages(flags)
85
87
.filter { packageInfo -> // only apps that are:
86
88
! packageInfo.isNotUpdatedSystemApp() && // not vanilla system apps
87
89
packageInfo.packageName != context.packageName // not this app
@@ -97,7 +99,8 @@ internal class PackageService(
97
99
get() {
98
100
// We need the GET_SIGNING_CERTIFICATES flag here,
99
101
// because the package info is used by [ApkBackup] which needs signing info.
100
- return packageManager.getInstalledPackages(GET_SIGNING_CERTIFICATES )
102
+ val flags = GET_SIGNING_CERTIFICATES or MATCH_UNINSTALLED_PACKAGES
103
+ return packageManager.getInstalledPackages(flags)
101
104
.filter { packageInfo ->
102
105
packageInfo.doesNotGetBackedUp() && // only apps that do not allow backup
103
106
! packageInfo.isNotUpdatedSystemApp() && // and are not vanilla system apps
0 commit comments