Fix managed profile bugs in manage apps list

- Uses the same package manager flags as secondary users for managed
   profiles, so that owner apps don't show up.

 - Fixes bug in getting AppEntries that caused app info for profile
   apps to get the owner one instead (which was unbadged and very
   broken).

Bug: 19817357
Change-Id: I659ab1081c68a231330f5b16486abc5a0a5b2029
This commit is contained in:
Jason Monk
2015-03-25 14:47:01 -04:00
parent 5528d8952b
commit 1f4f30cd06

View File

@@ -327,6 +327,7 @@ public class ApplicationsState {
final PackageManager mPm; final PackageManager mPm;
final IPackageManager mIpm; final IPackageManager mIpm;
final UserManager mUm; final UserManager mUm;
final int mOwnerRetrieveFlags;
final int mRetrieveFlags; final int mRetrieveFlags;
PackageIntentReceiver mPackageIntentReceiver; PackageIntentReceiver mPackageIntentReceiver;
@@ -531,14 +532,11 @@ public class ApplicationsState {
mBackgroundHandler = new BackgroundHandler(mThread.getLooper()); mBackgroundHandler = new BackgroundHandler(mThread.getLooper());
// Only the owner can see all apps. // Only the owner can see all apps.
if (UserHandle.myUserId() == 0) { mOwnerRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
mRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_DISABLED_COMPONENTS |
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS; PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS;
} else {
mRetrieveFlags = PackageManager.GET_DISABLED_COMPONENTS | mRetrieveFlags = PackageManager.GET_DISABLED_COMPONENTS |
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS; PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS;
}
/** /**
* This is a trick to prevent the foreground thread from being delayed. * This is a trick to prevent the foreground thread from being delayed.
@@ -742,7 +740,9 @@ public class ApplicationsState {
for (UserHandle user : mUm.getUserProfiles()) { for (UserHandle user : mUm.getUserProfiles()) {
try { try {
ParceledListSlice<ApplicationInfo> list = ParceledListSlice<ApplicationInfo> list =
mIpm.getInstalledApplications(mRetrieveFlags, user.getIdentifier()); mIpm.getInstalledApplications(
user.isOwner() ? mOwnerRetrieveFlags : mRetrieveFlags,
user.getIdentifier());
mApplications.addAll(list.getList()); mApplications.addAll(list.getList());
} catch (RemoteException e) { } catch (RemoteException e) {
} }
@@ -817,7 +817,8 @@ public class ApplicationsState {
if (entry == null) { if (entry == null) {
for (int i=0; i<mApplications.size(); i++) { for (int i=0; i<mApplications.size(); i++) {
ApplicationInfo info = mApplications.get(i); ApplicationInfo info = mApplications.get(i);
if (packageName.equals(info.packageName)) { if (packageName.equals(info.packageName)
&& userId == UserHandle.getUserId(info.uid)) {
entry = getEntryLocked(info); entry = getEntryLocked(info);
break; break;
} }
@@ -889,7 +890,9 @@ public class ApplicationsState {
if (DEBUG_LOCKING) Log.v(TAG, "addPackage release lock: already exists"); if (DEBUG_LOCKING) Log.v(TAG, "addPackage release lock: already exists");
return; return;
} }
ApplicationInfo info = mIpm.getApplicationInfo(pkgName, mRetrieveFlags, userId); ApplicationInfo info = mIpm.getApplicationInfo(pkgName,
userId == UserHandle.USER_OWNER ? mOwnerRetrieveFlags : mRetrieveFlags,
userId);
if (info == null) { if (info == null) {
return; return;
} }