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

Commit 1f4f30cd authored by Jason Monk's avatar Jason Monk
Browse files

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
parent 5528d895
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -327,6 +327,7 @@ public class ApplicationsState {
    final PackageManager mPm;
    final IPackageManager mIpm;
    final UserManager mUm;
    final int mOwnerRetrieveFlags;
    final int mRetrieveFlags;
    PackageIntentReceiver mPackageIntentReceiver;

@@ -531,14 +532,11 @@ public class ApplicationsState {
        mBackgroundHandler = new BackgroundHandler(mThread.getLooper());

        // Only the owner can see all apps.
        if (UserHandle.myUserId() == 0) {
            mRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
        mOwnerRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
                PackageManager.GET_DISABLED_COMPONENTS |
                PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS;
        } else {
        mRetrieveFlags = PackageManager.GET_DISABLED_COMPONENTS |
                PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS;
        }

        /**
         * This is a trick to prevent the foreground thread from being delayed.
@@ -742,7 +740,9 @@ public class ApplicationsState {
        for (UserHandle user : mUm.getUserProfiles()) {
            try {
                ParceledListSlice<ApplicationInfo> list =
                        mIpm.getInstalledApplications(mRetrieveFlags, user.getIdentifier());
                        mIpm.getInstalledApplications(
                                user.isOwner() ? mOwnerRetrieveFlags : mRetrieveFlags,
                                user.getIdentifier());
                mApplications.addAll(list.getList());
            } catch (RemoteException e) {
            }
@@ -817,7 +817,8 @@ public class ApplicationsState {
            if (entry == null) {
                for (int i=0; i<mApplications.size(); i++) {
                    ApplicationInfo info = mApplications.get(i);
                    if (packageName.equals(info.packageName)) {
                    if (packageName.equals(info.packageName)
                            && userId == UserHandle.getUserId(info.uid)) {
                        entry = getEntryLocked(info);
                        break;
                    }
@@ -889,7 +890,9 @@ public class ApplicationsState {
                    if (DEBUG_LOCKING) Log.v(TAG, "addPackage release lock: already exists");
                    return;
                }
                ApplicationInfo info = mIpm.getApplicationInfo(pkgName, mRetrieveFlags, userId);
                ApplicationInfo info = mIpm.getApplicationInfo(pkgName,
                        userId == UserHandle.USER_OWNER ? mOwnerRetrieveFlags : mRetrieveFlags,
                                userId);
                if (info == null) {
                    return;
                }