diff options
author | Winson Chung <winsonc@google.com> | 2022-02-08 06:22:47 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-11 21:37:40 +0000 |
commit | 7887ee9404d88865f2e63e9447c0ab4d8504cdfa (patch) | |
tree | 67315379cdb5ae42f691b1345c59c0098b48d70c | |
parent | ffb7161ee49579f239be5fae09762caeee3bdb50 (diff) | |
download | base-7887ee9404d88865f2e63e9447c0ab4d8504cdfa.tar.gz |
Backport missing permission check for querying main activity intent
- This was fixed in T in ag/16820166, but the original code was
submitted in S. This ensures that the caller of this method
is either holding the ACCESS_SHORTCUTS permission or is the
default launcher.
Bug: 229256049
Test: atest WMShellUnitTests
Change-Id: Ib233ad754a6c6e3c4e0d0e10ed788ab8e055cccc
Merged-In: Ib233ad754a6c6e3c4e0d0e10ed788ab8e055cccc
(cherry picked from commit f4ed441e180d7113b5f6ebfe711e61a2dd3fd8b1)
(cherry picked from commit b3192809643eff948d9457c8a7b36b968a7388a1)
Merged-In: Ib233ad754a6c6e3c4e0d0e10ed788ab8e055cccc
-rw-r--r-- | core/java/android/content/pm/ILauncherApps.aidl | 4 | ||||
-rw-r--r-- | core/java/android/content/pm/LauncherApps.java | 3 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/LauncherAppsService.java | 5 |
3 files changed, 7 insertions, 5 deletions
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl index 37fd3ffdeafa..2eaadb05276c 100644 --- a/core/java/android/content/pm/ILauncherApps.aidl +++ b/core/java/android/content/pm/ILauncherApps.aidl @@ -56,8 +56,8 @@ interface ILauncherApps { void startActivityAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); - PendingIntent getActivityLaunchIntent(in ComponentName component, in Bundle opts, - in UserHandle user); + PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component, + in Bundle opts, in UserHandle user); void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 0f9acadb11f9..4b6c586266a9 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -752,7 +752,8 @@ public class LauncherApps { } try { // due to b/209607104, startActivityOptions will be ignored - return mService.getActivityLaunchIntent(component, null /* opts */, user); + return mService.getActivityLaunchIntent(mContext.getPackageName(), component, + null /* opts */, user); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index 24b9f48e71a6..a238593a96f8 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -1098,8 +1098,9 @@ public class LauncherAppsService extends SystemService { } @Override - public PendingIntent getActivityLaunchIntent(ComponentName component, Bundle opts, - UserHandle user) { + public PendingIntent getActivityLaunchIntent(String callingPackage, ComponentName component, + Bundle opts, UserHandle user) { + ensureShortcutPermission(callingPackage); if (!canAccessProfile(user.getIdentifier(), "Cannot start activity")) { throw new ActivityNotFoundException("Activity could not be found"); } |