diff --git a/api/current.txt b/api/current.txt index 8a8a1d795602e..e6813fd014d58 100644 --- a/api/current.txt +++ b/api/current.txt @@ -10620,6 +10620,7 @@ package android.content.pm { 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 e23e4664d37a5..ba828b7e41d7f 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -11306,6 +11306,7 @@ package android.content.pm { 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 e79fc1e09e314..d5936b1a333da 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -10659,6 +10659,7 @@ package android.content.pm { 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 e2883873752c9..4004bd6686b1f 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1117,16 +1117,6 @@ public class ActivityManager { com.android.internal.R.bool.config_supportsSplitScreenMultiWindow); } - /** - * 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 aa7cdf7b475e5..02d18841f489e 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -155,6 +155,7 @@ public class ActivityOptions { /** * 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 @@ public class ActivityOptions { * 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 @@ public class ActivityOptions { /** * 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. + *

+ * 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 4f0ff61d2adc0..8f15dd8c8da0c 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -2292,6 +2292,14 @@ public abstract class PackageManager { @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; + /** + * 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 diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index f4e3b313e98aa..35654d76dee5b 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.FREEFORM_WORKSPACE_STACK_ID; 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 @@ public class ActivityManagerService extends IActivityManager.Stub 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 2b3a19a83e556..04c2af5af339e 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 @@ final class ActivityManagerShellCommand extends ShellCommand { 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 @@ final class ActivityManagerShellCommand extends ShellCommand { 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 packages = new ArrayList<>(); @@ -2637,8 +2626,6 @@ final class ActivityManagerShellCommand extends ShellCommand { 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 "); pw.println(" Suppresses configuration changes due to user resizing an activity/task."); pw.println(" set-inactive [--user ] true|false");