Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6bb5d0fa authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Allow querying for apps on adopted storage.

Apps that live on adopted storage devices appear to be uninstalled
while ejected.  They're technically still valid apps, with allocated
UIDs, so use MATCH_UNINSTALLED_PACKAGES when querying for their
details.

Test: builds, boots
Bug: 36177795
Change-Id: Ia7ed5f0462b1f47609ea8e1ace6fa145e0b5602c
parent b94427d2
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -208,7 +208,8 @@ public class StorageStatsService extends IStorageStatsManager.Stub {

        final ApplicationInfo appInfo;
        try {
            appInfo = mPackage.getApplicationInfoAsUser(packageName, 0, userId);
            appInfo = mPackage.getApplicationInfoAsUser(packageName,
                    PackageManager.MATCH_UNINSTALLED_PACKAGES, userId);
        } catch (NameNotFoundException e) {
            throw new IllegalStateException(e);
        }
@@ -251,8 +252,8 @@ public class StorageStatsService extends IStorageStatsManager.Stub {

        for (int i = 0; i < packageNames.length; i++) {
            try {
                codePaths[i] = mPackage.getApplicationInfoAsUser(packageNames[i], 0,
                        userId).getCodePath();
                codePaths[i] = mPackage.getApplicationInfoAsUser(packageNames[i],
                        PackageManager.MATCH_UNINSTALLED_PACKAGES, userId).getCodePath();
            } catch (NameNotFoundException e) {
                throw new IllegalStateException(e);
            }
@@ -284,7 +285,8 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
        }

        int[] appIds = null;
        for (ApplicationInfo app : mPackage.getInstalledApplicationsAsUser(0, userId)) {
        for (ApplicationInfo app : mPackage.getInstalledApplicationsAsUser(
                PackageManager.MATCH_UNINSTALLED_PACKAGES, userId)) {
            final int appId = UserHandle.getAppId(app.uid);
            if (!ArrayUtils.contains(appIds, appId)) {
                appIds = ArrayUtils.appendInt(appIds, appId);