summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2020-10-15 22:50:34 -0700
committerWinson Chung <winsonc@google.com>2020-10-26 14:33:05 -0700
commit8c1fc3ea3a6d2ccfbd369eb843809eb65bed2427 (patch)
treed27714dd2a52873a75305fe9884ceb98b006d06e /core/java/android
parent4f2f5f15478773261be6ab6158924ea1cb2b5efd (diff)
2/ Add support for dragging shortcuts and tasks
- Add mechanism for creating PendingIntents to launch apps in the same way as starting through LauncherApps service - Require callers starting a task launch to either be the recents component or have the START_TASKS_FROM_RECENTS permission Bug: 169894807 Test: atest LauncherAppsTest Test: atest DragDropControllerTest Change-Id: I2f9f622b4ef7a8aba06b0854a1549a2c07cf38e1
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/ClipDescription.java19
-rw-r--r--core/java/android/content/pm/ILauncherApps.aidl3
-rw-r--r--core/java/android/content/pm/LauncherApps.java24
3 files changed, 45 insertions, 1 deletions
diff --git a/core/java/android/content/ClipDescription.java b/core/java/android/content/ClipDescription.java
index dedfce6f6b96..38ab8aa2dcbc 100644
--- a/core/java/android/content/ClipDescription.java
+++ b/core/java/android/content/ClipDescription.java
@@ -64,12 +64,29 @@ public class ClipDescription implements Parcelable {
public static final String MIMETYPE_TEXT_INTENT = "text/vnd.android.intent";
/**
- * The MIME type for an activity.
+ * The MIME type for an activity. The ClipData must include intents with required extras
+ * {@link #EXTRA_PENDING_INTENT} and {@link Intent#EXTRA_USER}, and an optional
+ * {@link #EXTRA_ACTIVITY_OPTIONS}.
* @hide
*/
public static final String MIMETYPE_APPLICATION_ACTIVITY = "application/vnd.android.activity";
/**
+ * The MIME type for a shortcut. The ClipData must include intents with required extras
+ * {@link #EXTRA_PENDING_INTENT} and {@link Intent#EXTRA_USER}, and an optional
+ * {@link #EXTRA_ACTIVITY_OPTIONS}.
+ * @hide
+ */
+ public static final String MIMETYPE_APPLICATION_SHORTCUT = "application/vnd.android.shortcut";
+
+ /**
+ * The MIME type for a task. The ClipData must include an intent with a required extra
+ * {@link Intent#EXTRA_TASK_ID} of the task to launch.
+ * @hide
+ */
+ public static final String MIMETYPE_APPLICATION_TASK = "application/vnd.android.task";
+
+ /**
* The MIME type for data whose type is otherwise unknown.
* <p>
* Per RFC 2046, the "application" media type is to be used for discrete
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl
index d9ecf46069cd..d688614f6caa 100644
--- a/core/java/android/content/pm/ILauncherApps.aidl
+++ b/core/java/android/content/pm/ILauncherApps.aidl
@@ -17,6 +17,7 @@
package android.content.pm;
import android.app.IApplicationThread;
+import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentSender;
@@ -55,6 +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);
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 b7af397cd36a..2909d66d72ff 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -17,6 +17,7 @@
package android.content.pm;
import static android.Manifest.permission;
+import static android.app.PendingIntent.FLAG_IMMUTABLE;
import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
@@ -716,6 +717,29 @@ public class LauncherApps {
}
/**
+ * Returns a PendingIntent that would start the same activity started from
+ * {@link #startMainActivity(ComponentName, UserHandle, Rect, Bundle)}.
+ *
+ * @param component The ComponentName of the activity to launch
+ * @param startActivityOptions Options to pass to startActivity
+ * @param user The UserHandle of the profile
+ * @hide
+ */
+ @Nullable
+ public PendingIntent getMainActivityLaunchIntent(@NonNull ComponentName component,
+ @Nullable Bundle startActivityOptions, @NonNull UserHandle user) {
+ logErrorForInvalidProfileAccess(user);
+ if (DEBUG) {
+ Log.i(TAG, "GetMainActivityLaunchIntent " + component + " " + user);
+ }
+ try {
+ return mService.getActivityLaunchIntent(component, startActivityOptions, user);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns the activity info for a given intent and user handle, if it resolves. Otherwise it
* returns null.
*