Skip to content

Commit da9ce92

Browse files
Winson ChungOhMyVenyx
authored andcommitted
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 f4ed441) (cherry picked from commit b319280) Merged-In: Ib233ad754a6c6e3c4e0d0e10ed788ab8e055cccc
1 parent 6f692e2 commit da9ce92

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

core/java/android/content/pm/ILauncherApps.aidl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ interface ILauncherApps {
5656
void startActivityAsUser(in IApplicationThread caller, String callingPackage,
5757
String callingFeatureId, in ComponentName component, in Rect sourceBounds,
5858
in Bundle opts, in UserHandle user);
59-
PendingIntent getActivityLaunchIntent(in ComponentName component, in Bundle opts,
60-
in UserHandle user);
59+
PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component,
60+
in Bundle opts, in UserHandle user);
6161
void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage,
6262
String callingFeatureId, in ComponentName component, in Rect sourceBounds,
6363
in Bundle opts, in UserHandle user);

core/java/android/content/pm/LauncherApps.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ public PendingIntent getMainActivityLaunchIntent(@NonNull ComponentName componen
752752
}
753753
try {
754754
// due to b/209607104, startActivityOptions will be ignored
755-
return mService.getActivityLaunchIntent(component, null /* opts */, user);
755+
return mService.getActivityLaunchIntent(mContext.getPackageName(), component,
756+
null /* opts */, user);
756757
} catch (RemoteException re) {
757758
throw re.rethrowFromSystemServer();
758759
}

services/core/java/com/android/server/pm/LauncherAppsService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,9 @@ public void startSessionDetailsActivityAsUser(IApplicationThread caller,
11191119
}
11201120

11211121
@Override
1122-
public PendingIntent getActivityLaunchIntent(ComponentName component, Bundle opts,
1123-
UserHandle user) {
1122+
public PendingIntent getActivityLaunchIntent(String callingPackage, ComponentName component,
1123+
Bundle opts, UserHandle user) {
1124+
ensureShortcutPermission(callingPackage);
11241125
if (!canAccessProfile(user.getIdentifier(), "Cannot start activity")) {
11251126
throw new ActivityNotFoundException("Activity could not be found");
11261127
}

0 commit comments

Comments
 (0)