19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/* 29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2006 The Android Open Source Project 39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License. 69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at 79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and 149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License. 159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.view; 189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1967e2ae86396c6d0f989285275cbf908dee5e71f7Aurimas Liutikasimport static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE; 2067e2ae86396c6d0f989285275cbf908dee5e71f7Aurimas Liutikas 21f173c323449840771312afe5cbec03a71281e6ffRonghua Wuimport android.annotation.IntDef; 2258e829f71d2c525309e5bb5a1c02dc64397df221Michael Wrightimport android.annotation.RequiresPermission; 23e99bc0501a288735d337f2ff64f8fa47f766a59bAdrian Roosimport android.app.KeyguardManager; 2448d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautnerimport android.content.res.CompatibilityInfo; 25e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guyimport android.content.res.Configuration; 26609bf65668181d93502a57575f6f20281f2494b8Bryce Leeimport android.content.res.Resources; 27fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brownimport android.graphics.PixelFormat; 28ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackbornimport android.graphics.Point; 29ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackbornimport android.graphics.Rect; 30732a90a794bc8615788042e9073e2da0b8829808Andrii Kulianimport android.hardware.display.DisplayManager; 31bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brownimport android.hardware.display.DisplayManagerGlobal; 32b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligandimport android.os.Parcel; 33b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligandimport android.os.Parcelable; 34a506a6ec94863a35acca9feb165db76ddac3892cJeff Brownimport android.os.Process; 35ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackbornimport android.os.SystemClock; 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.util.DisplayMetrics; 37fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brownimport android.util.Log; 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 39f173c323449840771312afe5cbec03a71281e6ffRonghua Wuimport java.lang.annotation.Retention; 40f173c323449840771312afe5cbec03a71281e6ffRonghua Wuimport java.lang.annotation.RetentionPolicy; 413f145a2f958320766ae9240c7a57debc20d578aaMichael Wrightimport java.util.Arrays; 423f145a2f958320766ae9240c7a57debc20d578aaMichael Wright 43bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown/** 44fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Provides information about the size and density of a logical display. 45fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 46fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The display area is described in two different ways. 47fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <ul> 48fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <li>The application display area specifies the part of the display that may contain 49fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * an application window, excluding the system decorations. The application display area may 50fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * be smaller than the real display area because the system subtracts the space needed 51fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * for decor elements such as the status bar. Use the following methods to query the 52fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * application display area: {@link #getSize}, {@link #getRectSize} and {@link #getMetrics}.</li> 53fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <li>The real display area specifies the part of the display that contains content 54fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * including the system decorations. Even so, the real display area may be smaller than the 55fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * physical size of the display if the window manager is emulating a smaller display 56cd097993399f94aa663c5fad50e444b75e6ee5ddAndrii Kulian * using (adb shell wm size). Use the following methods to query the 57fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li> 58fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </ul> 59fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p><p> 60fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * A logical display does not necessarily represent a particular physical display device 61fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * such as the built-in screen or an external monitor. The contents of a logical 62fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * display may be presented on one or more physical displays according to the devices 63fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * that are currently attached and whether mirroring has been enabled. 64fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 65bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown */ 66fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brownpublic final class Display { 67fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private static final String TAG = "Display"; 68bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private static final boolean DEBUG = false; 69fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 70bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private final DisplayManagerGlobal mGlobal; 71fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private final int mDisplayId; 724ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown private final int mLayerStack; 7392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown private final int mFlags; 7492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown private final int mType; 7592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown private final String mAddress; 76a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown private final int mOwnerUid; 77a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown private final String mOwnerPackageName; 78609bf65668181d93502a57575f6f20281f2494b8Bryce Lee private final Resources mResources; 79609bf65668181d93502a57575f6f20281f2494b8Bryce Lee private DisplayAdjustments mDisplayAdjustments; 80bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown 81bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private DisplayInfo mDisplayInfo; // never null 82bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private boolean mIsValid; 83fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 84fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // Temporary display metrics structure used for compatibility mode. 85fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private final DisplayMetrics mTempMetrics = new DisplayMetrics(); 86fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 87fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // We cache the app width and height properties briefly between calls 88fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // to getHeight() and getWidth() to ensure that applications perceive 89fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // consistent results when the size changes (most of the time). 90fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // Applications should now be using getSize() instead. 91fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private static final int CACHED_APP_SIZE_DURATION_MILLIS = 20; 92fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private long mLastCachedAppSizeUpdate; 93fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private int mCachedAppWidthCompat; 94fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private int mCachedAppHeightCompat; 955fd2169eabd77e6bfafaf456e58051a3bafb2bcaDianne Hackborn 969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 9798365d7663cbd82979a5700faf0050220b01084dJeff Brown * The default Display id, which is the id of the built-in primary display 9898365d7663cbd82979a5700faf0050220b01084dJeff Brown * assuming there is one. 999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int DEFAULT_DISPLAY = 0; 1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 10326698514fbac587675221149aca98f3ea6414d55Wale Ogunwale * Invalid display id. 10426698514fbac587675221149aca98f3ea6414d55Wale Ogunwale */ 10526698514fbac587675221149aca98f3ea6414d55Wale Ogunwale public static final int INVALID_DISPLAY = -1; 10626698514fbac587675221149aca98f3ea6414d55Wale Ogunwale 10726698514fbac587675221149aca98f3ea6414d55Wale Ogunwale /** 10877aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * Display flag: Indicates that the display supports compositing content 10977aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * that is stored in protected graphics buffers. 110c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * <p> 111f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is set then the display device supports compositing protected buffers. 112f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 113f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is not set then the display device may not support compositing 114f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * protected buffers; the user may see a blank region on the screen instead of 115f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * the protected content. 116f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 11777aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * Secure (DRM) video decoders may allocate protected graphics buffers to request that 11877aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * a hardware-protected path be provided between the video decoder and the external 11977aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * display sink. If a hardware-protected path is not available, then content stored 12077aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * in protected graphics buffers may not be composited. 121c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * </p><p> 122f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * An application can use the absence of this flag as a hint that it should not use protected 123f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * buffers for this display because the content may not be visible. For example, 124f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * if the flag is not set then the application may choose not to show content on this 125f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * display, show an informative error message, select an alternate content stream 126f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * or adopt a different strategy for decoding content that does not rely on 127f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * protected buffers. 128c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * </p> 129f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * 130f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * @see #getFlags 131c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown */ 13277aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 0; 133c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown 134c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown /** 135f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * Display flag: Indicates that the display has a secure video output and 136f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * supports compositing secure surfaces. 137f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * <p> 138f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is set then the display device has a secure video output 139f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * and is capable of showing secure surfaces. It may also be capable of 140f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * showing {@link #FLAG_SUPPORTS_PROTECTED_BUFFERS protected buffers}. 141f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 142f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is not set then the display device may not have a secure video 143f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * output; the user may see a blank region on the screen instead of 144f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * the contents of secure surfaces or protected buffers. 145f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 146f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * Secure surfaces are used to prevent content rendered into those surfaces 147f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * by applications from appearing in screenshots or from being viewed 148f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * on non-secure displays. Protected buffers are used by secure video decoders 149f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * for a similar purpose. 150f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 151f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * An application creates a window with a secure surface by specifying the 152f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * {@link WindowManager.LayoutParams#FLAG_SECURE} window flag. 153f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * Likewise, an application creates a {@link SurfaceView} with a secure surface 154f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * by calling {@link SurfaceView#setSecure} before attaching the secure view to 155f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * its containing window. 156f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 157f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * An application can use the absence of this flag as a hint that it should not create 158f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * secure surfaces or protected buffers on this display because the content may 159f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * not be visible. For example, if the flag is not set then the application may 160f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * choose not to show content on this display, show an informative error message, 161f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * select an alternate content stream or adopt a different strategy for decoding 162f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * content that does not rely on secure surfaces or protected buffers. 163f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p> 164f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * 165f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * @see #getFlags 166f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown */ 167f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown public static final int FLAG_SECURE = 1 << 1; 168f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown 169f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown /** 170a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Display flag: Indicates that the display is private. Only the application that 171fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * owns the display and apps that are already on the display can create windows on it. 1727d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * 1737d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * @see #getFlags 1747d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown */ 1757d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown public static final int FLAG_PRIVATE = 1 << 2; 1767d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown 1777d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown /** 1787d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * Display flag: Indicates that the display is a presentation display. 179a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * <p> 1807d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * This flag identifies secondary displays that are suitable for 1817d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * use as presentation displays such as HDMI or Wireless displays. Applications 1827d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * may automatically project their content to presentation displays to provide 1837d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * richer second screen experiences. 184a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * </p> 185a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * 186a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @see #getFlags 187a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 1887d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown public static final int FLAG_PRESENTATION = 1 << 3; 189a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 190a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 19149e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * Display flag: Indicates that the display has a round shape. 19249e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * <p> 19349e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * This flag identifies displays that are circular, elliptical or otherwise 19449e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * do not permit the user to see all the way to the logical corners of the display. 19549e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * </p> 19649e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * 19749e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * @see #getFlags 19849e7ff9647e6547c2b852944a5435a05794b9951Adam Powell */ 19949e7ff9647e6547c2b852944a5435a05794b9951Adam Powell public static final int FLAG_ROUND = 1 << 4; 20049e7ff9647e6547c2b852944a5435a05794b9951Adam Powell 20149e7ff9647e6547c2b852944a5435a05794b9951Adam Powell /** 202fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * Display flag: Indicates that the display can show its content when non-secure keyguard is 203fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * shown. 204fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * <p> 205732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * This flag identifies secondary displays that will continue showing content if keyguard can be 206732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * dismissed without entering credentials. 207732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * </p><p> 208732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * An example of usage is a virtual display which content is displayed on external hardware 209732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * display that is not visible to the system directly. 210fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * </p> 211fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * 212732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * @see DisplayManager#VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD 213e99bc0501a288735d337f2ff64f8fa47f766a59bAdrian Roos * @see KeyguardManager#isDeviceSecure() 214e99bc0501a288735d337f2ff64f8fa47f766a59bAdrian Roos * @see KeyguardManager#isDeviceLocked() 215fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * @see #getFlags 21622512e8a225cee9b53f9028734d1e9d79d27f67dAndrii Kulian * @hide 217fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian */ 2187211d2eba8e02b5e7462313798fc25c0bd36ab2dAndrii Kulian public static final int FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; 219fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian 220fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian /** 221d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * Display flag: Indicates that the contents of the display should not be scaled 222d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * to fit the physical screen dimensions. Used for development only to emulate 223d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * devices with smaller physicals screens while preserving density. 224d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * 225d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * @hide 226d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown */ 227d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown public static final int FLAG_SCALING_DISABLED = 1 << 30; 228d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown 229d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown /** 23092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: Unknown display type. 23192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 23292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 23392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_UNKNOWN = 0; 23492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 23592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 23692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: Built-in display. 23792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 23892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 23992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_BUILT_IN = 1; 24092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 24192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 24292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: HDMI display. 24392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 24492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 24592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_HDMI = 2; 24692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 24792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 24892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: WiFi display. 24992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 25092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 25192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_WIFI = 3; 25292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 25392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 25492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: Overlay display. 25592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 25692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 25792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_OVERLAY = 4; 25892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 25992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 260a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Display type: Virtual display. 261a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 262a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 263a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public static final int TYPE_VIRTUAL = 5; 264a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 265a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 266037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Display state: The display state is unknown. 267037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 268037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 269037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 2701a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_UNKNOWN = ViewProtoEnums.DISPLAY_STATE_UNKNOWN; // 0 271037c33eae74bee2774897d969d48947f9abe254fJeff Brown 272037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 273037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Display state: The display is off. 274037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 275037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 276037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 2771a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_OFF = ViewProtoEnums.DISPLAY_STATE_OFF; // 1 278037c33eae74bee2774897d969d48947f9abe254fJeff Brown 279037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 280037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Display state: The display is on. 281037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 282037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 283037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 2841a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_ON = ViewProtoEnums.DISPLAY_STATE_ON; // 2 285037c33eae74bee2774897d969d48947f9abe254fJeff Brown 286037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 2875dc219142a756d57355b511c8f8ab913c01710daJeff Brown * Display state: The display is dozing in a low power state; it is still 2885dc219142a756d57355b511c8f8ab913c01710daJeff Brown * on but is optimized for showing system-provided content while the 2895dc219142a756d57355b511c8f8ab913c01710daJeff Brown * device is non-interactive. 290037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 291037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 292037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see android.os.PowerManager#isInteractive 293037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 2941a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_DOZE = ViewProtoEnums.DISPLAY_STATE_DOZE; // 3 2955dc219142a756d57355b511c8f8ab913c01710daJeff Brown 2965dc219142a756d57355b511c8f8ab913c01710daJeff Brown /** 2975dc219142a756d57355b511c8f8ab913c01710daJeff Brown * Display state: The display is dozing in a suspended low power state; it is still 29810a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * on but the CPU is not updating it. This may be used in one of two ways: to show 29910a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * static system-provided content while the device is non-interactive, or to allow 30010a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * a "Sidekick" compute resource to update the display. For this reason, the 30110a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * CPU must not control the display in this mode. 3025dc219142a756d57355b511c8f8ab913c01710daJeff Brown * 3035dc219142a756d57355b511c8f8ab913c01710daJeff Brown * @see #getState 3045dc219142a756d57355b511c8f8ab913c01710daJeff Brown * @see android.os.PowerManager#isInteractive 3055dc219142a756d57355b511c8f8ab913c01710daJeff Brown */ 3061a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_DOZE_SUSPEND = ViewProtoEnums.DISPLAY_STATE_DOZE_SUSPEND; // 4 307037c33eae74bee2774897d969d48947f9abe254fJeff Brown 3083107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon /** 3093107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * Display state: The display is on and optimized for VR mode. 3103107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * 3113107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * @see #getState 3123107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * @see android.os.PowerManager#isInteractive 3133107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon */ 3141a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_VR = ViewProtoEnums.DISPLAY_STATE_VR; // 5 3153107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon 31610a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix /** 31710a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * Display state: The display is in a suspended full power state; it is still 31810a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * on but the CPU is not updating it. This may be used in one of two ways: to show 31910a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * static system-provided content while the device is non-interactive, or to allow 32010a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * a "Sidekick" compute resource to update the display. For this reason, the 32110a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * CPU must not control the display in this mode. 32210a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * 32310a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * @see #getState 32410a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * @see android.os.PowerManager#isInteractive 32510a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix */ 3261a1b0464cb43903ed540f4c43fd423b16e398c04Bookatz public static final int STATE_ON_SUSPEND = ViewProtoEnums.DISPLAY_STATE_ON_SUSPEND; // 6 32710a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix 3281c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright /* The color mode constants defined below must be kept in sync with the ones in 3296d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * system/core/include/system/graphics-base.h */ 3301c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 3311c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright /** 3321c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Display color mode: The current color mode is unknown or invalid. 3331c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * @hide 3341c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright */ 3351c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public static final int COLOR_MODE_INVALID = -1; 3361c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 3371c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright /** 3381c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Display color mode: The default or native gamut of the display. 3391c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * @hide 3401c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright */ 3411c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public static final int COLOR_MODE_DEFAULT = 0; 3421c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 3436d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3446d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_625 = 1; 3456d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3466d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_625_UNADJUSTED = 2; 3476d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3486d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_525 = 3; 3496d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3506d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_525_UNADJUSTED = 4; 3516d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3526d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT709 = 5; 3536d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3546d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_DCI_P3 = 6; 3556d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3561c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public static final int COLOR_MODE_SRGB = 7; 3576d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3586d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_ADOBE_RGB = 8; 3596d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3606d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_DISPLAY_P3 = 9; 3611c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 362037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 363250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * Indicates that when display is removed, all its activities will be moved to the primary 364250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * display and the topmost activity should become focused. 365250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * 366250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @hide 367250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian */ 368250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian public static final int REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY = 0; 369250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian /** 370250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * Indicates that when display is removed, all its stacks and tasks will be removed, all 371250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * activities will be destroyed according to the usual lifecycle. 372250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * 373250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @hide 374250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian */ 375250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian public static final int REMOVE_MODE_DESTROY_CONTENT = 1; 376250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian 377250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian /** 378fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Internal method to create a display. 379609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * The display created with this method will have a static {@link DisplayAdjustments} applied. 380fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Applications should use {@link android.view.WindowManager#getDefaultDisplay()} 38198365d7663cbd82979a5700faf0050220b01084dJeff Brown * or {@link android.hardware.display.DisplayManager#getDisplay} 38298365d7663cbd82979a5700faf0050220b01084dJeff Brown * to get a display object. 383fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 384fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @hide 3859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 386609bf65668181d93502a57575f6f20281f2494b8Bryce Lee public Display(DisplayManagerGlobal global, int displayId, /*@NotNull*/ DisplayInfo displayInfo, 38748d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner DisplayAdjustments daj) { 388609bf65668181d93502a57575f6f20281f2494b8Bryce Lee this(global, displayId, displayInfo, daj, null /*res*/); 389609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 390609bf65668181d93502a57575f6f20281f2494b8Bryce Lee 391609bf65668181d93502a57575f6f20281f2494b8Bryce Lee /** 392609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * Internal method to create a display. 393609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * The display created with this method will be adjusted based on the adjustments in the 394609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * supplied {@link Resources}. 395609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * 396609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * @hide 397609bf65668181d93502a57575f6f20281f2494b8Bryce Lee */ 398609bf65668181d93502a57575f6f20281f2494b8Bryce Lee public Display(DisplayManagerGlobal global, int displayId, /*@NotNull*/ DisplayInfo displayInfo, 399609bf65668181d93502a57575f6f20281f2494b8Bryce Lee Resources res) { 400609bf65668181d93502a57575f6f20281f2494b8Bryce Lee this(global, displayId, displayInfo, null /*daj*/, res); 401609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 402609bf65668181d93502a57575f6f20281f2494b8Bryce Lee 403609bf65668181d93502a57575f6f20281f2494b8Bryce Lee private Display(DisplayManagerGlobal global, int displayId, 404609bf65668181d93502a57575f6f20281f2494b8Bryce Lee /*@NotNull*/ DisplayInfo displayInfo, DisplayAdjustments daj, Resources res) { 405bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mGlobal = global; 406fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mDisplayId = displayId; 407bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mDisplayInfo = displayInfo; 408609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mResources = res; 409609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayAdjustments = mResources != null 410609bf65668181d93502a57575f6f20281f2494b8Bryce Lee ? new DisplayAdjustments(mResources.getConfiguration()) 411609bf65668181d93502a57575f6f20281f2494b8Bryce Lee : daj != null ? new DisplayAdjustments(daj) : null; 412bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mIsValid = true; 41392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 41492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown // Cache properties that cannot change as long as the display is valid. 41592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mLayerStack = displayInfo.layerStack; 41692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mFlags = displayInfo.flags; 41792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mType = displayInfo.type; 41892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mAddress = displayInfo.address; 419a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown mOwnerUid = displayInfo.ownerUid; 420a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown mOwnerPackageName = displayInfo.ownerPackageName; 4215fd2169eabd77e6bfafaf456e58051a3bafb2bcaDianne Hackborn } 4225fd2169eabd77e6bfafaf456e58051a3bafb2bcaDianne Hackborn 4239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 424fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the display id. 425fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 426fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Each logical display has a unique id. 427fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The default display has id {@link #DEFAULT_DISPLAY}. 428fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 4299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int getDisplayId() { 431fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mDisplayId; 4329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 435bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * Returns true if this display is still valid, false if the display has been removed. 436bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * 437bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * If the display is invalid, then the methods of this class will 438bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * continue to report the most recently observed display information. 439bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * However, it is unwise (and rather fruitless) to continue using a 440bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * {@link Display} object after the display's demise. 441bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * 442bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * It's possible for a display that was previously invalid to become 443bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * valid again if a display with the same id is reconnected. 444bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * 445bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * @return True if the display is still valid. 446bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown */ 447bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown public boolean isValid() { 448bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown synchronized (this) { 449bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown updateDisplayInfoLocked(); 450bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown return mIsValid; 451bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 452bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 453bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown 454bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown /** 4552ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * Gets a full copy of the display information. 4562ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * 4572ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * @param outDisplayInfo The object to receive the copy of the display information. 458bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * @return True if the display is still valid. 4592ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * @hide 4602ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown */ 461bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown public boolean getDisplayInfo(DisplayInfo outDisplayInfo) { 4622ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown synchronized (this) { 4632ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown updateDisplayInfoLocked(); 4642ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown outDisplayInfo.copyFrom(mDisplayInfo); 465bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown return mIsValid; 4662ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown } 4672ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown } 4682ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown 4692ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown /** 47098365d7663cbd82979a5700faf0050220b01084dJeff Brown * Gets the display's layer stack. 47198365d7663cbd82979a5700faf0050220b01084dJeff Brown * 47298365d7663cbd82979a5700faf0050220b01084dJeff Brown * Each display has its own independent layer stack upon which surfaces 47398365d7663cbd82979a5700faf0050220b01084dJeff Brown * are placed to be managed by surface flinger. 47498365d7663cbd82979a5700faf0050220b01084dJeff Brown * 4754ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown * @return The display's layer stack number. 47698365d7663cbd82979a5700faf0050220b01084dJeff Brown * @hide 47798365d7663cbd82979a5700faf0050220b01084dJeff Brown */ 47898365d7663cbd82979a5700faf0050220b01084dJeff Brown public int getLayerStack() { 4794ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown return mLayerStack; 48098365d7663cbd82979a5700faf0050220b01084dJeff Brown } 48198365d7663cbd82979a5700faf0050220b01084dJeff Brown 48298365d7663cbd82979a5700faf0050220b01084dJeff Brown /** 483c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * Returns a combination of flags that describe the capabilities of the display. 484c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * 485c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * @return The display flags. 486c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * 48777aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * @see #FLAG_SUPPORTS_PROTECTED_BUFFERS 488f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * @see #FLAG_SECURE 489a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @see #FLAG_PRIVATE 490c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown */ 491c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown public int getFlags() { 49292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mFlags; 49392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 49492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 49592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 49692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Gets the display type. 49792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 49892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @return The display type. 49992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 50092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_UNKNOWN 50192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_BUILT_IN 50292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_HDMI 50392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_WIFI 50492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_OVERLAY 505a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @see #TYPE_VIRTUAL 50692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 50792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 50892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public int getType() { 50992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mType; 51092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 51192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 51292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 51392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Gets the display address, or null if none. 51492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Interpretation varies by display type. 51592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 51692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @return The display address. 51792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 51892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 51992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public String getAddress() { 52092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mAddress; 521c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown } 522c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown 523c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown /** 524a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Gets the UID of the application that owns this display, or zero if it is 525a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * owned by the system. 526a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * <p> 527a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * If the display is private, then only the owner can use it. 528a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * </p> 529a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * 530a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 531a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 532a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public int getOwnerUid() { 533a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return mOwnerUid; 534a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 535a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 536a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 537a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Gets the package name of the application that owns this display, or null if it is 538a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * owned by the system. 539a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * <p> 540a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * If the display is private, then only the owner can use it. 541a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * </p> 542a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * 543a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 544a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 545a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public String getOwnerPackageName() { 546a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return mOwnerPackageName; 547a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 548a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 549a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 55098365d7663cbd82979a5700faf0050220b01084dJeff Brown * Gets the compatibility info used by this display instance. 55198365d7663cbd82979a5700faf0050220b01084dJeff Brown * 55248d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner * @return The display adjustments holder, or null if none is required. 55398365d7663cbd82979a5700faf0050220b01084dJeff Brown * @hide 55498365d7663cbd82979a5700faf0050220b01084dJeff Brown */ 55548d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner public DisplayAdjustments getDisplayAdjustments() { 556609bf65668181d93502a57575f6f20281f2494b8Bryce Lee if (mResources != null) { 557609bf65668181d93502a57575f6f20281f2494b8Bryce Lee final DisplayAdjustments currentAdjustements = mResources.getDisplayAdjustments(); 558609bf65668181d93502a57575f6f20281f2494b8Bryce Lee if (!mDisplayAdjustments.equals(currentAdjustements)) { 559609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayAdjustments = new DisplayAdjustments(currentAdjustements); 560609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 561609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 562609bf65668181d93502a57575f6f20281f2494b8Bryce Lee 56348d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner return mDisplayAdjustments; 56498365d7663cbd82979a5700faf0050220b01084dJeff Brown } 56598365d7663cbd82979a5700faf0050220b01084dJeff Brown 56698365d7663cbd82979a5700faf0050220b01084dJeff Brown /** 5674ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown * Gets the name of the display. 56892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * <p> 56992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Note that some displays may be renamed by the user. 57092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * </p> 57192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 5724ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown * @return The display's name. 5734ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown */ 5744ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown public String getName() { 57592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown synchronized (this) { 57692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown updateDisplayInfoLocked(); 57792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mDisplayInfo.name; 57892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 5794ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown } 5804ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown 5814ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown /** 582bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * Gets the size of the display, in pixels. 5835f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * Value returned by this method does not necessarily represent the actual raw size 5845f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * (native resolution) of the display. 585bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * <p> 5865f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * 1. The returned size may be adjusted to exclude certain system decor elements 5875f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * that are always visible. 588bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p><p> 5895f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * 2. It may be scaled to provide compatibility with older applications that 590bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * were originally designed for smaller displays. 5915f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5925f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * 3. It can be different depending on the WindowManager to which the display belongs. 5935f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5945f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * - If requested from non-Activity context (e.g. Application context via 5955f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)}) 5965f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * it will report the size of the entire display based on current rotation and with subtracted 5975f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * system decoration areas. 5985f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5995f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * - If requested from activity (either using {@code getWindowManager()} or 6005f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * {@code (WindowManager) getSystemService(Context.WINDOW_SERVICE)}) resulting size will 6015f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * correspond to current app window size. In this case it can be smaller than physical size in 6025f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * multi-window mode. 6035f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 6045f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * Typically for the purposes of layout apps should make a request from activity context 6055f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * to obtain size available for the app content. 606bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p> 607bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * 608bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @param outSize A {@link Point} object to receive the size information. 6099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 610ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public void getSize(Point outSize) { 611fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 612fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 613609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 614fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.x = mTempMetrics.widthPixels; 615fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.y = mTempMetrics.heightPixels; 616ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 617ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 618fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 6199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 620bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * Gets the size of the display as a rectangle, in pixels. 621bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * 622bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @param outSize A {@link Rect} object to receive the size information. 623bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @see #getSize(Point) 6249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 625ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public void getRectSize(Rect outSize) { 626fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 627fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 628609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 629fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.set(0, 0, mTempMetrics.widthPixels, mTempMetrics.heightPixels); 630ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 631ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 6329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 633ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn /** 63468c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * Return the range of display sizes an application can expect to encounter 63568c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * under normal operation, as long as there is no physical change in screen 63668c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * size. This is basically the sizes you will see as the orientation 63768c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * changes, taking into account whatever screen decoration there is in 63868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * each rotation. For example, the status bar is always at the top of the 63968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * screen, so it will reduce the height both in landscape and portrait, and 64068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * the smallest height returned here will be the smaller of the two. 64168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * 64268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * This is intended for applications to get an idea of the range of sizes 64368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * they will encounter while going through device rotations, to provide a 64468c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * stable UI through rotation. The sizes here take into account all standard 64568c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * system decorations that reduce the size actually available to the 64668c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * application: the status bar, navigation bar, system bar, etc. It does 64768c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * <em>not</em> take into account more transient elements like an IME 64868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * soft keyboard. 64968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * 65068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * @param outSmallestSize Filled in with the smallest width and height 65168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * that the application will encounter, in pixels (not dp units). The x 65268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * (width) dimension here directly corresponds to 65368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * {@link android.content.res.Configuration#smallestScreenWidthDp 65468c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * Configuration.smallestScreenWidthDp}, except the value here is in raw 65568c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * screen pixels rather than dp units. Your application may of course 65668c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * still get smaller space yet if, for example, a soft keyboard is 65768c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * being displayed. 65868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * @param outLargestSize Filled in with the largest width and height 65968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * that the application will encounter, in pixels (not dp units). Your 66068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * application may of course still get larger space than this if, 66168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * for example, screen decorations like the status bar are being hidden. 66268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn */ 66368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn public void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize) { 664fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 665fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 666fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSmallestSize.x = mDisplayInfo.smallestNominalAppWidth; 667fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSmallestSize.y = mDisplayInfo.smallestNominalAppHeight; 668fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outLargestSize.x = mDisplayInfo.largestNominalAppWidth; 669fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outLargestSize.y = mDisplayInfo.largestNominalAppHeight; 67068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn } 67168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn } 67268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn 67368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn /** 674ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * Return the maximum screen size dimension that will happen. This is 675ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * mostly for wallpapers. 676ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * @hide 677ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn */ 678ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public int getMaximumSizeDimension() { 679fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 680fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 681fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return Math.max(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); 682ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 683ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 684ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn 685ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn /** 686ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * @deprecated Use {@link #getSize(Point)} instead. 687ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn */ 688ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn @Deprecated 689ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public int getWidth() { 690fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 691fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateCachedAppSizeIfNeededLocked(); 692fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mCachedAppWidthCompat; 693ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 694ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 695ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn 696ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn /** 697ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * @deprecated Use {@link #getSize(Point)} instead. 698ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn */ 699ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn @Deprecated 700ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public int getHeight() { 701fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 702fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateCachedAppSizeIfNeededLocked(); 703fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mCachedAppHeightCompat; 704bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 705bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 706ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn 707bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown /** 708c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * @hide 709c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * Return a rectangle defining the insets of the overscan region of the display. 710c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * Each field of the rectangle is the number of pixels the overscan area extends 711c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * into the display on that side. 712c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn */ 713c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn public void getOverscanInsets(Rect outRect) { 714c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn synchronized (this) { 715c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn updateDisplayInfoLocked(); 716c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn outRect.set(mDisplayInfo.overscanLeft, mDisplayInfo.overscanTop, 717c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn mDisplayInfo.overscanRight, mDisplayInfo.overscanBottom); 718c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn } 719c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn } 720c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn 721c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn /** 7225cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * Returns the rotation of the screen from its "natural" orientation. 7235cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * The returned value may be {@link Surface#ROTATION_0 Surface.ROTATION_0} 7245cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * (no rotation), {@link Surface#ROTATION_90 Surface.ROTATION_90}, 7255cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * {@link Surface#ROTATION_180 Surface.ROTATION_180}, or 7265cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * {@link Surface#ROTATION_270 Surface.ROTATION_270}. For 7275cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * example, if a device has a naturally tall screen, and the user has 7285cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * turned it on its side to go into a landscape orientation, the value 7295cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * returned here may be either {@link Surface#ROTATION_90 Surface.ROTATION_90} 7305cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * or {@link Surface#ROTATION_270 Surface.ROTATION_270} depending on 7315cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * the direction it was turned. The angle is the rotation of the drawn 7325cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * graphics on the screen, which is the opposite direction of the physical 7335cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * rotation of the device. For example, if the device is rotated 90 7345cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * degrees counter-clockwise, to compensate rendering will be rotated by 7355cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * 90 degrees clockwise and thus the returned value here will be 7365cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * {@link Surface#ROTATION_90 Surface.ROTATION_90}. 7375cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn */ 738d9273d6f289d9b55da3fd0db2f659fdfb48106a8Tor Norbye @Surface.Rotation 7395cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn public int getRotation() { 740fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 741fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 742fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mDisplayInfo.rotation; 743fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 7445cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn } 745fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 7465cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn /** 7474c904a3bf3dbe98607b5e3f706ee8ef8887ee104Joe Onorato * @deprecated use {@link #getRotation} 7489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return orientation of this display. 7499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 750fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown @Deprecated 751d9273d6f289d9b55da3fd0db2f659fdfb48106a8Tor Norbye @Surface.Rotation 752fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown public int getOrientation() { 753fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return getRotation(); 754fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 7559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 7569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 757fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the pixel format of the display. 758fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @return One of the constants defined in {@link android.graphics.PixelFormat}. 759fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 760fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @deprecated This method is no longer supported. 761fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The result is always {@link PixelFormat#RGBA_8888}. 7629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 763fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown @Deprecated 7649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int getPixelFormat() { 765fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return PixelFormat.RGBA_8888; 7669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 767fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 7689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 769fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the refresh rate of this display in frames per second. 7709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 7719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public float getRefreshRate() { 772fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 773fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 774b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mDisplayInfo.getMode().getRefreshRate(); 775fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 7769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 777fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 7789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 7793f145a2f958320766ae9240c7a57debc20d578aaMichael Wright * Get the supported refresh rates of this display in frames per second. 780b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 781b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * This method only returns refresh rates for the display's default modes. For more options, use 782b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * {@link #getSupportedModes()}. 783b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * 784b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @deprecated use {@link #getSupportedModes()} instead 7853f145a2f958320766ae9240c7a57debc20d578aaMichael Wright */ 786b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Deprecated 7873f145a2f958320766ae9240c7a57debc20d578aaMichael Wright public float[] getSupportedRefreshRates() { 7883f145a2f958320766ae9240c7a57debc20d578aaMichael Wright synchronized (this) { 7893f145a2f958320766ae9240c7a57debc20d578aaMichael Wright updateDisplayInfoLocked(); 790b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mDisplayInfo.getDefaultRefreshRates(); 791b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 792b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 793b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 794b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 795b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the active mode of the display. 796b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 797b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode getMode() { 798b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand synchronized (this) { 799b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand updateDisplayInfoLocked(); 800b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mDisplayInfo.getMode(); 801b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 802b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 803b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 804b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 805b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Gets the supported modes of this display. 806b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 807b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode[] getSupportedModes() { 808b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand synchronized (this) { 809b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand updateDisplayInfoLocked(); 810b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand final Display.Mode[] modes = mDisplayInfo.supportedModes; 811b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return Arrays.copyOf(modes, modes.length); 8123f145a2f958320766ae9240c7a57debc20d578aaMichael Wright } 8133f145a2f958320766ae9240c7a57debc20d578aaMichael Wright } 8143f145a2f958320766ae9240c7a57debc20d578aaMichael Wright 8153f145a2f958320766ae9240c7a57debc20d578aaMichael Wright /** 8161c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Request the display applies a color mode. 81758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright * @hide 81858e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright */ 8191c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright @RequiresPermission(CONFIGURE_DISPLAY_COLOR_MODE) 8201c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public void requestColorMode(int colorMode) { 8211c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright mGlobal.requestColorMode(mDisplayId, colorMode); 82258e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 82358e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 82458e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 8251c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Returns the active color mode of this display 82658e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright * @hide 82758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright */ 8281c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public int getColorMode() { 82958e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright synchronized (this) { 83058e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright updateDisplayInfoLocked(); 8311c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright return mDisplayInfo.colorMode; 83258e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 83358e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 83458e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 83558e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 836250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @hide 837250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * Get current remove mode of the display - what actions should be performed with the display's 838250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * content when it is removed. Default behavior for public displays in this case is to move all 839250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * activities to the primary display and make it focused. For private display - destroy all 840250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * activities. 841250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * 842250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @see #REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY 843250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @see #REMOVE_MODE_DESTROY_CONTENT 844250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian */ 845250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian public int getRemoveMode() { 846250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian return mDisplayInfo.removeMode; 847250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian } 848250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian 849250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian /** 850f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the display's HDR capabilities. 8516d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * 8526d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * @see #isHdr() 853f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 854f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities getHdrCapabilities() { 8559ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright synchronized (this) { 8569ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright updateDisplayInfoLocked(); 8579ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright return mDisplayInfo.hdrCapabilities; 8589ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright } 859f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 860f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 861f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 8626d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * Returns whether this display supports any HDR type. 8636d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * 8646d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * @see #getHdrCapabilities() 8656d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * @see HdrCapabilities#getSupportedHdrTypes() 8666d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy */ 8676d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public boolean isHdr() { 8686d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy synchronized (this) { 8696d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy updateDisplayInfoLocked(); 870408afbf06040ea29d1a9d60e9dc50d1923068de4Romain Guy return mDisplayInfo.isHdr(); 8716d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8726d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8736d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy 8746d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** 8756d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * Returns whether this display can be used to display wide color gamut content. 876e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guy * This does not necessarily mean the device itself can render wide color gamut 877e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guy * content. To ensure wide color gamut content can be produced, refer to 878e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guy * {@link Configuration#isScreenWideColorGamut()}. 8796d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy */ 8806d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public boolean isWideColorGamut() { 8816d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy synchronized (this) { 8826d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy updateDisplayInfoLocked(); 883408afbf06040ea29d1a9d60e9dc50d1923068de4Romain Guy return mDisplayInfo.isWideColorGamut(); 8846d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8856d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8866d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy 8876d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** 8881c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Gets the supported color modes of this device. 88958e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright * @hide 89058e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright */ 8911c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public int[] getSupportedColorModes() { 89258e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright synchronized (this) { 89358e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright updateDisplayInfoLocked(); 8941c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright int[] colorModes = mDisplayInfo.supportedColorModes; 8951c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright return Arrays.copyOf(colorModes, colorModes.length); 89658e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 89758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 89858e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 89958e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 900e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * Gets the app VSYNC offset, in nanoseconds. This is a positive value indicating 901e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * the phase offset of the VSYNC events provided by Choreographer relative to the 902e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * display refresh. For example, if Choreographer reports that the refresh occurred 903e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * at time N, it actually occurred at (N - appVsyncOffset). 904e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * <p> 905e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * Apps generally do not need to be aware of this. It's only useful for fine-grained 906e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * A/V synchronization. 907e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden */ 908e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden public long getAppVsyncOffsetNanos() { 909e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden synchronized (this) { 910e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden updateDisplayInfoLocked(); 911e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden return mDisplayInfo.appVsyncOffsetNanos; 912e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 913e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 914e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden 915e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden /** 916e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * This is how far in advance a buffer must be queued for presentation at 917e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * a given time. If you want a buffer to appear on the screen at 918e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * time N, you must submit the buffer before (N - presentationDeadline). 919e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * <p> 920e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * The desired presentation time for GLES rendering may be set with 921e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * {@link android.opengl.EGLExt#eglPresentationTimeANDROID}. For video decoding, use 922e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * {@link android.media.MediaCodec#releaseOutputBuffer(int, long)}. Times are 923e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * expressed in nanoseconds, using the system monotonic clock 924e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * ({@link System#nanoTime}). 925e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden */ 926e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden public long getPresentationDeadlineNanos() { 927e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden synchronized (this) { 928e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden updateDisplayInfoLocked(); 929e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden return mDisplayInfo.presentationDeadlineNanos; 930e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 931e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 932e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden 933e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden /** 934bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * Gets display metrics that describe the size and density of this display. 935a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * The size returned by this method does not necessarily represent the 936a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * actual raw size (native resolution) of the display. 937bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * <p> 938a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * 1. The returned size may be adjusted to exclude certain system decor elements 939a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * that are always visible. 940bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p><p> 941a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * 2. It may be scaled to provide compatibility with older applications that 942bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * were originally designed for smaller displays. 943a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * </p><p> 944a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * 3. It can be different depending on the WindowManager to which the display belongs. 9455f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 946a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * - If requested from non-Activity context (e.g. Application context via 947a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)}) 9485f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * metrics will report the size of the entire display based on current rotation and with 9495f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * subtracted system decoration areas. 9505f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 9515f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * - If requested from activity (either using {@code getWindowManager()} or 9525f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * {@code (WindowManager) getSystemService(Context.WINDOW_SERVICE)}) resulting metrics will 9535f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * correspond to current app window metrics. In this case the size can be smaller than physical 9545f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * size in multi-window mode. 955bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p> 956bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * 957bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. 9589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 9599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void getMetrics(DisplayMetrics outMetrics) { 960fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 961fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 962609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(outMetrics, getDisplayAdjustments()); 96368066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn } 96468066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn } 96568066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn 96668066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn /** 967fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the real size of the display without subtracting any window decor or 968fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * applying any compatibility scale factors. 969fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 970fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The size is adjusted based on the current rotation of the display. 971fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p><p> 972fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The real size may be smaller than the physical size of the screen when the 973cd097993399f94aa663c5fad50e444b75e6ee5ddAndrii Kulian * window manager is emulating a smaller display (using adb shell wm size). 974fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 975fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 976fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @param outSize Set to the real size of the display. 97768066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn */ 978fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown public void getRealSize(Point outSize) { 979fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 980fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 981fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.x = mDisplayInfo.logicalWidth; 982fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.y = mDisplayInfo.logicalHeight; 983bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 984bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 985bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown 986bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown /** 987fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets display metrics based on the real size of this display. 988fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 989fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The size is adjusted based on the current rotation of the display. 990fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p><p> 991fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The real size may be smaller than the physical size of the screen when the 992a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * window manager is emulating a smaller display (using adb shell wm size). 993fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 994fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 995fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. 99693de746e5554bc9397ca8109f57875d92e64eabcJeff Brown */ 997fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown public void getRealMetrics(DisplayMetrics outMetrics) { 998fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 999fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 100048d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner mDisplayInfo.getLogicalMetrics(outMetrics, 1001a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null); 1002fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 100393de746e5554bc9397ca8109f57875d92e64eabcJeff Brown } 100493de746e5554bc9397ca8109f57875d92e64eabcJeff Brown 1005a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 1006037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Gets the state of the display, such as whether it is on or off. 1007037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 1008037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @return The state of the display: one of {@link #STATE_OFF}, {@link #STATE_ON}, 100910a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * {@link #STATE_DOZE}, {@link #STATE_DOZE_SUSPEND}, {@link #STATE_ON_SUSPEND}, or 10103107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * {@link #STATE_UNKNOWN}. 1011037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 1012037c33eae74bee2774897d969d48947f9abe254fJeff Brown public int getState() { 1013037c33eae74bee2774897d969d48947f9abe254fJeff Brown synchronized (this) { 1014037c33eae74bee2774897d969d48947f9abe254fJeff Brown updateDisplayInfoLocked(); 1015037c33eae74bee2774897d969d48947f9abe254fJeff Brown return mIsValid ? mDisplayInfo.state : STATE_UNKNOWN; 1016037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1017037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1018037c33eae74bee2774897d969d48947f9abe254fJeff Brown 1019037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 1020a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Returns true if the specified UID has access to this display. 1021a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 1022a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 1023a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public boolean hasAccess(int uid) { 1024a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return Display.hasAccess(uid, mFlags, mOwnerUid); 1025a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 1026a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 1027a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** @hide */ 1028a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public static boolean hasAccess(int uid, int flags, int ownerUid) { 1029a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return (flags & Display.FLAG_PRIVATE) == 0 1030a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown || uid == ownerUid 1031a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown || uid == Process.SYSTEM_UID 1032a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown || uid == 0; 1033a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 1034a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 103569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown /** 103669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Returns true if the display is a public presentation display. 103769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * @hide 103869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown */ 103969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public boolean isPublicPresentation() { 104069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return (mFlags & (Display.FLAG_PRIVATE | Display.FLAG_PRESENTATION)) == 104169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown Display.FLAG_PRESENTATION; 104269b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 104369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 1044fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private void updateDisplayInfoLocked() { 1045bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown // Note: The display manager caches display info objects on our behalf. 1046bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId); 1047bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (newInfo == null) { 1048bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown // Preserve the old mDisplayInfo after the display is removed. 1049bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (mIsValid) { 1050bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mIsValid = false; 1051bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (DEBUG) { 1052bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown Log.d(TAG, "Logical display " + mDisplayId + " was removed."); 1053bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1054bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1055bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } else { 1056bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown // Use the new display info. (It might be the same object if nothing changed.) 1057bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mDisplayInfo = newInfo; 1058bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (!mIsValid) { 1059bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mIsValid = true; 1060bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (DEBUG) { 1061bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown Log.d(TAG, "Logical display " + mDisplayId + " was recreated."); 1062bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1063bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1064fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 10659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 10669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1067fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private void updateCachedAppSizeIfNeededLocked() { 1068fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown long now = SystemClock.uptimeMillis(); 1069fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown if (now > mLastCachedAppSizeUpdate + CACHED_APP_SIZE_DURATION_MILLIS) { 1070fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 1071609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 1072fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mCachedAppWidthCompat = mTempMetrics.widthPixels; 1073fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mCachedAppHeightCompat = mTempMetrics.heightPixels; 1074fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mLastCachedAppSizeUpdate = now; 1075fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 1076ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 1077bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown 1078bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown // For debugging purposes 1079bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown @Override 1080bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown public String toString() { 1081bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown synchronized (this) { 1082bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown updateDisplayInfoLocked(); 1083609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 1084bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown return "Display id " + mDisplayId + ": " + mDisplayInfo 1085bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown + ", " + mTempMetrics + ", isValid=" + mIsValid; 1086bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown } 1087bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown } 108892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 108992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 109092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 109192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 109292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static String typeToString(int type) { 109392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown switch (type) { 109492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_UNKNOWN: 109592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "UNKNOWN"; 109692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_BUILT_IN: 109792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "BUILT_IN"; 109892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_HDMI: 109992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "HDMI"; 110092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_WIFI: 110192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "WIFI"; 110292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_OVERLAY: 110392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "OVERLAY"; 1104a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown case TYPE_VIRTUAL: 1105a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return "VIRTUAL"; 110692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown default: 110792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return Integer.toString(type); 110892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 110992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 11109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1111037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 1112037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @hide 1113037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 1114037c33eae74bee2774897d969d48947f9abe254fJeff Brown public static String stateToString(int state) { 1115037c33eae74bee2774897d969d48947f9abe254fJeff Brown switch (state) { 1116037c33eae74bee2774897d969d48947f9abe254fJeff Brown case STATE_UNKNOWN: 1117037c33eae74bee2774897d969d48947f9abe254fJeff Brown return "UNKNOWN"; 1118037c33eae74bee2774897d969d48947f9abe254fJeff Brown case STATE_OFF: 1119037c33eae74bee2774897d969d48947f9abe254fJeff Brown return "OFF"; 1120037c33eae74bee2774897d969d48947f9abe254fJeff Brown case STATE_ON: 1121037c33eae74bee2774897d969d48947f9abe254fJeff Brown return "ON"; 11225dc219142a756d57355b511c8f8ab913c01710daJeff Brown case STATE_DOZE: 11235dc219142a756d57355b511c8f8ab913c01710daJeff Brown return "DOZE"; 11245dc219142a756d57355b511c8f8ab913c01710daJeff Brown case STATE_DOZE_SUSPEND: 11255dc219142a756d57355b511c8f8ab913c01710daJeff Brown return "DOZE_SUSPEND"; 11263107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon case STATE_VR: 11273107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon return "VR"; 112810a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix case STATE_ON_SUSPEND: 112910a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix return "ON_SUSPEND"; 1130037c33eae74bee2774897d969d48947f9abe254fJeff Brown default: 1131037c33eae74bee2774897d969d48947f9abe254fJeff Brown return Integer.toString(state); 1132037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1133037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1134970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown 1135970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown /** 1136970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown * Returns true if display updates may be suspended while in the specified 113710a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix * display power state. In SUSPEND states, updates are absolutely forbidden. 1138970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown * @hide 1139970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown */ 1140970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown public static boolean isSuspendedState(int state) { 114110a4a64bcc046ca0429069ad6dc2d20b65279bc6Chris Phoenix return state == STATE_OFF || state == STATE_DOZE_SUSPEND || state == STATE_ON_SUSPEND; 1142970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown } 1143b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1144b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 114505e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright * Returns true if the display may be in a reduced operating mode while in the 114605e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright * specified display power state. 114705e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright * @hide 114805e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright */ 114905e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright public static boolean isDozeState(int state) { 115005e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright return state == STATE_DOZE || state == STATE_DOZE_SUSPEND; 115105e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright } 115205e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright 115305e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright /** 1154b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * A mode supported by a given display. 1155b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * 1156b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @see Display#getSupportedModes() 1157b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1158b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public static final class Mode implements Parcelable { 1159b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1160b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @hide 1161b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1162b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public static final Mode[] EMPTY_ARRAY = new Mode[0]; 1163b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1164b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final int mModeId; 1165b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final int mWidth; 1166b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final int mHeight; 1167b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final float mRefreshRate; 1168b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1169b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1170b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @hide 1171b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1172b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode(int modeId, int width, int height, float refreshRate) { 1173b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mModeId = modeId; 1174b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mWidth = width; 1175b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mHeight = height; 1176b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mRefreshRate = refreshRate; 1177b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1178b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1179b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1180b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns this mode's id. 1181b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1182b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int getModeId() { 1183b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mModeId; 1184b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1185b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1186b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1187b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the physical width of the display in pixels when configured in this mode's 1188b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * resolution. 1189b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1190b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Note that due to application UI scaling, the number of pixels made available to 1191b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * applications when the mode is active (as reported by {@link Display#getWidth()} may 1192b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * differ from the mode's actual resolution (as reported by this function). 1193b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1194b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * For example, applications running on a 4K display may have their UI laid out and rendered 1195b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * in 1080p and then scaled up. Applications can take advantage of the extra resolution by 1196b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * rendering content through a {@link android.view.SurfaceView} using full size buffers. 1197b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1198b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int getPhysicalWidth() { 1199b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mWidth; 1200b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1201b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1202b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1203b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the physical height of the display in pixels when configured in this mode's 1204b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * resolution. 1205b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1206b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Note that due to application UI scaling, the number of pixels made available to 1207b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * applications when the mode is active (as reported by {@link Display#getHeight()} may 1208b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * differ from the mode's actual resolution (as reported by this function). 1209b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1210b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * For example, applications running on a 4K display may have their UI laid out and rendered 1211b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * in 1080p and then scaled up. Applications can take advantage of the extra resolution by 1212b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * rendering content through a {@link android.view.SurfaceView} using full size buffers. 1213b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1214b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int getPhysicalHeight() { 1215b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mHeight; 1216b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1217b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1218b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1219b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the refresh rate in frames per second. 1220b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1221b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public float getRefreshRate() { 1222b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mRefreshRate; 1223b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1224b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1225b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1226b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns {@code true} if this mode matches the given parameters. 1227b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * 1228b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @hide 1229b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1230b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public boolean matches(int width, int height, float refreshRate) { 1231b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mWidth == width && 1232b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mHeight == height && 1233b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand Float.floatToIntBits(mRefreshRate) == Float.floatToIntBits(refreshRate); 1234b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1235b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1236b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1237b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public boolean equals(Object other) { 1238b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand if (this == other) { 1239b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return true; 1240b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1241b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand if (!(other instanceof Mode)) { 1242b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return false; 1243b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1244b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand Mode that = (Mode) other; 1245b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mModeId == that.mModeId && matches(that.mWidth, that.mHeight, that.mRefreshRate); 1246b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1247b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1248b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1249b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int hashCode() { 1250b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand int hash = 1; 1251b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + mModeId; 1252b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + mWidth; 1253b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + mHeight; 1254b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + Float.floatToIntBits(mRefreshRate); 1255b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return hash; 1256b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1257b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1258b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1259b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public String toString() { 1260b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return new StringBuilder("{") 1261b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append("id=").append(mModeId) 1262b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append(", width=").append(mWidth) 1263b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append(", height=").append(mHeight) 1264b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append(", fps=").append(mRefreshRate) 1265b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append("}") 1266b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .toString(); 1267b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1268b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1269b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1270b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int describeContents() { 1271b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return 0; 1272b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1273b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1274b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private Mode(Parcel in) { 1275b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand this(in.readInt(), in.readInt(), in.readInt(), in.readFloat()); 1276b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1277b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1278b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1279b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public void writeToParcel(Parcel out, int parcelableFlags) { 1280b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeInt(mModeId); 1281b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeInt(mWidth); 1282b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeInt(mHeight); 1283b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeFloat(mRefreshRate); 1284b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1285b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1286b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @SuppressWarnings("hiding") 1287b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public static final Parcelable.Creator<Mode> CREATOR 1288b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand = new Parcelable.Creator<Mode>() { 1289b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1290b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode createFromParcel(Parcel in) { 1291b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return new Mode(in); 1292b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1293b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1294b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1295b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode[] newArray(int size) { 1296b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return new Mode[size]; 1297b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1298b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand }; 1299b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 130058e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 130158e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 1302f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Encapsulates the HDR capabilities of a given display. 1303f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * For example, what HDR types it supports and details about the desired luminance data. 1304f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * <p>You can get an instance for a given {@link Display} object with 1305f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * {@link Display#getHdrCapabilities getHdrCapabilities()}. 1306f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1307f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final class HdrCapabilities implements Parcelable { 1308f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1309f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Invalid luminance value. 1310f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1311f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final float INVALID_LUMINANCE = -1; 1312f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1313f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Dolby Vision high dynamic range (HDR) display. 1314f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1315f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final int HDR_TYPE_DOLBY_VISION = 1; 1316f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1317f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * HDR10 display. 1318f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1319f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final int HDR_TYPE_HDR10 = 2; 1320f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1321f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Hybrid Log-Gamma HDR display. 1322f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1323f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final int HDR_TYPE_HLG = 3; 1324f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1325da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang /** @hide */ 1326ce8db9911494225fcd99711d7df85a130de5a6ceJeff Sharkey @IntDef(prefix = { "HDR_TYPE_" }, value = { 1327ce8db9911494225fcd99711d7df85a130de5a6ceJeff Sharkey HDR_TYPE_DOLBY_VISION, 1328ce8db9911494225fcd99711d7df85a130de5a6ceJeff Sharkey HDR_TYPE_HDR10, 1329ce8db9911494225fcd99711d7df85a130de5a6ceJeff Sharkey HDR_TYPE_HLG, 1330f173c323449840771312afe5cbec03a71281e6ffRonghua Wu }) 1331f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Retention(RetentionPolicy.SOURCE) 1332f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public @interface HdrType {} 1333f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1334f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private @HdrType int[] mSupportedHdrTypes = new int[0]; 1335f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private float mMaxLuminance = INVALID_LUMINANCE; 1336f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private float mMaxAverageLuminance = INVALID_LUMINANCE; 1337f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private float mMinLuminance = INVALID_LUMINANCE; 1338f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1339da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang /** 1340da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang * @hide 1341da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang */ 1342f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities() { 1343f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1344f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 13451e7d1aa6a6bdee2c92245b5bef5aaa7167b8a311Hangyu Kuang /** 13461e7d1aa6a6bdee2c92245b5bef5aaa7167b8a311Hangyu Kuang * @hide 13471e7d1aa6a6bdee2c92245b5bef5aaa7167b8a311Hangyu Kuang */ 134854ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang public HdrCapabilities(int[] supportedHdrTypes, float maxLuminance, 134954ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang float maxAverageLuminance, float minLuminance) { 135054ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mSupportedHdrTypes = supportedHdrTypes; 135154ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mMaxLuminance = maxLuminance; 135254ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mMaxAverageLuminance = maxAverageLuminance; 135354ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mMinLuminance = minLuminance; 135454ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang } 135554ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang 1356f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1357f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Gets the supported HDR types of this display. 1358f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns empty array if HDR is not supported by the display. 1359f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1360f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public @HdrType int[] getSupportedHdrTypes() { 1361f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mSupportedHdrTypes; 1362f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1363f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1364f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the desired content max luminance data in cd/m2 for this display. 1365f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1366f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public float getDesiredMaxLuminance() { 1367f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mMaxLuminance; 1368f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1369f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1370f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the desired content max frame-average luminance data in cd/m2 for this display. 1371f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1372f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public float getDesiredMaxAverageLuminance() { 1373f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mMaxAverageLuminance; 1374f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1375f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1376f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the desired content min luminance data in cd/m2 for this display. 1377f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1378f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public float getDesiredMinLuminance() { 1379f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mMinLuminance; 1380f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1381f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 138216ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright @Override 138316ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright public boolean equals(Object other) { 138416ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright if (this == other) { 138516ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return true; 138616ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 138716ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 138816ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright if (!(other instanceof HdrCapabilities)) { 138916ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return false; 139016ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 139116ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright HdrCapabilities that = (HdrCapabilities) other; 139216ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 139316ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return Arrays.equals(mSupportedHdrTypes, that.mSupportedHdrTypes) 139416ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright && mMaxLuminance == that.mMaxLuminance 139516ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright && mMaxAverageLuminance == that.mMaxAverageLuminance 139616ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright && mMinLuminance == that.mMinLuminance; 139716ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 139816ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 139916ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright @Override 140016ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright public int hashCode() { 140116ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright int hash = 23; 140216ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Arrays.hashCode(mSupportedHdrTypes); 140316ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Float.floatToIntBits(mMaxLuminance); 140416ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Float.floatToIntBits(mMaxAverageLuminance); 140516ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Float.floatToIntBits(mMinLuminance); 140616ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return hash; 140716ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 140816ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 1409f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final Creator<HdrCapabilities> CREATOR = new Creator<HdrCapabilities>() { 1410f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1411f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities createFromParcel(Parcel source) { 1412f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return new HdrCapabilities(source); 1413f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1414f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1415f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1416f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities[] newArray(int size) { 1417f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return new HdrCapabilities[size]; 1418f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1419f173c323449840771312afe5cbec03a71281e6ffRonghua Wu }; 1420f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1421f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private HdrCapabilities(Parcel source) { 1422f173c323449840771312afe5cbec03a71281e6ffRonghua Wu readFromParcel(source); 1423f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1424f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1425da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang /** 1426da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang * @hide 1427da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang */ 1428f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public void readFromParcel(Parcel source) { 1429f173c323449840771312afe5cbec03a71281e6ffRonghua Wu int types = source.readInt(); 1430f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mSupportedHdrTypes = new int[types]; 1431f173c323449840771312afe5cbec03a71281e6ffRonghua Wu for (int i = 0; i < types; ++i) { 1432f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mSupportedHdrTypes[i] = source.readInt(); 1433f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1434f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mMaxLuminance = source.readFloat(); 1435f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mMaxAverageLuminance = source.readFloat(); 1436f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mMinLuminance = source.readFloat(); 1437f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1438f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1439f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1440f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public void writeToParcel(Parcel dest, int flags) { 1441f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeInt(mSupportedHdrTypes.length); 1442f173c323449840771312afe5cbec03a71281e6ffRonghua Wu for (int i = 0; i < mSupportedHdrTypes.length; ++i) { 1443f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeInt(mSupportedHdrTypes[i]); 1444f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1445f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeFloat(mMaxLuminance); 1446f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeFloat(mMaxAverageLuminance); 1447f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeFloat(mMinLuminance); 1448f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1449f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1450f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1451f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public int describeContents() { 1452f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return 0; 1453f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1454f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1455037c33eae74bee2774897d969d48947f9abe254fJeff Brown} 1456