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

Commit bcbadba6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Preventing component spoofing during getShortcutConfigActivityIntent"...

Merge "Preventing component spoofing during getShortcutConfigActivityIntent" into sc-dev am: d8b162aa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14189114

Change-Id: I6643e965f7899ebecb64c3318b62f7dc3ce458df
parents bb4b3a84 d8b162aa
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -636,9 +636,25 @@ public class LauncherAppsService extends SystemService {
            Objects.requireNonNull(component);

            // All right, create the sender.
            Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT).setComponent(component);
            final int callingUid = injectBinderCallingUid();
            final long identity = Binder.clearCallingIdentity();
            try {
                final PackageManagerInternal pmInt =
                        LocalServices.getService(PackageManagerInternal.class);
                Intent packageIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT)
                        .setPackage(component.getPackageName());
                List<ResolveInfo> apps = pmInt.queryIntentActivities(packageIntent,
                        packageIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        PackageManager.MATCH_DIRECT_BOOT_AWARE
                                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                        callingUid, user.getIdentifier());
                // ensure that the component is present in the list
                if (!apps.stream().anyMatch(
                        ri -> component.getClassName().equals(ri.activityInfo.name))) {
                    return null;
                }

                Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT).setComponent(component);
                final PendingIntent pi = PendingIntent.getActivityAsUser(
                        mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT
                                | PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT,