From 6bb5d0fabbe9dfce3d1da8ae94bc1de470e01bb0 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 14 Mar 2017 11:02:33 -0600 Subject: 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 --- .../java/com/android/server/usage/StorageStatsService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'services/usage/java') diff --git a/services/usage/java/com/android/server/usage/StorageStatsService.java b/services/usage/java/com/android/server/usage/StorageStatsService.java index ebd4b019790a..ecc2b7f0577a 100644 --- a/services/usage/java/com/android/server/usage/StorageStatsService.java +++ b/services/usage/java/com/android/server/usage/StorageStatsService.java @@ -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); -- cgit v1.2.3-59-g8ed1b