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

Commit 5ee3cb87 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not show hidden apps in DO/PO mode"

parents 4a710a85 e6a90389
Loading
Loading
Loading
Loading
+29 −18
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.AppDetailsActivity;
import android.app.AppGlobals;
import android.app.IApplicationThread;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -115,6 +116,7 @@ public class LauncherAppsService extends SystemService {
        private final ShortcutServiceInternal mShortcutServiceInternal;
        private final PackageCallbackList<IOnAppsChangedListener> mListeners
                = new PackageCallbackList<IOnAppsChangedListener>();
        private final DevicePolicyManager mDpm;

        private final MyPackageMonitor mPackageMonitor = new MyPackageMonitor();

@@ -133,6 +135,7 @@ public class LauncherAppsService extends SystemService {
                    LocalServices.getService(ShortcutServiceInternal.class));
            mShortcutServiceInternal.addListener(mPackageMonitor);
            mCallbackHandler = BackgroundThread.getHandler();
            mDpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
        }

        @VisibleForTesting
@@ -319,6 +322,17 @@ public class LauncherAppsService extends SystemService {
            }

            final int callingUid = injectBinderCallingUid();
            final long ident = injectClearCallingIdentity();
            try {
                if (mUm.getUserInfo(user.getIdentifier()).isManagedProfile()) {
                    // Managed profile should not show hidden apps
                    return launcherActivities;
                }
                if (mDpm.getDeviceOwnerComponentOnAnyUser() != null) {
                    // Device owner devices should not show hidden apps
                    return launcherActivities;
                }

                final ArrayList<ResolveInfo> result = new ArrayList<>(launcherActivities.getList());
                final PackageManagerInternal pmInt =
                        LocalServices.getService(PackageManagerInternal.class);
@@ -338,9 +352,6 @@ public class LauncherAppsService extends SystemService {
                    }
                    return new ParceledListSlice<>(result);
                }

            long ident = injectClearCallingIdentity();
            try {
                final HashSet<String> visiblePackages = new HashSet<>();
                for (ResolveInfo info : result) {
                    visiblePackages.add(info.activityInfo.packageName);