diff options
| author | Darryl L Johnson <darryljohnson@google.com> | 2020-06-05 12:20:32 -0700 |
|---|---|---|
| committer | Darryl L Johnson <darryljohnson@google.com> | 2020-07-06 09:41:50 -0700 |
| commit | 138c24fb136cdbd3953f81cbb7e6b875877fc0f4 (patch) | |
| tree | ebf6bec1a2ae4a776ca67dfa5f8767a82ef447a6 /core/java/android/app/ActivityTaskManager.java | |
| parent | e1e8fc451d916c28358f4907a41a3b1393aeb792 (diff) | |
Ensure split-screen support isn't reported on devices with small displays.
Several partners with devices that have small displays have run into
issues w/ CTS-on-GSI testing as these builds hardcode support for
split-screen. This prevents split-screen from being reported as
supported if the display isn't compatible according to the CDD.
Bug: 158310372
Test: android.server.wm.SplitScreenTests#testMinimumDeviceSize()
Change-Id: I0dfd6caca5116dccc115d64b755998171abe831f
Diffstat (limited to 'core/java/android/app/ActivityTaskManager.java')
| -rw-r--r-- | core/java/android/app/ActivityTaskManager.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityTaskManager.java b/core/java/android/app/ActivityTaskManager.java index 1cc63da3db0a..ef9034d8fa6b 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); |
