summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ActivityManager.java26
-rw-r--r--core/java/android/app/IActivityTaskManager.aidl2
2 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 84c778502393..d42326020323 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -1976,6 +1976,32 @@ public class ActivityManager {
}
/**
+ * Check if the context is allowed to start an activity on specified display. Some launch
+ * restrictions may apply to secondary displays that are private, virtual, or owned by the
+ * system, in which case an activity start may throw a {@link SecurityException}. Call this
+ * method prior to starting an activity on a secondary display to check if the current context
+ * has access to it.
+ *
+ * @see ActivityOptions#setLaunchDisplayId(int)
+ * @see android.view.Display.FLAG_PRIVATE
+ * @see android.view.Display.TYPE_VIRTUAL
+ *
+ * @param context Source context, from which an activity will be started.
+ * @param displayId Target display id.
+ * @param intent Intent used to launch an activity.
+ * @return {@code true} if a call to start an activity on the target display is allowed for the
+ * provided context and no {@link SecurityException} will be thrown, {@code false} otherwise.
+ */
+ public boolean isActivityStartAllowedOnDisplay(Context context, int displayId, Intent intent) {
+ try {
+ return getTaskService().isActivityStartAllowedOnDisplay(displayId, intent,
+ intent.resolveTypeIfNeeded(context.getContentResolver()), context.getUserId());
+ } catch (RemoteException e) {
+ throw new RuntimeException("Failure from system", e);
+ }
+ }
+
+ /**
* Information you can retrieve about a particular Service that is
* currently running in the system.
*/
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
index 777a4949a132..f549e1890b5e 100644
--- a/core/java/android/app/IActivityTaskManager.aidl
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -119,6 +119,8 @@ interface IActivityTaskManager {
in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options,
IBinder permissionToken, boolean ignoreTargetSecurity, int userId);
+ boolean isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType,
+ int userId);
void unhandledBack();
boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);