The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 19 | import android.content.res.CompatibilityInfo; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 20 | import android.graphics.PixelFormat; |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 21 | import android.graphics.Point; |
| 22 | import android.graphics.Rect; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 23 | import android.hardware.display.DisplayManagerGlobal; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 24 | import android.os.Process; |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 25 | import android.os.SystemClock; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.util.DisplayMetrics; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 27 | import android.util.Log; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 29 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 30 | * Provides information about the size and density of a logical display. |
| 31 | * <p> |
| 32 | * The display area is described in two different ways. |
| 33 | * <ul> |
| 34 | * <li>The application display area specifies the part of the display that may contain |
| 35 | * an application window, excluding the system decorations. The application display area may |
| 36 | * be smaller than the real display area because the system subtracts the space needed |
| 37 | * for decor elements such as the status bar. Use the following methods to query the |
| 38 | * application display area: {@link #getSize}, {@link #getRectSize} and {@link #getMetrics}.</li> |
| 39 | * <li>The real display area specifies the part of the display that contains content |
| 40 | * including the system decorations. Even so, the real display area may be smaller than the |
| 41 | * physical size of the display if the window manager is emulating a smaller display |
| 42 | * using (adb shell am display-size). Use the following methods to query the |
| 43 | * real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li> |
| 44 | * </ul> |
| 45 | * </p><p> |
| 46 | * A logical display does not necessarily represent a particular physical display device |
| 47 | * such as the built-in screen or an external monitor. The contents of a logical |
| 48 | * display may be presented on one or more physical displays according to the devices |
| 49 | * that are currently attached and whether mirroring has been enabled. |
| 50 | * </p> |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 51 | */ |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 52 | public final class Display { |
| 53 | private static final String TAG = "Display"; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 54 | private static final boolean DEBUG = false; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 55 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 56 | private final DisplayManagerGlobal mGlobal; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 57 | private final int mDisplayId; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 58 | private final int mLayerStack; |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 59 | private final int mFlags; |
| 60 | private final int mType; |
| 61 | private final String mAddress; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 62 | private final int mOwnerUid; |
| 63 | private final String mOwnerPackageName; |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 64 | private final DisplayAdjustments mDisplayAdjustments; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 65 | |
| 66 | private DisplayInfo mDisplayInfo; // never null |
| 67 | private boolean mIsValid; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 68 | |
| 69 | // Temporary display metrics structure used for compatibility mode. |
| 70 | private final DisplayMetrics mTempMetrics = new DisplayMetrics(); |
| 71 | |
| 72 | // We cache the app width and height properties briefly between calls |
| 73 | // to getHeight() and getWidth() to ensure that applications perceive |
| 74 | // consistent results when the size changes (most of the time). |
| 75 | // Applications should now be using getSize() instead. |
| 76 | private static final int CACHED_APP_SIZE_DURATION_MILLIS = 20; |
| 77 | private long mLastCachedAppSizeUpdate; |
| 78 | private int mCachedAppWidthCompat; |
| 79 | private int mCachedAppHeightCompat; |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 80 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | /** |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 82 | * The default Display id, which is the id of the built-in primary display |
| 83 | * assuming there is one. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | */ |
| 85 | public static final int DEFAULT_DISPLAY = 0; |
| 86 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | /** |
Jeff Brown | 77aebfd | 2012-10-01 21:07:03 -0700 | [diff] [blame] | 88 | * Display flag: Indicates that the display supports compositing content |
| 89 | * that is stored in protected graphics buffers. |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 90 | * <p> |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 91 | * If this flag is set then the display device supports compositing protected buffers. |
| 92 | * </p><p> |
| 93 | * If this flag is not set then the display device may not support compositing |
| 94 | * protected buffers; the user may see a blank region on the screen instead of |
| 95 | * the protected content. |
| 96 | * </p><p> |
Jeff Brown | 77aebfd | 2012-10-01 21:07:03 -0700 | [diff] [blame] | 97 | * Secure (DRM) video decoders may allocate protected graphics buffers to request that |
| 98 | * a hardware-protected path be provided between the video decoder and the external |
| 99 | * display sink. If a hardware-protected path is not available, then content stored |
| 100 | * in protected graphics buffers may not be composited. |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 101 | * </p><p> |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 102 | * An application can use the absence of this flag as a hint that it should not use protected |
| 103 | * buffers for this display because the content may not be visible. For example, |
| 104 | * if the flag is not set then the application may choose not to show content on this |
| 105 | * display, show an informative error message, select an alternate content stream |
| 106 | * or adopt a different strategy for decoding content that does not rely on |
| 107 | * protected buffers. |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 108 | * </p> |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 109 | * |
| 110 | * @see #getFlags |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 111 | */ |
Jeff Brown | 77aebfd | 2012-10-01 21:07:03 -0700 | [diff] [blame] | 112 | public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 0; |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 115 | * Display flag: Indicates that the display has a secure video output and |
| 116 | * supports compositing secure surfaces. |
| 117 | * <p> |
| 118 | * If this flag is set then the display device has a secure video output |
| 119 | * and is capable of showing secure surfaces. It may also be capable of |
| 120 | * showing {@link #FLAG_SUPPORTS_PROTECTED_BUFFERS protected buffers}. |
| 121 | * </p><p> |
| 122 | * If this flag is not set then the display device may not have a secure video |
| 123 | * output; the user may see a blank region on the screen instead of |
| 124 | * the contents of secure surfaces or protected buffers. |
| 125 | * </p><p> |
| 126 | * Secure surfaces are used to prevent content rendered into those surfaces |
| 127 | * by applications from appearing in screenshots or from being viewed |
| 128 | * on non-secure displays. Protected buffers are used by secure video decoders |
| 129 | * for a similar purpose. |
| 130 | * </p><p> |
| 131 | * An application creates a window with a secure surface by specifying the |
| 132 | * {@link WindowManager.LayoutParams#FLAG_SECURE} window flag. |
| 133 | * Likewise, an application creates a {@link SurfaceView} with a secure surface |
| 134 | * by calling {@link SurfaceView#setSecure} before attaching the secure view to |
| 135 | * its containing window. |
| 136 | * </p><p> |
| 137 | * An application can use the absence of this flag as a hint that it should not create |
| 138 | * secure surfaces or protected buffers on this display because the content may |
| 139 | * not be visible. For example, if the flag is not set then the application may |
| 140 | * choose not to show content on this display, show an informative error message, |
| 141 | * select an alternate content stream or adopt a different strategy for decoding |
| 142 | * content that does not rely on secure surfaces or protected buffers. |
| 143 | * </p> |
| 144 | * |
| 145 | * @see #getFlags |
| 146 | */ |
| 147 | public static final int FLAG_SECURE = 1 << 1; |
| 148 | |
| 149 | /** |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 150 | * Display flag: Indicates that the display is private. Only the application that |
| 151 | * owns the display can create windows on it. |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 152 | * |
| 153 | * @see #getFlags |
| 154 | */ |
| 155 | public static final int FLAG_PRIVATE = 1 << 2; |
| 156 | |
| 157 | /** |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 158 | * Display flag: Indicates that the display is a presentation display. |
| 159 | * <p> |
| 160 | * This flag identifies secondary displays that are suitable for |
| 161 | * use as presentation displays such as HDMI or Wireless displays. Applications |
| 162 | * may automatically project their content to presentation displays to provide |
| 163 | * richer second screen experiences. |
| 164 | * </p> |
| 165 | * |
| 166 | * @see #getFlags |
| 167 | */ |
| 168 | public static final int FLAG_PRESENTATION = 1 << 3; |
| 169 | |
| 170 | /** |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 171 | * Display type: Unknown display type. |
| 172 | * @hide |
| 173 | */ |
| 174 | public static final int TYPE_UNKNOWN = 0; |
| 175 | |
| 176 | /** |
| 177 | * Display type: Built-in display. |
| 178 | * @hide |
| 179 | */ |
| 180 | public static final int TYPE_BUILT_IN = 1; |
| 181 | |
| 182 | /** |
| 183 | * Display type: HDMI display. |
| 184 | * @hide |
| 185 | */ |
| 186 | public static final int TYPE_HDMI = 2; |
| 187 | |
| 188 | /** |
| 189 | * Display type: WiFi display. |
| 190 | * @hide |
| 191 | */ |
| 192 | public static final int TYPE_WIFI = 3; |
| 193 | |
| 194 | /** |
| 195 | * Display type: Overlay display. |
| 196 | * @hide |
| 197 | */ |
| 198 | public static final int TYPE_OVERLAY = 4; |
| 199 | |
| 200 | /** |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 201 | * Display type: Virtual display. |
| 202 | * @hide |
| 203 | */ |
| 204 | public static final int TYPE_VIRTUAL = 5; |
| 205 | |
| 206 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 207 | * Internal method to create a display. |
| 208 | * Applications should use {@link android.view.WindowManager#getDefaultDisplay()} |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 209 | * or {@link android.hardware.display.DisplayManager#getDisplay} |
| 210 | * to get a display object. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 211 | * |
| 212 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | */ |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 214 | public Display(DisplayManagerGlobal global, |
| 215 | int displayId, DisplayInfo displayInfo /*not null*/, |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 216 | DisplayAdjustments daj) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 217 | mGlobal = global; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 218 | mDisplayId = displayId; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 219 | mDisplayInfo = displayInfo; |
Craig Mautner | 1abaa53 | 2013-06-28 12:03:32 -0700 | [diff] [blame] | 220 | mDisplayAdjustments = new DisplayAdjustments(daj); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 221 | mIsValid = true; |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 222 | |
| 223 | // Cache properties that cannot change as long as the display is valid. |
| 224 | mLayerStack = displayInfo.layerStack; |
| 225 | mFlags = displayInfo.flags; |
| 226 | mType = displayInfo.type; |
| 227 | mAddress = displayInfo.address; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 228 | mOwnerUid = displayInfo.ownerUid; |
| 229 | mOwnerPackageName = displayInfo.ownerPackageName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 230 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 231 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 232 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 233 | * Gets the display id. |
| 234 | * <p> |
| 235 | * Each logical display has a unique id. |
| 236 | * The default display has id {@link #DEFAULT_DISPLAY}. |
| 237 | * </p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 238 | */ |
| 239 | public int getDisplayId() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 240 | return mDisplayId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | /** |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 244 | * Returns true if this display is still valid, false if the display has been removed. |
| 245 | * |
| 246 | * If the display is invalid, then the methods of this class will |
| 247 | * continue to report the most recently observed display information. |
| 248 | * However, it is unwise (and rather fruitless) to continue using a |
| 249 | * {@link Display} object after the display's demise. |
| 250 | * |
| 251 | * It's possible for a display that was previously invalid to become |
| 252 | * valid again if a display with the same id is reconnected. |
| 253 | * |
| 254 | * @return True if the display is still valid. |
| 255 | */ |
| 256 | public boolean isValid() { |
| 257 | synchronized (this) { |
| 258 | updateDisplayInfoLocked(); |
| 259 | return mIsValid; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /** |
Jeff Brown | 2ab1b7d9 | 2012-08-08 01:46:41 -0700 | [diff] [blame] | 264 | * Gets a full copy of the display information. |
| 265 | * |
| 266 | * @param outDisplayInfo The object to receive the copy of the display information. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 267 | * @return True if the display is still valid. |
Jeff Brown | 2ab1b7d9 | 2012-08-08 01:46:41 -0700 | [diff] [blame] | 268 | * @hide |
| 269 | */ |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 270 | public boolean getDisplayInfo(DisplayInfo outDisplayInfo) { |
Jeff Brown | 2ab1b7d9 | 2012-08-08 01:46:41 -0700 | [diff] [blame] | 271 | synchronized (this) { |
| 272 | updateDisplayInfoLocked(); |
| 273 | outDisplayInfo.copyFrom(mDisplayInfo); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 274 | return mIsValid; |
Jeff Brown | 2ab1b7d9 | 2012-08-08 01:46:41 -0700 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | |
| 278 | /** |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 279 | * Gets the display's layer stack. |
| 280 | * |
| 281 | * Each display has its own independent layer stack upon which surfaces |
| 282 | * are placed to be managed by surface flinger. |
| 283 | * |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 284 | * @return The display's layer stack number. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 285 | * @hide |
| 286 | */ |
| 287 | public int getLayerStack() { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 288 | return mLayerStack; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | /** |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 292 | * Returns a combination of flags that describe the capabilities of the display. |
| 293 | * |
| 294 | * @return The display flags. |
| 295 | * |
Jeff Brown | 77aebfd | 2012-10-01 21:07:03 -0700 | [diff] [blame] | 296 | * @see #FLAG_SUPPORTS_PROTECTED_BUFFERS |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 297 | * @see #FLAG_SECURE |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 298 | * @see #FLAG_PRIVATE |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 299 | */ |
| 300 | public int getFlags() { |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 301 | return mFlags; |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Gets the display type. |
| 306 | * |
| 307 | * @return The display type. |
| 308 | * |
| 309 | * @see #TYPE_UNKNOWN |
| 310 | * @see #TYPE_BUILT_IN |
| 311 | * @see #TYPE_HDMI |
| 312 | * @see #TYPE_WIFI |
| 313 | * @see #TYPE_OVERLAY |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 314 | * @see #TYPE_VIRTUAL |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 315 | * @hide |
| 316 | */ |
| 317 | public int getType() { |
| 318 | return mType; |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Gets the display address, or null if none. |
| 323 | * Interpretation varies by display type. |
| 324 | * |
| 325 | * @return The display address. |
| 326 | * @hide |
| 327 | */ |
| 328 | public String getAddress() { |
| 329 | return mAddress; |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /** |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 333 | * Gets the UID of the application that owns this display, or zero if it is |
| 334 | * owned by the system. |
| 335 | * <p> |
| 336 | * If the display is private, then only the owner can use it. |
| 337 | * </p> |
| 338 | * |
| 339 | * @hide |
| 340 | */ |
| 341 | public int getOwnerUid() { |
| 342 | return mOwnerUid; |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Gets the package name of the application that owns this display, or null if it is |
| 347 | * owned by the system. |
| 348 | * <p> |
| 349 | * If the display is private, then only the owner can use it. |
| 350 | * </p> |
| 351 | * |
| 352 | * @hide |
| 353 | */ |
| 354 | public String getOwnerPackageName() { |
| 355 | return mOwnerPackageName; |
| 356 | } |
| 357 | |
| 358 | /** |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 359 | * Gets the compatibility info used by this display instance. |
| 360 | * |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 361 | * @return The display adjustments holder, or null if none is required. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 362 | * @hide |
| 363 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 364 | public DisplayAdjustments getDisplayAdjustments() { |
| 365 | return mDisplayAdjustments; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | /** |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 369 | * Gets the name of the display. |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 370 | * <p> |
| 371 | * Note that some displays may be renamed by the user. |
| 372 | * </p> |
| 373 | * |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 374 | * @return The display's name. |
| 375 | */ |
| 376 | public String getName() { |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 377 | synchronized (this) { |
| 378 | updateDisplayInfoLocked(); |
| 379 | return mDisplayInfo.name; |
| 380 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | /** |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 384 | * Gets the size of the display, in pixels. |
| 385 | * <p> |
| 386 | * Note that this value should <em>not</em> be used for computing layouts, |
| 387 | * since a device will typically have screen decoration (such as a status bar) |
Dianne Hackborn | 5cb70b5 | 2010-02-25 17:01:14 -0800 | [diff] [blame] | 388 | * along the edges of the display that reduce the amount of application |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 389 | * space available from the size returned here. Layouts should instead use |
| 390 | * the window size. |
| 391 | * </p><p> |
| 392 | * The size is adjusted based on the current rotation of the display. |
| 393 | * </p><p> |
| 394 | * The size returned by this method does not necessarily represent the |
| 395 | * actual raw size (native resolution) of the display. The returned size may |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 396 | * be adjusted to exclude certain system decoration elements that are always visible. |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 397 | * It may also be scaled to provide compatibility with older applications that |
| 398 | * were originally designed for smaller displays. |
| 399 | * </p> |
| 400 | * |
| 401 | * @param outSize A {@link Point} object to receive the size information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | */ |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 403 | public void getSize(Point outSize) { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 404 | synchronized (this) { |
| 405 | updateDisplayInfoLocked(); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 406 | mDisplayInfo.getAppMetrics(mTempMetrics, mDisplayAdjustments); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 407 | outSize.x = mTempMetrics.widthPixels; |
| 408 | outSize.y = mTempMetrics.heightPixels; |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 409 | } |
| 410 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 411 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | /** |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 413 | * Gets the size of the display as a rectangle, in pixels. |
| 414 | * |
| 415 | * @param outSize A {@link Rect} object to receive the size information. |
| 416 | * @see #getSize(Point) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 417 | */ |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 418 | public void getRectSize(Rect outSize) { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 419 | synchronized (this) { |
| 420 | updateDisplayInfoLocked(); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 421 | mDisplayInfo.getAppMetrics(mTempMetrics, mDisplayAdjustments); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 422 | outSize.set(0, 0, mTempMetrics.widthPixels, mTempMetrics.heightPixels); |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 423 | } |
| 424 | } |
| 425 | |
| 426 | /** |
Dianne Hackborn | 68c33ca | 2012-04-19 14:51:25 -0700 | [diff] [blame] | 427 | * Return the range of display sizes an application can expect to encounter |
| 428 | * under normal operation, as long as there is no physical change in screen |
| 429 | * size. This is basically the sizes you will see as the orientation |
| 430 | * changes, taking into account whatever screen decoration there is in |
| 431 | * each rotation. For example, the status bar is always at the top of the |
| 432 | * screen, so it will reduce the height both in landscape and portrait, and |
| 433 | * the smallest height returned here will be the smaller of the two. |
| 434 | * |
| 435 | * This is intended for applications to get an idea of the range of sizes |
| 436 | * they will encounter while going through device rotations, to provide a |
| 437 | * stable UI through rotation. The sizes here take into account all standard |
| 438 | * system decorations that reduce the size actually available to the |
| 439 | * application: the status bar, navigation bar, system bar, etc. It does |
| 440 | * <em>not</em> take into account more transient elements like an IME |
| 441 | * soft keyboard. |
| 442 | * |
| 443 | * @param outSmallestSize Filled in with the smallest width and height |
| 444 | * that the application will encounter, in pixels (not dp units). The x |
| 445 | * (width) dimension here directly corresponds to |
| 446 | * {@link android.content.res.Configuration#smallestScreenWidthDp |
| 447 | * Configuration.smallestScreenWidthDp}, except the value here is in raw |
| 448 | * screen pixels rather than dp units. Your application may of course |
| 449 | * still get smaller space yet if, for example, a soft keyboard is |
| 450 | * being displayed. |
| 451 | * @param outLargestSize Filled in with the largest width and height |
| 452 | * that the application will encounter, in pixels (not dp units). Your |
| 453 | * application may of course still get larger space than this if, |
| 454 | * for example, screen decorations like the status bar are being hidden. |
| 455 | */ |
| 456 | public void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize) { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 457 | synchronized (this) { |
| 458 | updateDisplayInfoLocked(); |
| 459 | outSmallestSize.x = mDisplayInfo.smallestNominalAppWidth; |
| 460 | outSmallestSize.y = mDisplayInfo.smallestNominalAppHeight; |
| 461 | outLargestSize.x = mDisplayInfo.largestNominalAppWidth; |
| 462 | outLargestSize.y = mDisplayInfo.largestNominalAppHeight; |
Dianne Hackborn | 68c33ca | 2012-04-19 14:51:25 -0700 | [diff] [blame] | 463 | } |
| 464 | } |
| 465 | |
| 466 | /** |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 467 | * Return the maximum screen size dimension that will happen. This is |
| 468 | * mostly for wallpapers. |
| 469 | * @hide |
| 470 | */ |
| 471 | public int getMaximumSizeDimension() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 472 | synchronized (this) { |
| 473 | updateDisplayInfoLocked(); |
| 474 | return Math.max(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 475 | } |
| 476 | } |
| 477 | |
| 478 | /** |
| 479 | * @deprecated Use {@link #getSize(Point)} instead. |
| 480 | */ |
| 481 | @Deprecated |
| 482 | public int getWidth() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 483 | synchronized (this) { |
| 484 | updateCachedAppSizeIfNeededLocked(); |
| 485 | return mCachedAppWidthCompat; |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 486 | } |
| 487 | } |
| 488 | |
| 489 | /** |
| 490 | * @deprecated Use {@link #getSize(Point)} instead. |
| 491 | */ |
| 492 | @Deprecated |
| 493 | public int getHeight() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 494 | synchronized (this) { |
| 495 | updateCachedAppSizeIfNeededLocked(); |
| 496 | return mCachedAppHeightCompat; |
Dianne Hackborn | ac8dea1 | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 500 | /** |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 501 | * @hide |
| 502 | * Return a rectangle defining the insets of the overscan region of the display. |
| 503 | * Each field of the rectangle is the number of pixels the overscan area extends |
| 504 | * into the display on that side. |
| 505 | */ |
| 506 | public void getOverscanInsets(Rect outRect) { |
| 507 | synchronized (this) { |
| 508 | updateDisplayInfoLocked(); |
| 509 | outRect.set(mDisplayInfo.overscanLeft, mDisplayInfo.overscanTop, |
| 510 | mDisplayInfo.overscanRight, mDisplayInfo.overscanBottom); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | /** |
Dianne Hackborn | 5cb70b5 | 2010-02-25 17:01:14 -0800 | [diff] [blame] | 515 | * Returns the rotation of the screen from its "natural" orientation. |
| 516 | * The returned value may be {@link Surface#ROTATION_0 Surface.ROTATION_0} |
| 517 | * (no rotation), {@link Surface#ROTATION_90 Surface.ROTATION_90}, |
| 518 | * {@link Surface#ROTATION_180 Surface.ROTATION_180}, or |
| 519 | * {@link Surface#ROTATION_270 Surface.ROTATION_270}. For |
| 520 | * example, if a device has a naturally tall screen, and the user has |
| 521 | * turned it on its side to go into a landscape orientation, the value |
| 522 | * returned here may be either {@link Surface#ROTATION_90 Surface.ROTATION_90} |
| 523 | * or {@link Surface#ROTATION_270 Surface.ROTATION_270} depending on |
| 524 | * the direction it was turned. The angle is the rotation of the drawn |
| 525 | * graphics on the screen, which is the opposite direction of the physical |
| 526 | * rotation of the device. For example, if the device is rotated 90 |
| 527 | * degrees counter-clockwise, to compensate rendering will be rotated by |
| 528 | * 90 degrees clockwise and thus the returned value here will be |
| 529 | * {@link Surface#ROTATION_90 Surface.ROTATION_90}. |
| 530 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 531 | @Surface.Rotation |
Dianne Hackborn | 5cb70b5 | 2010-02-25 17:01:14 -0800 | [diff] [blame] | 532 | public int getRotation() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 533 | synchronized (this) { |
| 534 | updateDisplayInfoLocked(); |
| 535 | return mDisplayInfo.rotation; |
| 536 | } |
Dianne Hackborn | 5cb70b5 | 2010-02-25 17:01:14 -0800 | [diff] [blame] | 537 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 538 | |
Dianne Hackborn | 5cb70b5 | 2010-02-25 17:01:14 -0800 | [diff] [blame] | 539 | /** |
Joe Onorato | 4c904a3 | 2010-02-26 12:35:55 -0800 | [diff] [blame] | 540 | * @deprecated use {@link #getRotation} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 541 | * @return orientation of this display. |
| 542 | */ |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 543 | @Deprecated |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 544 | @Surface.Rotation |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 545 | public int getOrientation() { |
| 546 | return getRotation(); |
| 547 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | |
| 549 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 550 | * Gets the pixel format of the display. |
| 551 | * @return One of the constants defined in {@link android.graphics.PixelFormat}. |
| 552 | * |
| 553 | * @deprecated This method is no longer supported. |
| 554 | * The result is always {@link PixelFormat#RGBA_8888}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 555 | */ |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 556 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 557 | public int getPixelFormat() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 558 | return PixelFormat.RGBA_8888; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 559 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 560 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 561 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 562 | * Gets the refresh rate of this display in frames per second. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 563 | */ |
| 564 | public float getRefreshRate() { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 565 | synchronized (this) { |
| 566 | updateDisplayInfoLocked(); |
| 567 | return mDisplayInfo.refreshRate; |
| 568 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 569 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 570 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 571 | /** |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 572 | * Gets display metrics that describe the size and density of this display. |
| 573 | * <p> |
| 574 | * The size is adjusted based on the current rotation of the display. |
| 575 | * </p><p> |
| 576 | * The size returned by this method does not necessarily represent the |
| 577 | * actual raw size (native resolution) of the display. The returned size may |
| 578 | * be adjusted to exclude certain system decor elements that are always visible. |
| 579 | * It may also be scaled to provide compatibility with older applications that |
| 580 | * were originally designed for smaller displays. |
| 581 | * </p> |
| 582 | * |
| 583 | * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 584 | */ |
| 585 | public void getMetrics(DisplayMetrics outMetrics) { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 586 | synchronized (this) { |
| 587 | updateDisplayInfoLocked(); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 588 | mDisplayInfo.getAppMetrics(outMetrics, mDisplayAdjustments); |
Dianne Hackborn | 68066c2 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 589 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 590 | } |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 591 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 592 | /** |
| 593 | * Gets the real size of the display without subtracting any window decor or |
| 594 | * applying any compatibility scale factors. |
| 595 | * <p> |
| 596 | * The size is adjusted based on the current rotation of the display. |
| 597 | * </p><p> |
| 598 | * The real size may be smaller than the physical size of the screen when the |
| 599 | * window manager is emulating a smaller display (using adb shell am display-size). |
| 600 | * </p> |
| 601 | * |
| 602 | * @param outSize Set to the real size of the display. |
| 603 | */ |
| 604 | public void getRealSize(Point outSize) { |
| 605 | synchronized (this) { |
| 606 | updateDisplayInfoLocked(); |
| 607 | outSize.x = mDisplayInfo.logicalWidth; |
| 608 | outSize.y = mDisplayInfo.logicalHeight; |
| 609 | } |
Dianne Hackborn | 68066c2 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | /** |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 613 | * Gets display metrics based on the real size of this display. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 614 | * <p> |
| 615 | * The size is adjusted based on the current rotation of the display. |
| 616 | * </p><p> |
| 617 | * The real size may be smaller than the physical size of the screen when the |
| 618 | * window manager is emulating a smaller display (using adb shell am display-size). |
| 619 | * </p> |
| 620 | * |
| 621 | * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. |
Dianne Hackborn | 68066c2 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 622 | */ |
| 623 | public void getRealMetrics(DisplayMetrics outMetrics) { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 624 | synchronized (this) { |
| 625 | updateDisplayInfoLocked(); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 626 | mDisplayInfo.getLogicalMetrics(outMetrics, |
| 627 | CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, |
| 628 | mDisplayAdjustments.getActivityToken()); |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 629 | } |
Dianne Hackborn | 68066c2 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 630 | } |
| 631 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 632 | /** |
| 633 | * Returns true if the specified UID has access to this display. |
| 634 | * @hide |
| 635 | */ |
| 636 | public boolean hasAccess(int uid) { |
| 637 | return Display.hasAccess(uid, mFlags, mOwnerUid); |
| 638 | } |
| 639 | |
| 640 | /** @hide */ |
| 641 | public static boolean hasAccess(int uid, int flags, int ownerUid) { |
| 642 | return (flags & Display.FLAG_PRIVATE) == 0 |
| 643 | || uid == ownerUid |
| 644 | || uid == Process.SYSTEM_UID |
| 645 | || uid == 0; |
| 646 | } |
| 647 | |
Jeff Brown | 69b0716 | 2013-11-07 00:30:16 -0800 | [diff] [blame] | 648 | /** |
| 649 | * Returns true if the display is a public presentation display. |
| 650 | * @hide |
| 651 | */ |
| 652 | public boolean isPublicPresentation() { |
| 653 | return (mFlags & (Display.FLAG_PRIVATE | Display.FLAG_PRESENTATION)) == |
| 654 | Display.FLAG_PRESENTATION; |
| 655 | } |
| 656 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 657 | private void updateDisplayInfoLocked() { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 658 | // Note: The display manager caches display info objects on our behalf. |
| 659 | DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId); |
| 660 | if (newInfo == null) { |
| 661 | // Preserve the old mDisplayInfo after the display is removed. |
| 662 | if (mIsValid) { |
| 663 | mIsValid = false; |
| 664 | if (DEBUG) { |
| 665 | Log.d(TAG, "Logical display " + mDisplayId + " was removed."); |
| 666 | } |
| 667 | } |
| 668 | } else { |
| 669 | // Use the new display info. (It might be the same object if nothing changed.) |
| 670 | mDisplayInfo = newInfo; |
| 671 | if (!mIsValid) { |
| 672 | mIsValid = true; |
| 673 | if (DEBUG) { |
| 674 | Log.d(TAG, "Logical display " + mDisplayId + " was recreated."); |
| 675 | } |
| 676 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 677 | } |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 678 | } |
| 679 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 680 | private void updateCachedAppSizeIfNeededLocked() { |
| 681 | long now = SystemClock.uptimeMillis(); |
| 682 | if (now > mLastCachedAppSizeUpdate + CACHED_APP_SIZE_DURATION_MILLIS) { |
| 683 | updateDisplayInfoLocked(); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 684 | mDisplayInfo.getAppMetrics(mTempMetrics, mDisplayAdjustments); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 685 | mCachedAppWidthCompat = mTempMetrics.widthPixels; |
| 686 | mCachedAppHeightCompat = mTempMetrics.heightPixels; |
| 687 | mLastCachedAppSizeUpdate = now; |
| 688 | } |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 689 | } |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 690 | |
| 691 | // For debugging purposes |
| 692 | @Override |
| 693 | public String toString() { |
| 694 | synchronized (this) { |
| 695 | updateDisplayInfoLocked(); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 696 | mDisplayInfo.getAppMetrics(mTempMetrics, mDisplayAdjustments); |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 697 | return "Display id " + mDisplayId + ": " + mDisplayInfo |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 698 | + ", " + mTempMetrics + ", isValid=" + mIsValid; |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 699 | } |
| 700 | } |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 701 | |
| 702 | /** |
| 703 | * @hide |
| 704 | */ |
| 705 | public static String typeToString(int type) { |
| 706 | switch (type) { |
| 707 | case TYPE_UNKNOWN: |
| 708 | return "UNKNOWN"; |
| 709 | case TYPE_BUILT_IN: |
| 710 | return "BUILT_IN"; |
| 711 | case TYPE_HDMI: |
| 712 | return "HDMI"; |
| 713 | case TYPE_WIFI: |
| 714 | return "WIFI"; |
| 715 | case TYPE_OVERLAY: |
| 716 | return "OVERLAY"; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 717 | case TYPE_VIRTUAL: |
| 718 | return "VIRTUAL"; |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 719 | default: |
| 720 | return Integer.toString(type); |
| 721 | } |
| 722 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 723 | } |
| 724 | |