diff options
| author | Winson Chung <winsonc@google.com> | 2022-02-08 06:22:47 +0000 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2022-02-09 07:21:44 +0000 |
| commit | f4ed441e180d7113b5f6ebfe711e61a2dd3fd8b1 (patch) | |
| tree | 4b4613733018228336547a7dcc4702d426a736b7 /core/java/android | |
| parent | 5f32b96cee6932c42879ef1a8c9023192632fda8 (diff) | |
Allow dragging to launch multiple instances of the same activity
- When dragging to launch a new app, apply MULTIPLE_TASK to the launch
intent to allow apps that support it to show side-by-side
- This requires the pending intent resolved from LauncherAppsService to
be mutable (should be ok since we only use this api from SysUI)
- Also remove some unused members and duplication of getting the running
task when dragging
Bug: 207686016
Test: atest WMShellUnitTests
Change-Id: Ib233ad754a6c6e3c4e0d0e10ed788ab8e055cccc
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/content/pm/ILauncherApps.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/content/pm/LauncherApps.java | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl index cb8988eb5b92..08cfbf76a040 100644 --- a/core/java/android/content/pm/ILauncherApps.aidl +++ b/core/java/android/content/pm/ILauncherApps.aidl @@ -58,7 +58,7 @@ 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, + PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component, in UserHandle user); void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index e35c2f48038d..301d1bbc8e9d 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -749,24 +749,29 @@ public class LauncherApps { } /** - * Returns a PendingIntent that would start the same activity started from - * {@link #startMainActivity(ComponentName, UserHandle, Rect, Bundle)}. + * Returns a mutable PendingIntent that would start the same activity started from + * {@link #startMainActivity(ComponentName, UserHandle, Rect, Bundle)}. The caller needs to + * take care in ensuring that the mutable intent returned is not passed to untrusted parties. * * @param component The ComponentName of the activity to launch * @param startActivityOptions This parameter is no longer supported * @param user The UserHandle of the profile * @hide */ + @RequiresPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS) @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); } try { - // due to b/209607104, startActivityOptions will be ignored - return mService.getActivityLaunchIntent(component, null /* opts */, user); + return mService.getActivityLaunchIntent(mContext.getPackageName(), component, user); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } |
