From d532eb1810181dce134f00e11b928cd63a778fbb Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 3 May 2023 18:00:20 +0000 Subject: [PATCH] Enforce sysui-held permissions when getting main launch intent - Because a mutable pending intent is returned, we actually do need to enforce that SysUI is the only caller of this method Bug: 278881947 Bug: 253216640 Bug: 256590334 Test: atest LauncherAppTests Change-Id: I89dd6891a826f934a247881c6dd9ec5cacf2d082 --- core/java/android/content/pm/LauncherApps.java | 4 ---- .../java/com/android/server/pm/LauncherAppsService.java | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 27270d9f378f8..d6592d5727261 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -765,10 +765,6 @@ public class LauncherApps { @Nullable public PendingIntent getMainActivityLaunchIntent(@NonNull ComponentName component, @Nullable Bundle startActivityOptions, @NonNull UserHandle user) { - if (mContext.checkSelfPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS) - != PackageManager.PERMISSION_GRANTED) { - Log.w(TAG, "Only allowed for recents."); - } logErrorForInvalidProfileAccess(user); if (DEBUG) { Log.i(TAG, "GetMainActivityLaunchIntent " + component + " " + user); diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index 9b1a80bed17b2..0bd6dffed0240 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -1330,7 +1330,11 @@ public class LauncherAppsService extends SystemService { @Override public PendingIntent getActivityLaunchIntent(String callingPackage, ComponentName component, UserHandle user) { - ensureShortcutPermission(callingPackage); + if (mContext.checkPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS, + injectBinderCallingPid(), injectBinderCallingUid()) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Permission START_TASKS_FROM_RECENTS required"); + } if (!canAccessProfile(user.getIdentifier(), "Cannot start activity")) { throw new ActivityNotFoundException("Activity could not be found"); }