Merge "Use feature instead of hidden config for multi-display" into oc-dev
diff --git a/api/current.txt b/api/current.txt
index 53b1c1e..cbe4195 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -10616,6 +10616,7 @@
field public static final int DONT_KILL_APP = 1; // 0x1
field public static final java.lang.String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
field public static final java.lang.String EXTRA_VERIFICATION_RESULT = "android.content.pm.extra.VERIFICATION_RESULT";
+ field public static final java.lang.String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS = "android.software.activities_on_secondary_displays";
field public static final java.lang.String FEATURE_APP_WIDGETS = "android.software.app_widgets";
field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
field public static final java.lang.String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
diff --git a/api/system-current.txt b/api/system-current.txt
index f10fd9b..34f05da 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -11300,6 +11300,7 @@
field public static final java.lang.String EXTRA_REQUEST_PERMISSIONS_RESULTS = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
field public static final java.lang.String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
field public static final java.lang.String EXTRA_VERIFICATION_RESULT = "android.content.pm.extra.VERIFICATION_RESULT";
+ field public static final java.lang.String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS = "android.software.activities_on_secondary_displays";
field public static final java.lang.String FEATURE_APP_WIDGETS = "android.software.app_widgets";
field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
field public static final java.lang.String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
diff --git a/api/test-current.txt b/api/test-current.txt
index b1d55c8..ac49a9b 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -10655,6 +10655,7 @@
field public static final int DONT_KILL_APP = 1; // 0x1
field public static final java.lang.String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
field public static final java.lang.String EXTRA_VERIFICATION_RESULT = "android.content.pm.extra.VERIFICATION_RESULT";
+ field public static final java.lang.String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS = "android.software.activities_on_secondary_displays";
field public static final java.lang.String FEATURE_APP_WIDGETS = "android.software.app_widgets";
field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
field public static final java.lang.String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index e288387..4004bd6 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -1118,16 +1118,6 @@
}
/**
- * Returns true if the system supports running activities on secondary displays.
- * @hide
- */
- static public boolean supportsMultiDisplay() {
- return !isLowRamDeviceStatic()
- && Resources.getSystem().getBoolean(
- com.android.internal.R.bool.config_supportsMultiDisplay);
- }
-
- /**
* Return the maximum number of actions that will be displayed in the picture-in-picture UI when
* the user interacts with the activity currently in picture-in-picture mode.
*/
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index aa7cdf7..02d1884 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -155,6 +155,7 @@
/**
* The display id the activity should be launched into.
+ * @see #setLaunchDisplayId(int)
* @hide
*/
private static final String KEY_LAUNCH_DISPLAY_ID = "android.activity.launchDisplayId";
@@ -1038,6 +1039,7 @@
* Gets the id of the display where activity should be launched.
* @return The id of the display where activity should be launched,
* {@link android.view.Display#INVALID_DISPLAY} if not set.
+ * @see #setLaunchDisplayId(int)
*/
public int getLaunchDisplayId() {
return mLaunchDisplayId;
@@ -1045,6 +1047,12 @@
/**
* Sets the id of the display where activity should be launched.
+ * An app can launch activities on public displays or private displays that are owned by the app
+ * or where an app already has activities. Otherwise, trying to launch on a private display
+ * or providing an invalid display id will result in an exception.
+ * <p>
+ * Setting launch display id will be ignored on devices that don't have
+ * {@link android.content.pm.PackageManager#FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS}.
* @param launchDisplayId The id of the display where the activity should be launched.
* @return {@code this} {@link ActivityOptions} instance.
*/
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 50e3e68..fa3e4e9 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -2285,6 +2285,14 @@
/**
* Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
+ * The device supports running activities on secondary displays.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
+ = "android.software.activities_on_secondary_displays";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
* The device supports creating secondary users and managed profiles via
* {@link DevicePolicyManager}.
*/
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index f4e3b31..35654d7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -30,6 +30,7 @@
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
+import static android.content.pm.PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS;
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
import static android.content.pm.PackageManager.FEATURE_LEANBACK_ONLY;
import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
@@ -13766,7 +13767,8 @@
final boolean supportsMultiWindow = ActivityManager.supportsMultiWindow();
final boolean supportsSplitScreenMultiWindow =
ActivityManager.supportsSplitScreenMultiWindow();
- final boolean supportsMultiDisplay = ActivityManager.supportsMultiDisplay();
+ final boolean supportsMultiDisplay = mContext.getPackageManager()
+ .hasSystemFeature(FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS);
final String debugApp = Settings.Global.getString(resolver, DEBUG_APP);
final boolean waitForDebugger = Settings.Global.getInt(resolver, WAIT_FOR_DEBUGGER, 0) != 0;
final boolean alwaysFinishActivities =
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 2b3a19a..04c2af5 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -247,8 +247,6 @@
return runSupportsMultiwindow(pw);
case "supports-split-screen-multi-window":
return runSupportsSplitScreenMultiwindow(pw);
- case "supports-multi-display":
- return runSupportsMultiDisplay(pw);
case "update-appinfo":
return runUpdateApplicationInfo(pw);
case "no-home-screen":
@@ -2399,15 +2397,6 @@
return 0;
}
- int runSupportsMultiDisplay(PrintWriter pw) throws RemoteException {
- final Resources res = getResources(pw);
- if (res == null) {
- return -1;
- }
- pw.println(ActivityManager.supportsMultiDisplay());
- return 0;
- }
-
int runUpdateApplicationInfo(PrintWriter pw) throws RemoteException {
int userid = UserHandle.parseUserArg(getNextArgRequired());
ArrayList<String> packages = new ArrayList<>();
@@ -2637,8 +2626,6 @@
pw.println(" Returns true if the device supports multiwindow.");
pw.println(" supports-split-screen-multi-window");
pw.println(" Returns true if the device supports split screen multiwindow.");
- pw.println(" supports-multi-display");
- pw.println(" Returns true if the device supports multi-display.");
pw.println(" suppress-resize-config-changes <true|false>");
pw.println(" Suppresses configuration changes due to user resizing an activity/task.");
pw.println(" set-inactive [--user <USER_ID>] <PACKAGE> true|false");