diff --git a/api/test-current.txt b/api/test-current.txt index 113d585164f67..e11fcde984e3f 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -144,6 +144,7 @@ package android.app { method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void stopSystemLockTaskMode(); method public static boolean supportsMultiWindow(android.content.Context); method public static boolean supportsSplitScreenMultiWindow(android.content.Context); + field public static final int DEFAULT_MINIMAL_SPLIT_SCREEN_DISPLAY_SIZE_DP = 440; // 0x1b8 field public static final int INVALID_STACK_ID = -1; // 0xffffffff field public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1; // 0x1 field public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0; // 0x0 diff --git a/core/java/android/app/ActivityTaskManager.java b/core/java/android/app/ActivityTaskManager.java index 0f31529451fb3..4283d7ad2a62c 100644 --- a/core/java/android/app/ActivityTaskManager.java +++ b/core/java/android/app/ActivityTaskManager.java @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.util.DisplayMetrics; import android.util.Singleton; import java.util.List; @@ -139,6 +140,8 @@ public class ActivityTaskManager { public static final String EXTRA_IGNORE_TARGET_SECURITY = "android.app.extra.EXTRA_IGNORE_TARGET_SECURITY"; + /** The minimal size of a display's long-edge needed to support split-screen multi-window. */ + public static final int DEFAULT_MINIMAL_SPLIT_SCREEN_DISPLAY_SIZE_DP = 440; private static int sMaxRecentTasks = -1; @@ -282,8 +285,23 @@ public class ActivityTaskManager { com.android.internal.R.bool.config_supportsMultiWindow); } - /** Returns true if the system supports split screen multi-window. */ + /** + * Returns {@code true} if the display the context is associated with supports split screen + * multi-window. + * + * @throws UnsupportedOperationException if the supplied {@link Context} is not associated with + * a display. + */ public static boolean supportsSplitScreenMultiWindow(Context context) { + DisplayMetrics dm = new DisplayMetrics(); + context.getDisplay().getRealMetrics(dm); + + int widthDp = (int) (dm.widthPixels / dm.density); + int heightDp = (int) (dm.heightPixels / dm.density); + if (Math.max(widthDp, heightDp) < DEFAULT_MINIMAL_SPLIT_SCREEN_DISPLAY_SIZE_DP) { + return false; + } + return supportsMultiWindow(context) && Resources.getSystem().getBoolean( com.android.internal.R.bool.config_supportsSplitScreenMultiWindow);