summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2022-02-10 18:59:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-02-10 18:59:35 +0000
commitab4e152e0552144aa1c43b855128854be8df25ad (patch)
tree78a670868364f13667af24b2c7c540d86619a3be /core/java/android
parent556e1ae1c66e6fc63946d0b0686cd952ccaa997b (diff)
parentf4ed441e180d7113b5f6ebfe711e61a2dd3fd8b1 (diff)
Merge "Allow dragging to launch multiple instances of the same activity"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/ILauncherApps.aidl2
-rw-r--r--core/java/android/content/pm/LauncherApps.java13
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();
}