summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAndrii Kulian <akulian@google.com>2018-12-23 20:43:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-12-23 20:43:03 +0000
commit60e88ecdca6929863719fde6d9048a95fb1b367e (patch)
tree8cee9213312c24e9ca0825780548e5b017a9f6b2 /core/java
parent89e8be4121e09a60aa8adc7d74fb9236e5aec064 (diff)
parent2eb84b28779b35da8e410564db33a8aab1f3fbcb (diff)
Merge "Add API to check if activity can be started on a display"
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);