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; 2348d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautnerimport android.content.res.CompatibilityInfo; 24e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guyimport android.content.res.Configuration; 25609bf65668181d93502a57575f6f20281f2494b8Bryce Leeimport android.content.res.Resources; 26fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brownimport android.graphics.PixelFormat; 27ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackbornimport android.graphics.Point; 28ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackbornimport android.graphics.Rect; 29732a90a794bc8615788042e9073e2da0b8829808Andrii Kulianimport android.hardware.display.DisplayManager; 30bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brownimport android.hardware.display.DisplayManagerGlobal; 31b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligandimport android.os.Parcel; 32b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligandimport android.os.Parcelable; 33a506a6ec94863a35acca9feb165db76ddac3892cJeff Brownimport android.os.Process; 34ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackbornimport android.os.SystemClock; 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.util.DisplayMetrics; 36fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brownimport android.util.Log; 379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 38f173c323449840771312afe5cbec03a71281e6ffRonghua Wuimport java.lang.annotation.Retention; 39f173c323449840771312afe5cbec03a71281e6ffRonghua Wuimport java.lang.annotation.RetentionPolicy; 403f145a2f958320766ae9240c7a57debc20d578aaMichael Wrightimport java.util.Arrays; 413f145a2f958320766ae9240c7a57debc20d578aaMichael Wright 42bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown/** 43fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Provides information about the size and density of a logical display. 44fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 45fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The display area is described in two different ways. 46fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <ul> 47fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <li>The application display area specifies the part of the display that may contain 48fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * an application window, excluding the system decorations. The application display area may 49fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * be smaller than the real display area because the system subtracts the space needed 50fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * for decor elements such as the status bar. Use the following methods to query the 51fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * application display area: {@link #getSize}, {@link #getRectSize} and {@link #getMetrics}.</li> 52fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <li>The real display area specifies the part of the display that contains content 53fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * including the system decorations. Even so, the real display area may be smaller than the 54fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * physical size of the display if the window manager is emulating a smaller display 55cd097993399f94aa663c5fad50e444b75e6ee5ddAndrii Kulian * using (adb shell wm size). Use the following methods to query the 56fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li> 57fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </ul> 58fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p><p> 59fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * A logical display does not necessarily represent a particular physical display device 60fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * such as the built-in screen or an external monitor. The contents of a logical 61fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * display may be presented on one or more physical displays according to the devices 62fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * that are currently attached and whether mirroring has been enabled. 63fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 64bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown */ 65fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brownpublic final class Display { 66fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private static final String TAG = "Display"; 67bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private static final boolean DEBUG = false; 68fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 69bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private final DisplayManagerGlobal mGlobal; 70fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private final int mDisplayId; 714ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown private final int mLayerStack; 7292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown private final int mFlags; 7392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown private final int mType; 7492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown private final String mAddress; 75a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown private final int mOwnerUid; 76a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown private final String mOwnerPackageName; 77609bf65668181d93502a57575f6f20281f2494b8Bryce Lee private final Resources mResources; 78609bf65668181d93502a57575f6f20281f2494b8Bryce Lee private DisplayAdjustments mDisplayAdjustments; 79bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown 80bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private DisplayInfo mDisplayInfo; // never null 81bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown private boolean mIsValid; 82fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 83fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // Temporary display metrics structure used for compatibility mode. 84fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private final DisplayMetrics mTempMetrics = new DisplayMetrics(); 85fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 86fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // We cache the app width and height properties briefly between calls 87fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // to getHeight() and getWidth() to ensure that applications perceive 88fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // consistent results when the size changes (most of the time). 89fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown // Applications should now be using getSize() instead. 90fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private static final int CACHED_APP_SIZE_DURATION_MILLIS = 20; 91fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private long mLastCachedAppSizeUpdate; 92fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private int mCachedAppWidthCompat; 93fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private int mCachedAppHeightCompat; 945fd2169eabd77e6bfafaf456e58051a3bafb2bcaDianne Hackborn 959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 9698365d7663cbd82979a5700faf0050220b01084dJeff Brown * The default Display id, which is the id of the built-in primary display 9798365d7663cbd82979a5700faf0050220b01084dJeff Brown * assuming there is one. 989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int DEFAULT_DISPLAY = 0; 1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 10226698514fbac587675221149aca98f3ea6414d55Wale Ogunwale * Invalid display id. 10326698514fbac587675221149aca98f3ea6414d55Wale Ogunwale */ 10426698514fbac587675221149aca98f3ea6414d55Wale Ogunwale public static final int INVALID_DISPLAY = -1; 10526698514fbac587675221149aca98f3ea6414d55Wale Ogunwale 10626698514fbac587675221149aca98f3ea6414d55Wale Ogunwale /** 10777aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * Display flag: Indicates that the display supports compositing content 10877aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * that is stored in protected graphics buffers. 109c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * <p> 110f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is set then the display device supports compositing protected buffers. 111f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 112f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is not set then the display device may not support compositing 113f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * protected buffers; the user may see a blank region on the screen instead of 114f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * the protected content. 115f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 11677aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * Secure (DRM) video decoders may allocate protected graphics buffers to request that 11777aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * a hardware-protected path be provided between the video decoder and the external 11877aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * display sink. If a hardware-protected path is not available, then content stored 11977aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * in protected graphics buffers may not be composited. 120c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * </p><p> 121f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * An application can use the absence of this flag as a hint that it should not use protected 122f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * buffers for this display because the content may not be visible. For example, 123f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * if the flag is not set then the application may choose not to show content on this 124f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * display, show an informative error message, select an alternate content stream 125f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * or adopt a different strategy for decoding content that does not rely on 126f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * protected buffers. 127c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * </p> 128f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * 129f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * @see #getFlags 130c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown */ 13177aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 0; 132c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown 133c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown /** 134f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * Display flag: Indicates that the display has a secure video output and 135f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * supports compositing secure surfaces. 136f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * <p> 137f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is set then the display device has a secure video output 138f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * and is capable of showing secure surfaces. It may also be capable of 139f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * showing {@link #FLAG_SUPPORTS_PROTECTED_BUFFERS protected buffers}. 140f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 141f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * If this flag is not set then the display device may not have a secure video 142f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * output; the user may see a blank region on the screen instead of 143f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * the contents of secure surfaces or protected buffers. 144f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 145f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * Secure surfaces are used to prevent content rendered into those surfaces 146f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * by applications from appearing in screenshots or from being viewed 147f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * on non-secure displays. Protected buffers are used by secure video decoders 148f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * for a similar purpose. 149f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 150f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * An application creates a window with a secure surface by specifying the 151f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * {@link WindowManager.LayoutParams#FLAG_SECURE} window flag. 152f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * Likewise, an application creates a {@link SurfaceView} with a secure surface 153f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * by calling {@link SurfaceView#setSecure} before attaching the secure view to 154f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * its containing window. 155f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p><p> 156f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * An application can use the absence of this flag as a hint that it should not create 157f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * secure surfaces or protected buffers on this display because the content may 158f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * not be visible. For example, if the flag is not set then the application may 159f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * choose not to show content on this display, show an informative error message, 160f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * select an alternate content stream or adopt a different strategy for decoding 161f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * content that does not rely on secure surfaces or protected buffers. 162f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * </p> 163f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * 164f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * @see #getFlags 165f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown */ 166f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown public static final int FLAG_SECURE = 1 << 1; 167f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown 168f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown /** 169a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Display flag: Indicates that the display is private. Only the application that 170fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * owns the display and apps that are already on the display can create windows on it. 1717d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * 1727d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * @see #getFlags 1737d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown */ 1747d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown public static final int FLAG_PRIVATE = 1 << 2; 1757d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown 1767d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown /** 1777d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * Display flag: Indicates that the display is a presentation display. 178a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * <p> 1797d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * This flag identifies secondary displays that are suitable for 1807d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * use as presentation displays such as HDMI or Wireless displays. Applications 1817d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * may automatically project their content to presentation displays to provide 1827d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown * richer second screen experiences. 183a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * </p> 184a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * 185a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @see #getFlags 186a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 1877d00affce6e25b22fd8fc135933b3bf6b547a0dcJeff Brown public static final int FLAG_PRESENTATION = 1 << 3; 188a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 189a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 19049e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * Display flag: Indicates that the display has a round shape. 19149e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * <p> 19249e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * This flag identifies displays that are circular, elliptical or otherwise 19349e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * do not permit the user to see all the way to the logical corners of the display. 19449e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * </p> 19549e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * 19649e7ff9647e6547c2b852944a5435a05794b9951Adam Powell * @see #getFlags 19749e7ff9647e6547c2b852944a5435a05794b9951Adam Powell */ 19849e7ff9647e6547c2b852944a5435a05794b9951Adam Powell public static final int FLAG_ROUND = 1 << 4; 19949e7ff9647e6547c2b852944a5435a05794b9951Adam Powell 20049e7ff9647e6547c2b852944a5435a05794b9951Adam Powell /** 201fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * Display flag: Indicates that the display can show its content when non-secure keyguard is 202fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * shown. 203fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * <p> 204732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * This flag identifies secondary displays that will continue showing content if keyguard can be 205732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * dismissed without entering credentials. 206732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * </p><p> 207732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * An example of usage is a virtual display which content is displayed on external hardware 208732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * display that is not visible to the system directly. 209fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * </p> 210fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * 211732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * @see DisplayManager#VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD 212732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * @see WindowManagerPolicy#isKeyguardSecure(int) 213732a90a794bc8615788042e9073e2da0b8829808Andrii Kulian * @see WindowManagerPolicy#isKeyguardTrustedLw() 214fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian * @see #getFlags 21522512e8a225cee9b53f9028734d1e9d79d27f67dAndrii Kulian * @hide 216fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian */ 2177211d2eba8e02b5e7462313798fc25c0bd36ab2dAndrii Kulian public static final int FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; 218fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian 219fc8f82bc6b587bddd2aeaddc54c1ea3f598bb9c3Andrii Kulian /** 220d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * Display flag: Indicates that the contents of the display should not be scaled 221d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * to fit the physical screen dimensions. Used for development only to emulate 222d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * devices with smaller physicals screens while preserving density. 223d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * 224d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown * @hide 225d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown */ 226d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown public static final int FLAG_SCALING_DISABLED = 1 << 30; 227d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown 228d46747a1c64b6ca3282e8841833980ab91829436Jeff Brown /** 22992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: Unknown display type. 23092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 23192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 23292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_UNKNOWN = 0; 23392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 23492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 23592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: Built-in display. 23692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 23792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 23892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_BUILT_IN = 1; 23992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 24092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 24192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: HDMI display. 24292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 24392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 24492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_HDMI = 2; 24592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 24692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 24792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: WiFi display. 24892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 24992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 25092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_WIFI = 3; 25192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 25292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 25392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Display type: Overlay display. 25492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 25592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 25692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static final int TYPE_OVERLAY = 4; 25792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 25892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 259a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Display type: Virtual display. 260a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 261a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 262a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public static final int TYPE_VIRTUAL = 5; 263a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 264a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 265037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Display state: The display state is unknown. 266037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 267037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 268037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 269037c33eae74bee2774897d969d48947f9abe254fJeff Brown public static final int STATE_UNKNOWN = 0; 270037c33eae74bee2774897d969d48947f9abe254fJeff Brown 271037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 272037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Display state: The display is off. 273037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 274037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 275037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 276037c33eae74bee2774897d969d48947f9abe254fJeff Brown public static final int STATE_OFF = 1; 277037c33eae74bee2774897d969d48947f9abe254fJeff Brown 278037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 279037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Display state: The display is on. 280037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 281037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 282037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 283037c33eae74bee2774897d969d48947f9abe254fJeff Brown public static final int STATE_ON = 2; 284037c33eae74bee2774897d969d48947f9abe254fJeff Brown 285037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 2865dc219142a756d57355b511c8f8ab913c01710daJeff Brown * Display state: The display is dozing in a low power state; it is still 2875dc219142a756d57355b511c8f8ab913c01710daJeff Brown * on but is optimized for showing system-provided content while the 2885dc219142a756d57355b511c8f8ab913c01710daJeff Brown * device is non-interactive. 289037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 290037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see #getState 291037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @see android.os.PowerManager#isInteractive 292037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 2935dc219142a756d57355b511c8f8ab913c01710daJeff Brown public static final int STATE_DOZE = 3; 2945dc219142a756d57355b511c8f8ab913c01710daJeff Brown 2955dc219142a756d57355b511c8f8ab913c01710daJeff Brown /** 2965dc219142a756d57355b511c8f8ab913c01710daJeff Brown * Display state: The display is dozing in a suspended low power state; it is still 2975dc219142a756d57355b511c8f8ab913c01710daJeff Brown * on but is optimized for showing static system-provided content while the device 2985dc219142a756d57355b511c8f8ab913c01710daJeff Brown * is non-interactive. This mode may be used to conserve even more power by allowing 2995dc219142a756d57355b511c8f8ab913c01710daJeff Brown * the hardware to stop applying frame buffer updates from the graphics subsystem or 3005dc219142a756d57355b511c8f8ab913c01710daJeff Brown * to take over the display and manage it autonomously to implement low power always-on 3015dc219142a756d57355b511c8f8ab913c01710daJeff Brown * display functionality. 3025dc219142a756d57355b511c8f8ab913c01710daJeff Brown * 3035dc219142a756d57355b511c8f8ab913c01710daJeff Brown * @see #getState 3045dc219142a756d57355b511c8f8ab913c01710daJeff Brown * @see android.os.PowerManager#isInteractive 3055dc219142a756d57355b511c8f8ab913c01710daJeff Brown */ 3065dc219142a756d57355b511c8f8ab913c01710daJeff Brown public static final int 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 */ 3143107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon public static final int STATE_VR = 5; 3153107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon 3161c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright /* The color mode constants defined below must be kept in sync with the ones in 3176d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * system/core/include/system/graphics-base.h */ 3181c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 3191c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright /** 3201c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Display color mode: The current color mode is unknown or invalid. 3211c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * @hide 3221c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright */ 3231c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public static final int COLOR_MODE_INVALID = -1; 3241c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 3251c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright /** 3261c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Display color mode: The default or native gamut of the display. 3271c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * @hide 3281c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright */ 3291c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public static final int COLOR_MODE_DEFAULT = 0; 3301c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 3316d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3326d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_625 = 1; 3336d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3346d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_625_UNADJUSTED = 2; 3356d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3366d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_525 = 3; 3376d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3386d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT601_525_UNADJUSTED = 4; 3396d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3406d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_BT709 = 5; 3416d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3426d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_DCI_P3 = 6; 3436d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3441c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public static final int COLOR_MODE_SRGB = 7; 3456d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3466d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_ADOBE_RGB = 8; 3476d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** @hide */ 3486d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public static final int COLOR_MODE_DISPLAY_P3 = 9; 3491c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright 350037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 351250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * Indicates that when display is removed, all its activities will be moved to the primary 352250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * display and the topmost activity should become focused. 353250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * 354250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @hide 355250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian */ 356250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian public static final int REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY = 0; 357250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian /** 358250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * Indicates that when display is removed, all its stacks and tasks will be removed, all 359250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * activities will be destroyed according to the usual lifecycle. 360250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * 361250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @hide 362250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian */ 363250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian public static final int REMOVE_MODE_DESTROY_CONTENT = 1; 364250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian 365250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian /** 366fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Internal method to create a display. 367609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * The display created with this method will have a static {@link DisplayAdjustments} applied. 368fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Applications should use {@link android.view.WindowManager#getDefaultDisplay()} 36998365d7663cbd82979a5700faf0050220b01084dJeff Brown * or {@link android.hardware.display.DisplayManager#getDisplay} 37098365d7663cbd82979a5700faf0050220b01084dJeff Brown * to get a display object. 371fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 372fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @hide 3739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 374609bf65668181d93502a57575f6f20281f2494b8Bryce Lee public Display(DisplayManagerGlobal global, int displayId, /*@NotNull*/ DisplayInfo displayInfo, 37548d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner DisplayAdjustments daj) { 376609bf65668181d93502a57575f6f20281f2494b8Bryce Lee this(global, displayId, displayInfo, daj, null /*res*/); 377609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 378609bf65668181d93502a57575f6f20281f2494b8Bryce Lee 379609bf65668181d93502a57575f6f20281f2494b8Bryce Lee /** 380609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * Internal method to create a display. 381609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * The display created with this method will be adjusted based on the adjustments in the 382609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * supplied {@link Resources}. 383609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * 384609bf65668181d93502a57575f6f20281f2494b8Bryce Lee * @hide 385609bf65668181d93502a57575f6f20281f2494b8Bryce Lee */ 386609bf65668181d93502a57575f6f20281f2494b8Bryce Lee public Display(DisplayManagerGlobal global, int displayId, /*@NotNull*/ DisplayInfo displayInfo, 387609bf65668181d93502a57575f6f20281f2494b8Bryce Lee Resources res) { 388609bf65668181d93502a57575f6f20281f2494b8Bryce Lee this(global, displayId, displayInfo, null /*daj*/, res); 389609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 390609bf65668181d93502a57575f6f20281f2494b8Bryce Lee 391609bf65668181d93502a57575f6f20281f2494b8Bryce Lee private Display(DisplayManagerGlobal global, int displayId, 392609bf65668181d93502a57575f6f20281f2494b8Bryce Lee /*@NotNull*/ DisplayInfo displayInfo, DisplayAdjustments daj, Resources res) { 393bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mGlobal = global; 394fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mDisplayId = displayId; 395bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mDisplayInfo = displayInfo; 396609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mResources = res; 397609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayAdjustments = mResources != null 398609bf65668181d93502a57575f6f20281f2494b8Bryce Lee ? new DisplayAdjustments(mResources.getConfiguration()) 399609bf65668181d93502a57575f6f20281f2494b8Bryce Lee : daj != null ? new DisplayAdjustments(daj) : null; 400bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mIsValid = true; 40192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 40292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown // Cache properties that cannot change as long as the display is valid. 40392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mLayerStack = displayInfo.layerStack; 40492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mFlags = displayInfo.flags; 40592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mType = displayInfo.type; 40692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown mAddress = displayInfo.address; 407a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown mOwnerUid = displayInfo.ownerUid; 408a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown mOwnerPackageName = displayInfo.ownerPackageName; 4095fd2169eabd77e6bfafaf456e58051a3bafb2bcaDianne Hackborn } 4105fd2169eabd77e6bfafaf456e58051a3bafb2bcaDianne Hackborn 4119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 412fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the display id. 413fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 414fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Each logical display has a unique id. 415fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The default display has id {@link #DEFAULT_DISPLAY}. 416fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 4179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int getDisplayId() { 419fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mDisplayId; 4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 423bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * Returns true if this display is still valid, false if the display has been removed. 424bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * 425bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * If the display is invalid, then the methods of this class will 426bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * continue to report the most recently observed display information. 427bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * However, it is unwise (and rather fruitless) to continue using a 428bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * {@link Display} object after the display's demise. 429bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * 430bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * It's possible for a display that was previously invalid to become 431bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * valid again if a display with the same id is reconnected. 432bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * 433bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * @return True if the display is still valid. 434bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown */ 435bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown public boolean isValid() { 436bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown synchronized (this) { 437bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown updateDisplayInfoLocked(); 438bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown return mIsValid; 439bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 440bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 441bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown 442bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown /** 4432ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * Gets a full copy of the display information. 4442ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * 4452ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * @param outDisplayInfo The object to receive the copy of the display information. 446bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown * @return True if the display is still valid. 4472ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown * @hide 4482ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown */ 449bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown public boolean getDisplayInfo(DisplayInfo outDisplayInfo) { 4502ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown synchronized (this) { 4512ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown updateDisplayInfoLocked(); 4522ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown outDisplayInfo.copyFrom(mDisplayInfo); 453bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown return mIsValid; 4542ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown } 4552ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown } 4562ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown 4572ab1b7d9abc1b720b63ae01abcf1df0dc780eed4Jeff Brown /** 45898365d7663cbd82979a5700faf0050220b01084dJeff Brown * Gets the display's layer stack. 45998365d7663cbd82979a5700faf0050220b01084dJeff Brown * 46098365d7663cbd82979a5700faf0050220b01084dJeff Brown * Each display has its own independent layer stack upon which surfaces 46198365d7663cbd82979a5700faf0050220b01084dJeff Brown * are placed to be managed by surface flinger. 46298365d7663cbd82979a5700faf0050220b01084dJeff Brown * 4634ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown * @return The display's layer stack number. 46498365d7663cbd82979a5700faf0050220b01084dJeff Brown * @hide 46598365d7663cbd82979a5700faf0050220b01084dJeff Brown */ 46698365d7663cbd82979a5700faf0050220b01084dJeff Brown public int getLayerStack() { 4674ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown return mLayerStack; 46898365d7663cbd82979a5700faf0050220b01084dJeff Brown } 46998365d7663cbd82979a5700faf0050220b01084dJeff Brown 47098365d7663cbd82979a5700faf0050220b01084dJeff Brown /** 471c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * Returns a combination of flags that describe the capabilities of the display. 472c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * 473c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * @return The display flags. 474c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown * 47577aebfdbae489c3712ae3f9bca29d01fb1f09dc2Jeff Brown * @see #FLAG_SUPPORTS_PROTECTED_BUFFERS 476f0681b34dffc1510cbd9c3da5c3a7e695553fa8dJeff Brown * @see #FLAG_SECURE 477a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @see #FLAG_PRIVATE 478c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown */ 479c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown public int getFlags() { 48092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mFlags; 48192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 48292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 48392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 48492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Gets the display type. 48592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 48692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @return The display type. 48792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 48892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_UNKNOWN 48992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_BUILT_IN 49092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_HDMI 49192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_WIFI 49292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @see #TYPE_OVERLAY 493a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @see #TYPE_VIRTUAL 49492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 49592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 49692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public int getType() { 49792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mType; 49892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 49992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 50092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 50192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Gets the display address, or null if none. 50292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Interpretation varies by display type. 50392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 50492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @return The display address. 50592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 50692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 50792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public String getAddress() { 50892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mAddress; 509c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown } 510c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown 511c5df37c285221d0fb113f55b9e78b35632241d3fJeff Brown /** 512a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Gets the UID of the application that owns this display, or zero if it is 513a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * owned by the system. 514a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * <p> 515a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * If the display is private, then only the owner can use it. 516a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * </p> 517a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * 518a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 519a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 520a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public int getOwnerUid() { 521a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return mOwnerUid; 522a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 523a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 524a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 525a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Gets the package name of the application that owns this display, or null if it is 526a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * owned by the system. 527a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * <p> 528a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * If the display is private, then only the owner can use it. 529a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * </p> 530a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * 531a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 532a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 533a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public String getOwnerPackageName() { 534a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return mOwnerPackageName; 535a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 536a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 537a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 53898365d7663cbd82979a5700faf0050220b01084dJeff Brown * Gets the compatibility info used by this display instance. 53998365d7663cbd82979a5700faf0050220b01084dJeff Brown * 54048d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner * @return The display adjustments holder, or null if none is required. 54198365d7663cbd82979a5700faf0050220b01084dJeff Brown * @hide 54298365d7663cbd82979a5700faf0050220b01084dJeff Brown */ 54348d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner public DisplayAdjustments getDisplayAdjustments() { 544609bf65668181d93502a57575f6f20281f2494b8Bryce Lee if (mResources != null) { 545609bf65668181d93502a57575f6f20281f2494b8Bryce Lee final DisplayAdjustments currentAdjustements = mResources.getDisplayAdjustments(); 546609bf65668181d93502a57575f6f20281f2494b8Bryce Lee if (!mDisplayAdjustments.equals(currentAdjustements)) { 547609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayAdjustments = new DisplayAdjustments(currentAdjustements); 548609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 549609bf65668181d93502a57575f6f20281f2494b8Bryce Lee } 550609bf65668181d93502a57575f6f20281f2494b8Bryce Lee 55148d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner return mDisplayAdjustments; 55298365d7663cbd82979a5700faf0050220b01084dJeff Brown } 55398365d7663cbd82979a5700faf0050220b01084dJeff Brown 55498365d7663cbd82979a5700faf0050220b01084dJeff Brown /** 5554ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown * Gets the name of the display. 55692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * <p> 55792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * Note that some displays may be renamed by the user. 55892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * </p> 55992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * 5604ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown * @return The display's name. 5614ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown */ 5624ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown public String getName() { 56392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown synchronized (this) { 56492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown updateDisplayInfoLocked(); 56592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return mDisplayInfo.name; 56692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 5674ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown } 5684ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown 5694ed8fe75e1dde1a2b9576f3862aecc5a572c56b5Jeff Brown /** 570bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * Gets the size of the display, in pixels. 5715f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * Value returned by this method does not necessarily represent the actual raw size 5725f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * (native resolution) of the display. 573bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * <p> 5745f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * 1. The returned size may be adjusted to exclude certain system decor elements 5755f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * that are always visible. 576bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p><p> 5775f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * 2. It may be scaled to provide compatibility with older applications that 578bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * were originally designed for smaller displays. 5795f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5805f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * 3. It can be different depending on the WindowManager to which the display belongs. 5815f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5825f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * - If requested from non-Activity context (e.g. Application context via 5835f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)}) 5845f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * it will report the size of the entire display based on current rotation and with subtracted 5855f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * system decoration areas. 5865f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5875f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * - If requested from activity (either using {@code getWindowManager()} or 5885f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * {@code (WindowManager) getSystemService(Context.WINDOW_SERVICE)}) resulting size will 5895f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * correspond to current app window size. In this case it can be smaller than physical size in 5905f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * multi-window mode. 5915f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 5925f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * Typically for the purposes of layout apps should make a request from activity context 5935f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * to obtain size available for the app content. 594bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p> 595bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * 596bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @param outSize A {@link Point} object to receive the size information. 5979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 598ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public void getSize(Point outSize) { 599fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 600fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 601609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 602fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.x = mTempMetrics.widthPixels; 603fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.y = mTempMetrics.heightPixels; 604ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 605ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 606fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 6079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 608bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * Gets the size of the display as a rectangle, in pixels. 609bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * 610bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @param outSize A {@link Rect} object to receive the size information. 611bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @see #getSize(Point) 6129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 613ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public void getRectSize(Rect outSize) { 614fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 615fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 616609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 617fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.set(0, 0, mTempMetrics.widthPixels, mTempMetrics.heightPixels); 618ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 619ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 6209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 621ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn /** 62268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * Return the range of display sizes an application can expect to encounter 62368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * under normal operation, as long as there is no physical change in screen 62468c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * size. This is basically the sizes you will see as the orientation 62568c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * changes, taking into account whatever screen decoration there is in 62668c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * each rotation. For example, the status bar is always at the top of the 62768c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * screen, so it will reduce the height both in landscape and portrait, and 62868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * the smallest height returned here will be the smaller of the two. 62968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * 63068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * This is intended for applications to get an idea of the range of sizes 63168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * they will encounter while going through device rotations, to provide a 63268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * stable UI through rotation. The sizes here take into account all standard 63368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * system decorations that reduce the size actually available to the 63468c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * application: the status bar, navigation bar, system bar, etc. It does 63568c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * <em>not</em> take into account more transient elements like an IME 63668c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * soft keyboard. 63768c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * 63868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * @param outSmallestSize Filled in with the smallest width and height 63968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * that the application will encounter, in pixels (not dp units). The x 64068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * (width) dimension here directly corresponds to 64168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * {@link android.content.res.Configuration#smallestScreenWidthDp 64268c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * Configuration.smallestScreenWidthDp}, except the value here is in raw 64368c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * screen pixels rather than dp units. Your application may of course 64468c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * still get smaller space yet if, for example, a soft keyboard is 64568c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * being displayed. 64668c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * @param outLargestSize Filled in with the largest width and height 64768c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * that the application will encounter, in pixels (not dp units). Your 64868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * application may of course still get larger space than this if, 64968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn * for example, screen decorations like the status bar are being hidden. 65068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn */ 65168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn public void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize) { 652fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 653fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 654fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSmallestSize.x = mDisplayInfo.smallestNominalAppWidth; 655fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSmallestSize.y = mDisplayInfo.smallestNominalAppHeight; 656fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outLargestSize.x = mDisplayInfo.largestNominalAppWidth; 657fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outLargestSize.y = mDisplayInfo.largestNominalAppHeight; 65868c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn } 65968c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn } 66068c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn 66168c33ca7ce1f142eb5f1e1f90118aeba4c9db1e3Dianne Hackborn /** 662ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * Return the maximum screen size dimension that will happen. This is 663ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * mostly for wallpapers. 664ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * @hide 665ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn */ 666ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public int getMaximumSizeDimension() { 667fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 668fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 669fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return Math.max(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); 670ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 671ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 672ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn 673ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn /** 674ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * @deprecated Use {@link #getSize(Point)} instead. 675ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn */ 676ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn @Deprecated 677ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public int getWidth() { 678fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 679fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateCachedAppSizeIfNeededLocked(); 680fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mCachedAppWidthCompat; 681ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 682ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 683ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn 684ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn /** 685ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn * @deprecated Use {@link #getSize(Point)} instead. 686ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn */ 687ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn @Deprecated 688ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn public int getHeight() { 689fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 690fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateCachedAppSizeIfNeededLocked(); 691fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mCachedAppHeightCompat; 692bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 693bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 694ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn 695bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown /** 696c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * @hide 697c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * Return a rectangle defining the insets of the overscan region of the display. 698c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * Each field of the rectangle is the number of pixels the overscan area extends 699c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn * into the display on that side. 700c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn */ 701c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn public void getOverscanInsets(Rect outRect) { 702c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn synchronized (this) { 703c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn updateDisplayInfoLocked(); 704c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn outRect.set(mDisplayInfo.overscanLeft, mDisplayInfo.overscanTop, 705c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn mDisplayInfo.overscanRight, mDisplayInfo.overscanBottom); 706c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn } 707c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn } 708c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn 709c652de8141f5b8e3c6bcf8916842b6e106413b1aDianne Hackborn /** 7105cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * Returns the rotation of the screen from its "natural" orientation. 7115cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * The returned value may be {@link Surface#ROTATION_0 Surface.ROTATION_0} 7125cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * (no rotation), {@link Surface#ROTATION_90 Surface.ROTATION_90}, 7135cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * {@link Surface#ROTATION_180 Surface.ROTATION_180}, or 7145cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * {@link Surface#ROTATION_270 Surface.ROTATION_270}. For 7155cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * example, if a device has a naturally tall screen, and the user has 7165cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * turned it on its side to go into a landscape orientation, the value 7175cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * returned here may be either {@link Surface#ROTATION_90 Surface.ROTATION_90} 7185cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * or {@link Surface#ROTATION_270 Surface.ROTATION_270} depending on 7195cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * the direction it was turned. The angle is the rotation of the drawn 7205cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * graphics on the screen, which is the opposite direction of the physical 7215cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * rotation of the device. For example, if the device is rotated 90 7225cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * degrees counter-clockwise, to compensate rendering will be rotated by 7235cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * 90 degrees clockwise and thus the returned value here will be 7245cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn * {@link Surface#ROTATION_90 Surface.ROTATION_90}. 7255cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn */ 726d9273d6f289d9b55da3fd0db2f659fdfb48106a8Tor Norbye @Surface.Rotation 7275cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn public int getRotation() { 728fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 729fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 730fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return mDisplayInfo.rotation; 731fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 7325cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn } 733fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 7345cb70b54156fb305d579a1cc167424c8705bfdf7Dianne Hackborn /** 7354c904a3bf3dbe98607b5e3f706ee8ef8887ee104Joe Onorato * @deprecated use {@link #getRotation} 7369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return orientation of this display. 7379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 738fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown @Deprecated 739d9273d6f289d9b55da3fd0db2f659fdfb48106a8Tor Norbye @Surface.Rotation 740fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown public int getOrientation() { 741fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return getRotation(); 742fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 7439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 7449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 745fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the pixel format of the display. 746fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @return One of the constants defined in {@link android.graphics.PixelFormat}. 747fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 748fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @deprecated This method is no longer supported. 749fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The result is always {@link PixelFormat#RGBA_8888}. 7509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 751fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown @Deprecated 7529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int getPixelFormat() { 753fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown return PixelFormat.RGBA_8888; 7549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 755fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 7569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 757fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the refresh rate of this display in frames per second. 7589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 7599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public float getRefreshRate() { 760fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 761fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 762b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mDisplayInfo.getMode().getRefreshRate(); 763fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 7649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 765fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown 7669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 7673f145a2f958320766ae9240c7a57debc20d578aaMichael Wright * Get the supported refresh rates of this display in frames per second. 768b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 769b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * This method only returns refresh rates for the display's default modes. For more options, use 770b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * {@link #getSupportedModes()}. 771b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * 772b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @deprecated use {@link #getSupportedModes()} instead 7733f145a2f958320766ae9240c7a57debc20d578aaMichael Wright */ 774b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Deprecated 7753f145a2f958320766ae9240c7a57debc20d578aaMichael Wright public float[] getSupportedRefreshRates() { 7763f145a2f958320766ae9240c7a57debc20d578aaMichael Wright synchronized (this) { 7773f145a2f958320766ae9240c7a57debc20d578aaMichael Wright updateDisplayInfoLocked(); 778b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mDisplayInfo.getDefaultRefreshRates(); 779b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 780b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 781b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 782b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 783b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the active mode of the display. 784b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 785b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode getMode() { 786b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand synchronized (this) { 787b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand updateDisplayInfoLocked(); 788b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mDisplayInfo.getMode(); 789b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 790b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 791b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 792b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 793b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Gets the supported modes of this display. 794b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 795b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode[] getSupportedModes() { 796b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand synchronized (this) { 797b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand updateDisplayInfoLocked(); 798b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand final Display.Mode[] modes = mDisplayInfo.supportedModes; 799b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return Arrays.copyOf(modes, modes.length); 8003f145a2f958320766ae9240c7a57debc20d578aaMichael Wright } 8013f145a2f958320766ae9240c7a57debc20d578aaMichael Wright } 8023f145a2f958320766ae9240c7a57debc20d578aaMichael Wright 8033f145a2f958320766ae9240c7a57debc20d578aaMichael Wright /** 8041c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Request the display applies a color mode. 80558e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright * @hide 80658e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright */ 8071c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright @RequiresPermission(CONFIGURE_DISPLAY_COLOR_MODE) 8081c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public void requestColorMode(int colorMode) { 8091c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright mGlobal.requestColorMode(mDisplayId, colorMode); 81058e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 81158e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 81258e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 8131c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Returns the active color mode of this display 81458e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright * @hide 81558e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright */ 8161c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public int getColorMode() { 81758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright synchronized (this) { 81858e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright updateDisplayInfoLocked(); 8191c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright return mDisplayInfo.colorMode; 82058e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 82158e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 82258e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 82358e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 824250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @hide 825250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * Get current remove mode of the display - what actions should be performed with the display's 826250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * content when it is removed. Default behavior for public displays in this case is to move all 827250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * activities to the primary display and make it focused. For private display - destroy all 828250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * activities. 829250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * 830250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @see #REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY 831250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian * @see #REMOVE_MODE_DESTROY_CONTENT 832250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian */ 833250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian public int getRemoveMode() { 834250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian return mDisplayInfo.removeMode; 835250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian } 836250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian 837250d653325ffeeb8ef75e51e3a3d08d6abb8cf9cAndrii Kulian /** 838f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the display's HDR capabilities. 8396d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * 8406d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * @see #isHdr() 841f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 842f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities getHdrCapabilities() { 8439ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright synchronized (this) { 8449ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright updateDisplayInfoLocked(); 8459ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright return mDisplayInfo.hdrCapabilities; 8469ff94c0251722c44eece7c3561b4ed36b286d4a8Michael Wright } 847f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 848f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 849f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 8506d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * Returns whether this display supports any HDR type. 8516d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * 8526d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * @see #getHdrCapabilities() 8536d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * @see HdrCapabilities#getSupportedHdrTypes() 8546d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy */ 8556d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public boolean isHdr() { 8566d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy synchronized (this) { 8576d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy updateDisplayInfoLocked(); 858408afbf06040ea29d1a9d60e9dc50d1923068de4Romain Guy return mDisplayInfo.isHdr(); 8596d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8606d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8616d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy 8626d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** 8636d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy * Returns whether this display can be used to display wide color gamut content. 864e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guy * This does not necessarily mean the device itself can render wide color gamut 865e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guy * content. To ensure wide color gamut content can be produced, refer to 866e89d0bba66d76fe4c0d316f065a3d0f96f375c75Romain Guy * {@link Configuration#isScreenWideColorGamut()}. 8676d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy */ 8686d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy public boolean isWideColorGamut() { 8696d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy synchronized (this) { 8706d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy updateDisplayInfoLocked(); 871408afbf06040ea29d1a9d60e9dc50d1923068de4Romain Guy return mDisplayInfo.isWideColorGamut(); 8726d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8736d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy } 8746d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy 8756d228c2589db75ef8ae6cd820d58a1c66f6ebe19Romain Guy /** 8761c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright * Gets the supported color modes of this device. 87758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright * @hide 87858e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright */ 8791c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright public int[] getSupportedColorModes() { 88058e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright synchronized (this) { 88158e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright updateDisplayInfoLocked(); 8821c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright int[] colorModes = mDisplayInfo.supportedColorModes; 8831c9977b762b4bac46b4470f04c898bfd17da5d90Michael Wright return Arrays.copyOf(colorModes, colorModes.length); 88458e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 88558e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright } 88658e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 88758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 888e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * Gets the app VSYNC offset, in nanoseconds. This is a positive value indicating 889e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * the phase offset of the VSYNC events provided by Choreographer relative to the 890e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * display refresh. For example, if Choreographer reports that the refresh occurred 891e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * at time N, it actually occurred at (N - appVsyncOffset). 892e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * <p> 893e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * Apps generally do not need to be aware of this. It's only useful for fine-grained 894e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * A/V synchronization. 895e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden */ 896e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden public long getAppVsyncOffsetNanos() { 897e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden synchronized (this) { 898e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden updateDisplayInfoLocked(); 899e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden return mDisplayInfo.appVsyncOffsetNanos; 900e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 901e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 902e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden 903e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden /** 904e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * This is how far in advance a buffer must be queued for presentation at 905e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * a given time. If you want a buffer to appear on the screen at 906e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * time N, you must submit the buffer before (N - presentationDeadline). 907e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * <p> 908e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * The desired presentation time for GLES rendering may be set with 909e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * {@link android.opengl.EGLExt#eglPresentationTimeANDROID}. For video decoding, use 910e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * {@link android.media.MediaCodec#releaseOutputBuffer(int, long)}. Times are 911e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * expressed in nanoseconds, using the system monotonic clock 912e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden * ({@link System#nanoTime}). 913e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden */ 914e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden public long getPresentationDeadlineNanos() { 915e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden synchronized (this) { 916e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden updateDisplayInfoLocked(); 917e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden return mDisplayInfo.presentationDeadlineNanos; 918e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 919e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden } 920e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden 921e8b1aeb51e1e5da64f1d4fd40f2ee1e815886fe5Andy McFadden /** 922bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * Gets display metrics that describe the size and density of this display. 923a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * The size returned by this method does not necessarily represent the 924a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * actual raw size (native resolution) of the display. 925bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * <p> 926a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * 1. The returned size may be adjusted to exclude certain system decor elements 927a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * that are always visible. 928bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p><p> 929a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * 2. It may be scaled to provide compatibility with older applications that 930bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * were originally designed for smaller displays. 931a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * </p><p> 932a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * 3. It can be different depending on the WindowManager to which the display belongs. 9335f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 934a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * - If requested from non-Activity context (e.g. Application context via 935a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)}) 9365f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * metrics will report the size of the entire display based on current rotation and with 9375f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * subtracted system decoration areas. 9385f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * </p><p> 9395f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * - If requested from activity (either using {@code getWindowManager()} or 9405f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * {@code (WindowManager) getSystemService(Context.WINDOW_SERVICE)}) resulting metrics will 9415f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * correspond to current app window metrics. In this case the size can be smaller than physical 9425f57a3d6d8a8ae97aa431386b76e35a70dbb9314Andrii Kulian * size in multi-window mode. 943bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * </p> 944bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * 945bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. 9469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 9479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void getMetrics(DisplayMetrics outMetrics) { 948fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 949fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 950609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(outMetrics, getDisplayAdjustments()); 95168066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn } 95268066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn } 95368066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn 95468066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn /** 955fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets the real size of the display without subtracting any window decor or 956fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * applying any compatibility scale factors. 957fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 958fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The size is adjusted based on the current rotation of the display. 959fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p><p> 960fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The real size may be smaller than the physical size of the screen when the 961cd097993399f94aa663c5fad50e444b75e6ee5ddAndrii Kulian * window manager is emulating a smaller display (using adb shell wm size). 962fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 963fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 964fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @param outSize Set to the real size of the display. 96568066c2f38e47b56f0510c56eafd827731a0dc08Dianne Hackborn */ 966fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown public void getRealSize(Point outSize) { 967fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 968fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 969fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.x = mDisplayInfo.logicalWidth; 970fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown outSize.y = mDisplayInfo.logicalHeight; 971bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 972bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown } 973bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown 974bc68a59c024bdb745dac8e2ec7408a9f30595f1aJeff Brown /** 975fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * Gets display metrics based on the real size of this display. 976fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * <p> 977fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The size is adjusted based on the current rotation of the display. 978fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p><p> 979fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * The real size may be smaller than the physical size of the screen when the 980a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian * window manager is emulating a smaller display (using adb shell wm size). 981fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * </p> 982fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * 983fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. 98493de746e5554bc9397ca8109f57875d92e64eabcJeff Brown */ 985fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown public void getRealMetrics(DisplayMetrics outMetrics) { 986fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown synchronized (this) { 987fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 98848d0d1886731ff19ed3fb47a5997be5df0d1bba8Craig Mautner mDisplayInfo.getLogicalMetrics(outMetrics, 989a4bb9d3f527663862bcc2abc1cd81489bfc6754eAndrii Kulian CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null); 990fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 99193de746e5554bc9397ca8109f57875d92e64eabcJeff Brown } 99293de746e5554bc9397ca8109f57875d92e64eabcJeff Brown 993a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** 994037c33eae74bee2774897d969d48947f9abe254fJeff Brown * Gets the state of the display, such as whether it is on or off. 995037c33eae74bee2774897d969d48947f9abe254fJeff Brown * 996037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @return The state of the display: one of {@link #STATE_OFF}, {@link #STATE_ON}, 9973107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * {@link #STATE_DOZE}, {@link #STATE_DOZE_SUSPEND}, or 9983107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon * {@link #STATE_UNKNOWN}. 999037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 1000037c33eae74bee2774897d969d48947f9abe254fJeff Brown public int getState() { 1001037c33eae74bee2774897d969d48947f9abe254fJeff Brown synchronized (this) { 1002037c33eae74bee2774897d969d48947f9abe254fJeff Brown updateDisplayInfoLocked(); 1003037c33eae74bee2774897d969d48947f9abe254fJeff Brown return mIsValid ? mDisplayInfo.state : STATE_UNKNOWN; 1004037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1005037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1006037c33eae74bee2774897d969d48947f9abe254fJeff Brown 1007037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 1008a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * Returns true if the specified UID has access to this display. 1009a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown * @hide 1010a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown */ 1011a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public boolean hasAccess(int uid) { 1012a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return Display.hasAccess(uid, mFlags, mOwnerUid); 1013a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 1014a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 1015a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown /** @hide */ 1016a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown public static boolean hasAccess(int uid, int flags, int ownerUid) { 1017a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return (flags & Display.FLAG_PRIVATE) == 0 1018a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown || uid == ownerUid 1019a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown || uid == Process.SYSTEM_UID 1020a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown || uid == 0; 1021a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown } 1022a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown 102369b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown /** 102469b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * Returns true if the display is a public presentation display. 102569b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown * @hide 102669b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown */ 102769b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown public boolean isPublicPresentation() { 102869b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown return (mFlags & (Display.FLAG_PRIVATE | Display.FLAG_PRESENTATION)) == 102969b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown Display.FLAG_PRESENTATION; 103069b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown } 103169b07161bebdb2c726e3a826c2268866f1a94517Jeff Brown 1032fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private void updateDisplayInfoLocked() { 1033bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown // Note: The display manager caches display info objects on our behalf. 1034bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId); 1035bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (newInfo == null) { 1036bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown // Preserve the old mDisplayInfo after the display is removed. 1037bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (mIsValid) { 1038bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mIsValid = false; 1039bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (DEBUG) { 1040bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown Log.d(TAG, "Logical display " + mDisplayId + " was removed."); 1041bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1042bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1043bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } else { 1044bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown // Use the new display info. (It might be the same object if nothing changed.) 1045bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mDisplayInfo = newInfo; 1046bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (!mIsValid) { 1047bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown mIsValid = true; 1048bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown if (DEBUG) { 1049bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown Log.d(TAG, "Logical display " + mDisplayId + " was recreated."); 1050bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1051bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown } 1052fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 10539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 10549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1055fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown private void updateCachedAppSizeIfNeededLocked() { 1056fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown long now = SystemClock.uptimeMillis(); 1057fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown if (now > mLastCachedAppSizeUpdate + CACHED_APP_SIZE_DURATION_MILLIS) { 1058fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown updateDisplayInfoLocked(); 1059609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 1060fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mCachedAppWidthCompat = mTempMetrics.widthPixels; 1061fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mCachedAppHeightCompat = mTempMetrics.heightPixels; 1062fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown mLastCachedAppSizeUpdate = now; 1063fa25bf5382467b1018bd9af7f1cb30a23d7d59f7Jeff Brown } 1064ac8dea12c17aa047e03a358110aeb60401d36aa2Dianne Hackborn } 1065bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown 1066bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown // For debugging purposes 1067bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown @Override 1068bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown public String toString() { 1069bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown synchronized (this) { 1070bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown updateDisplayInfoLocked(); 1071609bf65668181d93502a57575f6f20281f2494b8Bryce Lee mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments()); 1072bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown return "Display id " + mDisplayId + ": " + mDisplayInfo 1073bd6e1500aedc5461e832f69e76341bff0e55fa2bJeff Brown + ", " + mTempMetrics + ", isValid=" + mIsValid; 1074bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown } 1075bf5740e75efd87ae0213486e78e029403804c6f0Jeff Brown } 107692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown 107792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown /** 107892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown * @hide 107992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown */ 108092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown public static String typeToString(int type) { 108192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown switch (type) { 108292130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_UNKNOWN: 108392130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "UNKNOWN"; 108492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_BUILT_IN: 108592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "BUILT_IN"; 108692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_HDMI: 108792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "HDMI"; 108892130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_WIFI: 108992130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "WIFI"; 109092130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown case TYPE_OVERLAY: 109192130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return "OVERLAY"; 1092a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown case TYPE_VIRTUAL: 1093a506a6ec94863a35acca9feb165db76ddac3892cJeff Brown return "VIRTUAL"; 109492130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown default: 109592130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown return Integer.toString(type); 109692130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 109792130f6407dc51c58b3b941d28a6daf4e04b8d62Jeff Brown } 10989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1099037c33eae74bee2774897d969d48947f9abe254fJeff Brown /** 1100037c33eae74bee2774897d969d48947f9abe254fJeff Brown * @hide 1101037c33eae74bee2774897d969d48947f9abe254fJeff Brown */ 1102037c33eae74bee2774897d969d48947f9abe254fJeff Brown public static String stateToString(int state) { 1103037c33eae74bee2774897d969d48947f9abe254fJeff Brown switch (state) { 1104037c33eae74bee2774897d969d48947f9abe254fJeff Brown case STATE_UNKNOWN: 1105037c33eae74bee2774897d969d48947f9abe254fJeff Brown return "UNKNOWN"; 1106037c33eae74bee2774897d969d48947f9abe254fJeff Brown case STATE_OFF: 1107037c33eae74bee2774897d969d48947f9abe254fJeff Brown return "OFF"; 1108037c33eae74bee2774897d969d48947f9abe254fJeff Brown case STATE_ON: 1109037c33eae74bee2774897d969d48947f9abe254fJeff Brown return "ON"; 11105dc219142a756d57355b511c8f8ab913c01710daJeff Brown case STATE_DOZE: 11115dc219142a756d57355b511c8f8ab913c01710daJeff Brown return "DOZE"; 11125dc219142a756d57355b511c8f8ab913c01710daJeff Brown case STATE_DOZE_SUSPEND: 11135dc219142a756d57355b511c8f8ab913c01710daJeff Brown return "DOZE_SUSPEND"; 11143107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon case STATE_VR: 11153107d29c8f6f40b98533978a7e19e5c328f73d24Santos Cordon return "VR"; 1116037c33eae74bee2774897d969d48947f9abe254fJeff Brown default: 1117037c33eae74bee2774897d969d48947f9abe254fJeff Brown return Integer.toString(state); 1118037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1119037c33eae74bee2774897d969d48947f9abe254fJeff Brown } 1120970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown 1121970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown /** 1122970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown * Returns true if display updates may be suspended while in the specified 1123970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown * display power state. 1124970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown * @hide 1125970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown */ 1126970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown public static boolean isSuspendedState(int state) { 1127970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown return state == STATE_OFF || state == STATE_DOZE_SUSPEND; 1128970d4132ea28e748c1010be39450a98bbf7466f3Jeff Brown } 1129b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1130b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 113105e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright * Returns true if the display may be in a reduced operating mode while in the 113205e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright * specified display power state. 113305e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright * @hide 113405e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright */ 113505e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright public static boolean isDozeState(int state) { 113605e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright return state == STATE_DOZE || state == STATE_DOZE_SUSPEND; 113705e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright } 113805e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright 113905e76fe38fa797c12507ad26719797b3fe2a1308Michael Wright /** 1140b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * A mode supported by a given display. 1141b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * 1142b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @see Display#getSupportedModes() 1143b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1144b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public static final class Mode implements Parcelable { 1145b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1146b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @hide 1147b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1148b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public static final Mode[] EMPTY_ARRAY = new Mode[0]; 1149b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1150b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final int mModeId; 1151b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final int mWidth; 1152b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final int mHeight; 1153b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private final float mRefreshRate; 1154b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1155b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1156b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @hide 1157b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1158b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode(int modeId, int width, int height, float refreshRate) { 1159b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mModeId = modeId; 1160b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mWidth = width; 1161b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mHeight = height; 1162b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mRefreshRate = refreshRate; 1163b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1164b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1165b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1166b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns this mode's id. 1167b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1168b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int getModeId() { 1169b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mModeId; 1170b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1171b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1172b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1173b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the physical width of the display in pixels when configured in this mode's 1174b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * resolution. 1175b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1176b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Note that due to application UI scaling, the number of pixels made available to 1177b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * applications when the mode is active (as reported by {@link Display#getWidth()} may 1178b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * differ from the mode's actual resolution (as reported by this function). 1179b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1180b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * For example, applications running on a 4K display may have their UI laid out and rendered 1181b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * in 1080p and then scaled up. Applications can take advantage of the extra resolution by 1182b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * rendering content through a {@link android.view.SurfaceView} using full size buffers. 1183b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1184b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int getPhysicalWidth() { 1185b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mWidth; 1186b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1187b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1188b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1189b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the physical height of the display in pixels when configured in this mode's 1190b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * resolution. 1191b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1192b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Note that due to application UI scaling, the number of pixels made available to 1193b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * applications when the mode is active (as reported by {@link Display#getHeight()} may 1194b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * differ from the mode's actual resolution (as reported by this function). 1195b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * <p> 1196b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * For example, applications running on a 4K display may have their UI laid out and rendered 1197b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * in 1080p and then scaled up. Applications can take advantage of the extra resolution by 1198b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * rendering content through a {@link android.view.SurfaceView} using full size buffers. 1199b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1200b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int getPhysicalHeight() { 1201b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mHeight; 1202b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1203b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1204b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1205b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns the refresh rate in frames per second. 1206b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1207b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public float getRefreshRate() { 1208b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mRefreshRate; 1209b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1210b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1211b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand /** 1212b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * Returns {@code true} if this mode matches the given parameters. 1213b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * 1214b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand * @hide 1215b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand */ 1216b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public boolean matches(int width, int height, float refreshRate) { 1217b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mWidth == width && 1218b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand mHeight == height && 1219b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand Float.floatToIntBits(mRefreshRate) == Float.floatToIntBits(refreshRate); 1220b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1221b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1222b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1223b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public boolean equals(Object other) { 1224b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand if (this == other) { 1225b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return true; 1226b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1227b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand if (!(other instanceof Mode)) { 1228b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return false; 1229b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1230b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand Mode that = (Mode) other; 1231b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return mModeId == that.mModeId && matches(that.mWidth, that.mHeight, that.mRefreshRate); 1232b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1233b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1234b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1235b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int hashCode() { 1236b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand int hash = 1; 1237b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + mModeId; 1238b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + mWidth; 1239b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + mHeight; 1240b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand hash = hash * 17 + Float.floatToIntBits(mRefreshRate); 1241b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return hash; 1242b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1243b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1244b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1245b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public String toString() { 1246b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return new StringBuilder("{") 1247b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append("id=").append(mModeId) 1248b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append(", width=").append(mWidth) 1249b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append(", height=").append(mHeight) 1250b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append(", fps=").append(mRefreshRate) 1251b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .append("}") 1252b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand .toString(); 1253b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1254b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1255b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1256b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public int describeContents() { 1257b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return 0; 1258b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1259b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1260b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand private Mode(Parcel in) { 1261b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand this(in.readInt(), in.readInt(), in.readInt(), in.readFloat()); 1262b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1263b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1264b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1265b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public void writeToParcel(Parcel out, int parcelableFlags) { 1266b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeInt(mModeId); 1267b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeInt(mWidth); 1268b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeInt(mHeight); 1269b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand out.writeFloat(mRefreshRate); 1270b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1271b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1272b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @SuppressWarnings("hiding") 1273b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public static final Parcelable.Creator<Mode> CREATOR 1274b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand = new Parcelable.Creator<Mode>() { 1275b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1276b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode createFromParcel(Parcel in) { 1277b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return new Mode(in); 1278b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1279b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand 1280b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand @Override 1281b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand public Mode[] newArray(int size) { 1282b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand return new Mode[size]; 1283b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 1284b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand }; 1285b3b9eb3cfc5b3b3609a5d01258315798b38a5cf9P.Y. Laligand } 128658e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright 128758e829f71d2c525309e5bb5a1c02dc64397df221Michael Wright /** 1288f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Encapsulates the HDR capabilities of a given display. 1289f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * For example, what HDR types it supports and details about the desired luminance data. 1290f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * <p>You can get an instance for a given {@link Display} object with 1291f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * {@link Display#getHdrCapabilities getHdrCapabilities()}. 1292f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1293f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final class HdrCapabilities implements Parcelable { 1294f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1295f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Invalid luminance value. 1296f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1297f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final float INVALID_LUMINANCE = -1; 1298f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1299f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Dolby Vision high dynamic range (HDR) display. 1300f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1301f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final int HDR_TYPE_DOLBY_VISION = 1; 1302f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1303f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * HDR10 display. 1304f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1305f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final int HDR_TYPE_HDR10 = 2; 1306f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1307f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Hybrid Log-Gamma HDR display. 1308f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1309f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final int HDR_TYPE_HLG = 3; 1310f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1311da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang /** @hide */ 1312f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @IntDef({ 1313f173c323449840771312afe5cbec03a71281e6ffRonghua Wu HDR_TYPE_DOLBY_VISION, 1314f173c323449840771312afe5cbec03a71281e6ffRonghua Wu HDR_TYPE_HDR10, 1315f173c323449840771312afe5cbec03a71281e6ffRonghua Wu HDR_TYPE_HLG, 1316f173c323449840771312afe5cbec03a71281e6ffRonghua Wu }) 1317f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Retention(RetentionPolicy.SOURCE) 1318f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public @interface HdrType {} 1319f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1320f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private @HdrType int[] mSupportedHdrTypes = new int[0]; 1321f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private float mMaxLuminance = INVALID_LUMINANCE; 1322f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private float mMaxAverageLuminance = INVALID_LUMINANCE; 1323f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private float mMinLuminance = INVALID_LUMINANCE; 1324f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1325da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang /** 1326da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang * @hide 1327da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang */ 1328f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities() { 1329f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1330f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 13311e7d1aa6a6bdee2c92245b5bef5aaa7167b8a311Hangyu Kuang /** 13321e7d1aa6a6bdee2c92245b5bef5aaa7167b8a311Hangyu Kuang * @hide 13331e7d1aa6a6bdee2c92245b5bef5aaa7167b8a311Hangyu Kuang */ 133454ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang public HdrCapabilities(int[] supportedHdrTypes, float maxLuminance, 133554ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang float maxAverageLuminance, float minLuminance) { 133654ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mSupportedHdrTypes = supportedHdrTypes; 133754ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mMaxLuminance = maxLuminance; 133854ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mMaxAverageLuminance = maxAverageLuminance; 133954ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang mMinLuminance = minLuminance; 134054ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang } 134154ac21918481fe6f7aac1c0effde51f9e9860ae3Hangyu Kuang 1342f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1343f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Gets the supported HDR types of this display. 1344f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns empty array if HDR is not supported by the display. 1345f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1346f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public @HdrType int[] getSupportedHdrTypes() { 1347f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mSupportedHdrTypes; 1348f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1349f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1350f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the desired content max luminance data in cd/m2 for this display. 1351f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1352f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public float getDesiredMaxLuminance() { 1353f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mMaxLuminance; 1354f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1355f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1356f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the desired content max frame-average luminance data in cd/m2 for this display. 1357f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1358f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public float getDesiredMaxAverageLuminance() { 1359f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mMaxAverageLuminance; 1360f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1361f173c323449840771312afe5cbec03a71281e6ffRonghua Wu /** 1362f173c323449840771312afe5cbec03a71281e6ffRonghua Wu * Returns the desired content min luminance data in cd/m2 for this display. 1363f173c323449840771312afe5cbec03a71281e6ffRonghua Wu */ 1364f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public float getDesiredMinLuminance() { 1365f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return mMinLuminance; 1366f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1367f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 136816ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright @Override 136916ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright public boolean equals(Object other) { 137016ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright if (this == other) { 137116ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return true; 137216ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 137316ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 137416ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright if (!(other instanceof HdrCapabilities)) { 137516ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return false; 137616ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 137716ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright HdrCapabilities that = (HdrCapabilities) other; 137816ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 137916ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return Arrays.equals(mSupportedHdrTypes, that.mSupportedHdrTypes) 138016ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright && mMaxLuminance == that.mMaxLuminance 138116ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright && mMaxAverageLuminance == that.mMaxAverageLuminance 138216ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright && mMinLuminance == that.mMinLuminance; 138316ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 138416ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 138516ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright @Override 138616ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright public int hashCode() { 138716ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright int hash = 23; 138816ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Arrays.hashCode(mSupportedHdrTypes); 138916ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Float.floatToIntBits(mMaxLuminance); 139016ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Float.floatToIntBits(mMaxAverageLuminance); 139116ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright hash = hash * 17 + Float.floatToIntBits(mMinLuminance); 139216ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright return hash; 139316ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright } 139416ae0423516ec1146ff191b4e856e1a6f88ea495Michael Wright 1395f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public static final Creator<HdrCapabilities> CREATOR = new Creator<HdrCapabilities>() { 1396f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1397f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities createFromParcel(Parcel source) { 1398f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return new HdrCapabilities(source); 1399f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1400f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1401f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1402f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public HdrCapabilities[] newArray(int size) { 1403f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return new HdrCapabilities[size]; 1404f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1405f173c323449840771312afe5cbec03a71281e6ffRonghua Wu }; 1406f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1407f173c323449840771312afe5cbec03a71281e6ffRonghua Wu private HdrCapabilities(Parcel source) { 1408f173c323449840771312afe5cbec03a71281e6ffRonghua Wu readFromParcel(source); 1409f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1410f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1411da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang /** 1412da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang * @hide 1413da802f5100fe2b19b5cb898efc2c66bdd7e19fd1Hangyu Kuang */ 1414f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public void readFromParcel(Parcel source) { 1415f173c323449840771312afe5cbec03a71281e6ffRonghua Wu int types = source.readInt(); 1416f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mSupportedHdrTypes = new int[types]; 1417f173c323449840771312afe5cbec03a71281e6ffRonghua Wu for (int i = 0; i < types; ++i) { 1418f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mSupportedHdrTypes[i] = source.readInt(); 1419f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1420f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mMaxLuminance = source.readFloat(); 1421f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mMaxAverageLuminance = source.readFloat(); 1422f173c323449840771312afe5cbec03a71281e6ffRonghua Wu mMinLuminance = source.readFloat(); 1423f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1424f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1425f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1426f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public void writeToParcel(Parcel dest, int flags) { 1427f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeInt(mSupportedHdrTypes.length); 1428f173c323449840771312afe5cbec03a71281e6ffRonghua Wu for (int i = 0; i < mSupportedHdrTypes.length; ++i) { 1429f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeInt(mSupportedHdrTypes[i]); 1430f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1431f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeFloat(mMaxLuminance); 1432f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeFloat(mMaxAverageLuminance); 1433f173c323449840771312afe5cbec03a71281e6ffRonghua Wu dest.writeFloat(mMinLuminance); 1434f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1435f173c323449840771312afe5cbec03a71281e6ffRonghua Wu 1436f173c323449840771312afe5cbec03a71281e6ffRonghua Wu @Override 1437f173c323449840771312afe5cbec03a71281e6ffRonghua Wu public int describeContents() { 1438f173c323449840771312afe5cbec03a71281e6ffRonghua Wu return 0; 1439f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1440f173c323449840771312afe5cbec03a71281e6ffRonghua Wu } 1441037c33eae74bee2774897d969d48947f9abe254fJeff Brown} 1442