blob: 476126c9e6d02f558a484c6bad5198b22c16a1d1 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.view;
18
Aurimas Liutikas67e2ae82016-10-11 18:17:42 -070019import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE;
20
Ronghua Wuf173c322016-02-29 13:57:18 -080021import android.annotation.IntDef;
Michael Wright58e829f2015-09-15 00:13:26 +010022import android.annotation.RequiresPermission;
Mathew Inwoode5ad5982018-08-17 15:07:52 +010023import android.annotation.UnsupportedAppUsage;
Adrian Roose99bc052017-11-20 17:55:31 +010024import android.app.KeyguardManager;
Craig Mautner48d0d182013-06-11 07:53:06 -070025import android.content.res.CompatibilityInfo;
Romain Guye89d0bb2017-06-20 12:23:42 -070026import android.content.res.Configuration;
Bryce Lee609bf652017-02-09 16:50:13 -080027import android.content.res.Resources;
Jeff Brownfa25bf52012-07-23 19:26:30 -070028import android.graphics.PixelFormat;
Dianne Hackbornac8dea12011-04-20 18:18:51 -070029import android.graphics.Point;
30import android.graphics.Rect;
Andrii Kulian732a90a2017-08-17 17:21:20 -070031import android.hardware.display.DisplayManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070032import android.hardware.display.DisplayManagerGlobal;
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -070033import android.os.Parcel;
34import android.os.Parcelable;
Jeff Browna506a6e2013-06-04 00:02:38 -070035import android.os.Process;
Dianne Hackbornac8dea12011-04-20 18:18:51 -070036import android.os.SystemClock;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037import android.util.DisplayMetrics;
Jeff Brownfa25bf52012-07-23 19:26:30 -070038import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039
Ronghua Wuf173c322016-02-29 13:57:18 -080040import java.lang.annotation.Retention;
41import java.lang.annotation.RetentionPolicy;
Michael Wright3f145a22014-07-22 19:46:03 -070042import java.util.Arrays;
43
Jeff Brownbc68a592011-07-25 12:58:12 -070044/**
Jeff Brownfa25bf52012-07-23 19:26:30 -070045 * Provides information about the size and density of a logical display.
46 * <p>
47 * The display area is described in two different ways.
48 * <ul>
49 * <li>The application display area specifies the part of the display that may contain
50 * an application window, excluding the system decorations. The application display area may
51 * be smaller than the real display area because the system subtracts the space needed
52 * for decor elements such as the status bar. Use the following methods to query the
53 * application display area: {@link #getSize}, {@link #getRectSize} and {@link #getMetrics}.</li>
54 * <li>The real display area specifies the part of the display that contains content
55 * including the system decorations. Even so, the real display area may be smaller than the
56 * physical size of the display if the window manager is emulating a smaller display
Andrii Kuliancd097992017-03-23 18:31:59 -070057 * using (adb shell wm size). Use the following methods to query the
Jeff Brownfa25bf52012-07-23 19:26:30 -070058 * real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li>
59 * </ul>
60 * </p><p>
61 * A logical display does not necessarily represent a particular physical display device
62 * such as the built-in screen or an external monitor. The contents of a logical
63 * display may be presented on one or more physical displays according to the devices
64 * that are currently attached and whether mirroring has been enabled.
65 * </p>
Jeff Brownbc68a592011-07-25 12:58:12 -070066 */
Jeff Brownfa25bf52012-07-23 19:26:30 -070067public final class Display {
68 private static final String TAG = "Display";
Jeff Brownbd6e1502012-08-28 03:27:37 -070069 private static final boolean DEBUG = false;
Jeff Brownfa25bf52012-07-23 19:26:30 -070070
Jeff Brownbd6e1502012-08-28 03:27:37 -070071 private final DisplayManagerGlobal mGlobal;
Jeff Brownfa25bf52012-07-23 19:26:30 -070072 private final int mDisplayId;
Jeff Brown4ed8fe72012-08-30 18:18:29 -070073 private final int mLayerStack;
Jeff Brown92130f62012-10-24 21:28:33 -070074 private final int mFlags;
75 private final int mType;
76 private final String mAddress;
Jeff Browna506a6e2013-06-04 00:02:38 -070077 private final int mOwnerUid;
78 private final String mOwnerPackageName;
Bryce Lee609bf652017-02-09 16:50:13 -080079 private final Resources mResources;
80 private DisplayAdjustments mDisplayAdjustments;
Jeff Brownbd6e1502012-08-28 03:27:37 -070081
Mathew Inwoode5ad5982018-08-17 15:07:52 +010082 @UnsupportedAppUsage
Jeff Brownbd6e1502012-08-28 03:27:37 -070083 private DisplayInfo mDisplayInfo; // never null
84 private boolean mIsValid;
Jeff Brownfa25bf52012-07-23 19:26:30 -070085
86 // Temporary display metrics structure used for compatibility mode.
87 private final DisplayMetrics mTempMetrics = new DisplayMetrics();
88
89 // We cache the app width and height properties briefly between calls
90 // to getHeight() and getWidth() to ensure that applications perceive
91 // consistent results when the size changes (most of the time).
92 // Applications should now be using getSize() instead.
93 private static final int CACHED_APP_SIZE_DURATION_MILLIS = 20;
94 private long mLastCachedAppSizeUpdate;
95 private int mCachedAppWidthCompat;
96 private int mCachedAppHeightCompat;
Dianne Hackborn5fd21692011-06-07 14:09:47 -070097
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 /**
Jeff Brown98365d72012-08-19 20:30:52 -070099 * The default Display id, which is the id of the built-in primary display
100 * assuming there is one.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 */
102 public static final int DEFAULT_DISPLAY = 0;
103
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 /**
Wale Ogunwale26698512015-06-05 16:55:33 -0700105 * Invalid display id.
106 */
107 public static final int INVALID_DISPLAY = -1;
108
109 /**
Jeff Brown77aebfd2012-10-01 21:07:03 -0700110 * Display flag: Indicates that the display supports compositing content
111 * that is stored in protected graphics buffers.
Jeff Brownc5df37c2012-09-13 11:45:07 -0700112 * <p>
Jeff Brownf0681b32012-10-23 17:35:57 -0700113 * If this flag is set then the display device supports compositing protected buffers.
114 * </p><p>
115 * If this flag is not set then the display device may not support compositing
116 * protected buffers; the user may see a blank region on the screen instead of
117 * the protected content.
118 * </p><p>
Jeff Brown77aebfd2012-10-01 21:07:03 -0700119 * Secure (DRM) video decoders may allocate protected graphics buffers to request that
120 * a hardware-protected path be provided between the video decoder and the external
121 * display sink. If a hardware-protected path is not available, then content stored
122 * in protected graphics buffers may not be composited.
Jeff Brownc5df37c2012-09-13 11:45:07 -0700123 * </p><p>
Jeff Brownf0681b32012-10-23 17:35:57 -0700124 * An application can use the absence of this flag as a hint that it should not use protected
125 * buffers for this display because the content may not be visible. For example,
126 * if the flag is not set then the application may choose not to show content on this
127 * display, show an informative error message, select an alternate content stream
128 * or adopt a different strategy for decoding content that does not rely on
129 * protected buffers.
Jeff Brownc5df37c2012-09-13 11:45:07 -0700130 * </p>
Jeff Brownf0681b32012-10-23 17:35:57 -0700131 *
132 * @see #getFlags
Jeff Brownc5df37c2012-09-13 11:45:07 -0700133 */
Jeff Brown77aebfd2012-10-01 21:07:03 -0700134 public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 0;
Jeff Brownc5df37c2012-09-13 11:45:07 -0700135
136 /**
Jeff Brownf0681b32012-10-23 17:35:57 -0700137 * Display flag: Indicates that the display has a secure video output and
138 * supports compositing secure surfaces.
139 * <p>
140 * If this flag is set then the display device has a secure video output
141 * and is capable of showing secure surfaces. It may also be capable of
142 * showing {@link #FLAG_SUPPORTS_PROTECTED_BUFFERS protected buffers}.
143 * </p><p>
144 * If this flag is not set then the display device may not have a secure video
145 * output; the user may see a blank region on the screen instead of
146 * the contents of secure surfaces or protected buffers.
147 * </p><p>
148 * Secure surfaces are used to prevent content rendered into those surfaces
149 * by applications from appearing in screenshots or from being viewed
150 * on non-secure displays. Protected buffers are used by secure video decoders
151 * for a similar purpose.
152 * </p><p>
153 * An application creates a window with a secure surface by specifying the
154 * {@link WindowManager.LayoutParams#FLAG_SECURE} window flag.
155 * Likewise, an application creates a {@link SurfaceView} with a secure surface
156 * by calling {@link SurfaceView#setSecure} before attaching the secure view to
157 * its containing window.
158 * </p><p>
159 * An application can use the absence of this flag as a hint that it should not create
160 * secure surfaces or protected buffers on this display because the content may
161 * not be visible. For example, if the flag is not set then the application may
162 * choose not to show content on this display, show an informative error message,
163 * select an alternate content stream or adopt a different strategy for decoding
164 * content that does not rely on secure surfaces or protected buffers.
165 * </p>
166 *
167 * @see #getFlags
168 */
169 public static final int FLAG_SECURE = 1 << 1;
170
171 /**
Jeff Browna506a6e2013-06-04 00:02:38 -0700172 * Display flag: Indicates that the display is private. Only the application that
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800173 * owns the display and apps that are already on the display can create windows on it.
Jeff Browna506a6e2013-06-04 00:02:38 -0700174 *
175 * @see #getFlags
176 */
177 public static final int FLAG_PRIVATE = 1 << 2;
178
179 /**
Jeff Brown7d00aff2013-08-02 19:03:49 -0700180 * Display flag: Indicates that the display is a presentation display.
181 * <p>
182 * This flag identifies secondary displays that are suitable for
183 * use as presentation displays such as HDMI or Wireless displays. Applications
184 * may automatically project their content to presentation displays to provide
185 * richer second screen experiences.
186 * </p>
187 *
188 * @see #getFlags
189 */
190 public static final int FLAG_PRESENTATION = 1 << 3;
191
192 /**
Adam Powell49e7ff92015-05-14 16:18:53 -0700193 * Display flag: Indicates that the display has a round shape.
194 * <p>
195 * This flag identifies displays that are circular, elliptical or otherwise
196 * do not permit the user to see all the way to the logical corners of the display.
197 * </p>
198 *
199 * @see #getFlags
200 */
201 public static final int FLAG_ROUND = 1 << 4;
202
203 /**
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800204 * Display flag: Indicates that the display can show its content when non-secure keyguard is
205 * shown.
206 * <p>
Andrii Kulian732a90a2017-08-17 17:21:20 -0700207 * This flag identifies secondary displays that will continue showing content if keyguard can be
208 * dismissed without entering credentials.
209 * </p><p>
210 * An example of usage is a virtual display which content is displayed on external hardware
211 * display that is not visible to the system directly.
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800212 * </p>
213 *
Andrii Kulian732a90a2017-08-17 17:21:20 -0700214 * @see DisplayManager#VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD
Adrian Roose99bc052017-11-20 17:55:31 +0100215 * @see KeyguardManager#isDeviceSecure()
216 * @see KeyguardManager#isDeviceLocked()
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800217 * @see #getFlags
Andrii Kulian22512e82017-04-13 11:34:43 -0700218 * @hide
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800219 */
Andrii Kulian7211d2e2017-01-27 15:58:05 -0800220 public static final int FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5;
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800221
222 /**
Jeff Brownd46747a2015-04-15 19:02:36 -0700223 * Display flag: Indicates that the contents of the display should not be scaled
224 * to fit the physical screen dimensions. Used for development only to emulate
225 * devices with smaller physicals screens while preserving density.
226 *
227 * @hide
228 */
229 public static final int FLAG_SCALING_DISABLED = 1 << 30;
230
231 /**
Jeff Brown92130f62012-10-24 21:28:33 -0700232 * Display type: Unknown display type.
233 * @hide
234 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100235 @UnsupportedAppUsage
Jeff Brown92130f62012-10-24 21:28:33 -0700236 public static final int TYPE_UNKNOWN = 0;
237
238 /**
239 * Display type: Built-in display.
240 * @hide
241 */
242 public static final int TYPE_BUILT_IN = 1;
243
244 /**
245 * Display type: HDMI display.
246 * @hide
247 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100248 @UnsupportedAppUsage
Jeff Brown92130f62012-10-24 21:28:33 -0700249 public static final int TYPE_HDMI = 2;
250
251 /**
252 * Display type: WiFi display.
253 * @hide
254 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100255 @UnsupportedAppUsage
Jeff Brown92130f62012-10-24 21:28:33 -0700256 public static final int TYPE_WIFI = 3;
257
258 /**
259 * Display type: Overlay display.
260 * @hide
261 */
262 public static final int TYPE_OVERLAY = 4;
263
264 /**
Jeff Browna506a6e2013-06-04 00:02:38 -0700265 * Display type: Virtual display.
266 * @hide
267 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100268 @UnsupportedAppUsage
Jeff Browna506a6e2013-06-04 00:02:38 -0700269 public static final int TYPE_VIRTUAL = 5;
270
271 /**
Jeff Brown037c33e2014-04-09 00:31:55 -0700272 * Display state: The display state is unknown.
273 *
274 * @see #getState
275 */
Bookatz1a1b0462018-01-12 11:47:03 -0800276 public static final int STATE_UNKNOWN = ViewProtoEnums.DISPLAY_STATE_UNKNOWN; // 0
Jeff Brown037c33e2014-04-09 00:31:55 -0700277
278 /**
279 * Display state: The display is off.
280 *
281 * @see #getState
282 */
Bookatz1a1b0462018-01-12 11:47:03 -0800283 public static final int STATE_OFF = ViewProtoEnums.DISPLAY_STATE_OFF; // 1
Jeff Brown037c33e2014-04-09 00:31:55 -0700284
285 /**
286 * Display state: The display is on.
287 *
288 * @see #getState
289 */
Bookatz1a1b0462018-01-12 11:47:03 -0800290 public static final int STATE_ON = ViewProtoEnums.DISPLAY_STATE_ON; // 2
Jeff Brown037c33e2014-04-09 00:31:55 -0700291
292 /**
Jeff Brown5dc21912014-07-17 18:50:18 -0700293 * Display state: The display is dozing in a low power state; it is still
294 * on but is optimized for showing system-provided content while the
295 * device is non-interactive.
Jeff Brown037c33e2014-04-09 00:31:55 -0700296 *
297 * @see #getState
298 * @see android.os.PowerManager#isInteractive
299 */
Bookatz1a1b0462018-01-12 11:47:03 -0800300 public static final int STATE_DOZE = ViewProtoEnums.DISPLAY_STATE_DOZE; // 3
Jeff Brown5dc21912014-07-17 18:50:18 -0700301
302 /**
303 * Display state: The display is dozing in a suspended low power state; it is still
Chris Phoenix10a4a642017-09-25 13:21:00 -0700304 * on but the CPU is not updating it. This may be used in one of two ways: to show
305 * static system-provided content while the device is non-interactive, or to allow
306 * a "Sidekick" compute resource to update the display. For this reason, the
307 * CPU must not control the display in this mode.
Jeff Brown5dc21912014-07-17 18:50:18 -0700308 *
309 * @see #getState
310 * @see android.os.PowerManager#isInteractive
311 */
Bookatz1a1b0462018-01-12 11:47:03 -0800312 public static final int STATE_DOZE_SUSPEND = ViewProtoEnums.DISPLAY_STATE_DOZE_SUSPEND; // 4
Jeff Brown037c33e2014-04-09 00:31:55 -0700313
Santos Cordon3107d292016-09-20 15:50:35 -0700314 /**
315 * Display state: The display is on and optimized for VR mode.
316 *
317 * @see #getState
318 * @see android.os.PowerManager#isInteractive
Santos Cordon3107d292016-09-20 15:50:35 -0700319 */
Bookatz1a1b0462018-01-12 11:47:03 -0800320 public static final int STATE_VR = ViewProtoEnums.DISPLAY_STATE_VR; // 5
Santos Cordon3107d292016-09-20 15:50:35 -0700321
Chris Phoenix10a4a642017-09-25 13:21:00 -0700322 /**
323 * Display state: The display is in a suspended full power state; it is still
324 * on but the CPU is not updating it. This may be used in one of two ways: to show
325 * static system-provided content while the device is non-interactive, or to allow
326 * a "Sidekick" compute resource to update the display. For this reason, the
327 * CPU must not control the display in this mode.
328 *
329 * @see #getState
330 * @see android.os.PowerManager#isInteractive
331 */
Bookatz1a1b0462018-01-12 11:47:03 -0800332 public static final int STATE_ON_SUSPEND = ViewProtoEnums.DISPLAY_STATE_ON_SUSPEND; // 6
Chris Phoenix10a4a642017-09-25 13:21:00 -0700333
Michael Wright1c9977b2016-07-12 13:30:10 -0700334 /* The color mode constants defined below must be kept in sync with the ones in
Romain Guy6d228c22017-01-20 18:41:06 -0800335 * system/core/include/system/graphics-base.h */
Michael Wright1c9977b2016-07-12 13:30:10 -0700336
337 /**
338 * Display color mode: The current color mode is unknown or invalid.
339 * @hide
340 */
341 public static final int COLOR_MODE_INVALID = -1;
342
343 /**
344 * Display color mode: The default or native gamut of the display.
345 * @hide
346 */
347 public static final int COLOR_MODE_DEFAULT = 0;
348
Romain Guy6d228c22017-01-20 18:41:06 -0800349 /** @hide */
350 public static final int COLOR_MODE_BT601_625 = 1;
351 /** @hide */
352 public static final int COLOR_MODE_BT601_625_UNADJUSTED = 2;
353 /** @hide */
354 public static final int COLOR_MODE_BT601_525 = 3;
355 /** @hide */
356 public static final int COLOR_MODE_BT601_525_UNADJUSTED = 4;
357 /** @hide */
358 public static final int COLOR_MODE_BT709 = 5;
359 /** @hide */
360 public static final int COLOR_MODE_DCI_P3 = 6;
361 /** @hide */
Michael Wright1c9977b2016-07-12 13:30:10 -0700362 public static final int COLOR_MODE_SRGB = 7;
Romain Guy6d228c22017-01-20 18:41:06 -0800363 /** @hide */
364 public static final int COLOR_MODE_ADOBE_RGB = 8;
365 /** @hide */
366 public static final int COLOR_MODE_DISPLAY_P3 = 9;
Michael Wright1c9977b2016-07-12 13:30:10 -0700367
Jeff Brown037c33e2014-04-09 00:31:55 -0700368 /**
Andrii Kulian250d6532017-02-08 23:30:45 -0800369 * Indicates that when display is removed, all its activities will be moved to the primary
370 * display and the topmost activity should become focused.
371 *
372 * @hide
373 */
374 public static final int REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY = 0;
375 /**
376 * Indicates that when display is removed, all its stacks and tasks will be removed, all
377 * activities will be destroyed according to the usual lifecycle.
378 *
379 * @hide
380 */
381 public static final int REMOVE_MODE_DESTROY_CONTENT = 1;
382
383 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -0700384 * Internal method to create a display.
Bryce Lee609bf652017-02-09 16:50:13 -0800385 * The display created with this method will have a static {@link DisplayAdjustments} applied.
Jeff Brownfa25bf52012-07-23 19:26:30 -0700386 * Applications should use {@link android.view.WindowManager#getDefaultDisplay()}
Jeff Brown98365d72012-08-19 20:30:52 -0700387 * or {@link android.hardware.display.DisplayManager#getDisplay}
388 * to get a display object.
Jeff Brownfa25bf52012-07-23 19:26:30 -0700389 *
390 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800391 */
Bryce Lee609bf652017-02-09 16:50:13 -0800392 public Display(DisplayManagerGlobal global, int displayId, /*@NotNull*/ DisplayInfo displayInfo,
Craig Mautner48d0d182013-06-11 07:53:06 -0700393 DisplayAdjustments daj) {
Bryce Lee609bf652017-02-09 16:50:13 -0800394 this(global, displayId, displayInfo, daj, null /*res*/);
395 }
396
397 /**
398 * Internal method to create a display.
399 * The display created with this method will be adjusted based on the adjustments in the
400 * supplied {@link Resources}.
401 *
402 * @hide
403 */
404 public Display(DisplayManagerGlobal global, int displayId, /*@NotNull*/ DisplayInfo displayInfo,
405 Resources res) {
406 this(global, displayId, displayInfo, null /*daj*/, res);
407 }
408
409 private Display(DisplayManagerGlobal global, int displayId,
410 /*@NotNull*/ DisplayInfo displayInfo, DisplayAdjustments daj, Resources res) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700411 mGlobal = global;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700412 mDisplayId = displayId;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700413 mDisplayInfo = displayInfo;
Bryce Lee609bf652017-02-09 16:50:13 -0800414 mResources = res;
415 mDisplayAdjustments = mResources != null
416 ? new DisplayAdjustments(mResources.getConfiguration())
417 : daj != null ? new DisplayAdjustments(daj) : null;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700418 mIsValid = true;
Jeff Brown92130f62012-10-24 21:28:33 -0700419
420 // Cache properties that cannot change as long as the display is valid.
421 mLayerStack = displayInfo.layerStack;
422 mFlags = displayInfo.flags;
423 mType = displayInfo.type;
424 mAddress = displayInfo.address;
Jeff Browna506a6e2013-06-04 00:02:38 -0700425 mOwnerUid = displayInfo.ownerUid;
426 mOwnerPackageName = displayInfo.ownerPackageName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800427 }
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700428
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800429 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -0700430 * Gets the display id.
431 * <p>
432 * Each logical display has a unique id.
433 * The default display has id {@link #DEFAULT_DISPLAY}.
434 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800435 */
436 public int getDisplayId() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700437 return mDisplayId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 }
439
440 /**
Jeff Brownbd6e1502012-08-28 03:27:37 -0700441 * Returns true if this display is still valid, false if the display has been removed.
442 *
443 * If the display is invalid, then the methods of this class will
444 * continue to report the most recently observed display information.
445 * However, it is unwise (and rather fruitless) to continue using a
446 * {@link Display} object after the display's demise.
447 *
448 * It's possible for a display that was previously invalid to become
449 * valid again if a display with the same id is reconnected.
450 *
451 * @return True if the display is still valid.
452 */
453 public boolean isValid() {
454 synchronized (this) {
455 updateDisplayInfoLocked();
456 return mIsValid;
457 }
458 }
459
460 /**
Jeff Brown2ab1b7d92012-08-08 01:46:41 -0700461 * Gets a full copy of the display information.
462 *
463 * @param outDisplayInfo The object to receive the copy of the display information.
Jeff Brownbd6e1502012-08-28 03:27:37 -0700464 * @return True if the display is still valid.
Jeff Brown2ab1b7d92012-08-08 01:46:41 -0700465 * @hide
466 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100467 @UnsupportedAppUsage
Jeff Brownbd6e1502012-08-28 03:27:37 -0700468 public boolean getDisplayInfo(DisplayInfo outDisplayInfo) {
Jeff Brown2ab1b7d92012-08-08 01:46:41 -0700469 synchronized (this) {
470 updateDisplayInfoLocked();
471 outDisplayInfo.copyFrom(mDisplayInfo);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700472 return mIsValid;
Jeff Brown2ab1b7d92012-08-08 01:46:41 -0700473 }
474 }
475
476 /**
Jeff Brown98365d72012-08-19 20:30:52 -0700477 * Gets the display's layer stack.
478 *
479 * Each display has its own independent layer stack upon which surfaces
480 * are placed to be managed by surface flinger.
481 *
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700482 * @return The display's layer stack number.
Jeff Brown98365d72012-08-19 20:30:52 -0700483 * @hide
484 */
485 public int getLayerStack() {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700486 return mLayerStack;
Jeff Brown98365d72012-08-19 20:30:52 -0700487 }
488
489 /**
Jeff Brownc5df37c2012-09-13 11:45:07 -0700490 * Returns a combination of flags that describe the capabilities of the display.
491 *
492 * @return The display flags.
493 *
Jeff Brown77aebfd2012-10-01 21:07:03 -0700494 * @see #FLAG_SUPPORTS_PROTECTED_BUFFERS
Jeff Brownf0681b32012-10-23 17:35:57 -0700495 * @see #FLAG_SECURE
Jeff Browna506a6e2013-06-04 00:02:38 -0700496 * @see #FLAG_PRIVATE
Jeff Brownc5df37c2012-09-13 11:45:07 -0700497 */
498 public int getFlags() {
Jeff Brown92130f62012-10-24 21:28:33 -0700499 return mFlags;
500 }
501
502 /**
503 * Gets the display type.
504 *
505 * @return The display type.
506 *
507 * @see #TYPE_UNKNOWN
508 * @see #TYPE_BUILT_IN
509 * @see #TYPE_HDMI
510 * @see #TYPE_WIFI
511 * @see #TYPE_OVERLAY
Jeff Browna506a6e2013-06-04 00:02:38 -0700512 * @see #TYPE_VIRTUAL
Jeff Brown92130f62012-10-24 21:28:33 -0700513 * @hide
514 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100515 @UnsupportedAppUsage
Jeff Brown92130f62012-10-24 21:28:33 -0700516 public int getType() {
517 return mType;
518 }
519
520 /**
521 * Gets the display address, or null if none.
522 * Interpretation varies by display type.
523 *
524 * @return The display address.
525 * @hide
526 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100527 @UnsupportedAppUsage
Jeff Brown92130f62012-10-24 21:28:33 -0700528 public String getAddress() {
529 return mAddress;
Jeff Brownc5df37c2012-09-13 11:45:07 -0700530 }
531
532 /**
Jeff Browna506a6e2013-06-04 00:02:38 -0700533 * Gets the UID of the application that owns this display, or zero if it is
534 * owned by the system.
535 * <p>
536 * If the display is private, then only the owner can use it.
537 * </p>
538 *
539 * @hide
540 */
541 public int getOwnerUid() {
542 return mOwnerUid;
543 }
544
545 /**
546 * Gets the package name of the application that owns this display, or null if it is
547 * owned by the system.
548 * <p>
549 * If the display is private, then only the owner can use it.
550 * </p>
551 *
552 * @hide
553 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100554 @UnsupportedAppUsage
Jeff Browna506a6e2013-06-04 00:02:38 -0700555 public String getOwnerPackageName() {
556 return mOwnerPackageName;
557 }
558
559 /**
Jeff Brown98365d72012-08-19 20:30:52 -0700560 * Gets the compatibility info used by this display instance.
561 *
Craig Mautner48d0d182013-06-11 07:53:06 -0700562 * @return The display adjustments holder, or null if none is required.
Jeff Brown98365d72012-08-19 20:30:52 -0700563 * @hide
564 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100565 @UnsupportedAppUsage
Craig Mautner48d0d182013-06-11 07:53:06 -0700566 public DisplayAdjustments getDisplayAdjustments() {
Bryce Lee609bf652017-02-09 16:50:13 -0800567 if (mResources != null) {
568 final DisplayAdjustments currentAdjustements = mResources.getDisplayAdjustments();
569 if (!mDisplayAdjustments.equals(currentAdjustements)) {
570 mDisplayAdjustments = new DisplayAdjustments(currentAdjustements);
571 }
572 }
573
Craig Mautner48d0d182013-06-11 07:53:06 -0700574 return mDisplayAdjustments;
Jeff Brown98365d72012-08-19 20:30:52 -0700575 }
576
577 /**
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700578 * Gets the name of the display.
Jeff Brown92130f62012-10-24 21:28:33 -0700579 * <p>
580 * Note that some displays may be renamed by the user.
581 * </p>
582 *
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700583 * @return The display's name.
584 */
585 public String getName() {
Jeff Brown92130f62012-10-24 21:28:33 -0700586 synchronized (this) {
587 updateDisplayInfoLocked();
588 return mDisplayInfo.name;
589 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700590 }
591
592 /**
Jeff Brownbc68a592011-07-25 12:58:12 -0700593 * Gets the size of the display, in pixels.
Andrii Kulian5f57a3d2016-06-28 18:41:42 -0700594 * Value returned by this method does not necessarily represent the actual raw size
595 * (native resolution) of the display.
Jeff Brownbc68a592011-07-25 12:58:12 -0700596 * <p>
Andrii Kulian5f57a3d2016-06-28 18:41:42 -0700597 * 1. The returned size may be adjusted to exclude certain system decor elements
598 * that are always visible.
Jeff Brownbc68a592011-07-25 12:58:12 -0700599 * </p><p>
Andrii Kulian5f57a3d2016-06-28 18:41:42 -0700600 * 2. It may be scaled to provide compatibility with older applications that
Jeff Brownbc68a592011-07-25 12:58:12 -0700601 * were originally designed for smaller displays.
Andrii Kulian5f57a3d2016-06-28 18:41:42 -0700602 * </p><p>
603 * 3. It can be different depending on the WindowManager to which the display belongs.
604 * </p><p>
605 * - If requested from non-Activity context (e.g. Application context via
606 * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)})
607 * it will report the size of the entire display based on current rotation and with subtracted
608 * system decoration areas.
609 * </p><p>
610 * - If requested from activity (either using {@code getWindowManager()} or
611 * {@code (WindowManager) getSystemService(Context.WINDOW_SERVICE)}) resulting size will
612 * correspond to current app window size. In this case it can be smaller than physical size in
613 * multi-window mode.
614 * </p><p>
615 * Typically for the purposes of layout apps should make a request from activity context
616 * to obtain size available for the app content.
Jeff Brownbc68a592011-07-25 12:58:12 -0700617 * </p>
618 *
619 * @param outSize A {@link Point} object to receive the size information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800620 */
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700621 public void getSize(Point outSize) {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700622 synchronized (this) {
623 updateDisplayInfoLocked();
Bryce Lee609bf652017-02-09 16:50:13 -0800624 mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments());
Jeff Brownfa25bf52012-07-23 19:26:30 -0700625 outSize.x = mTempMetrics.widthPixels;
626 outSize.y = mTempMetrics.heightPixels;
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700627 }
628 }
Jeff Brownfa25bf52012-07-23 19:26:30 -0700629
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800630 /**
Jeff Brownbc68a592011-07-25 12:58:12 -0700631 * Gets the size of the display as a rectangle, in pixels.
632 *
633 * @param outSize A {@link Rect} object to receive the size information.
634 * @see #getSize(Point)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800635 */
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700636 public void getRectSize(Rect outSize) {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700637 synchronized (this) {
638 updateDisplayInfoLocked();
Bryce Lee609bf652017-02-09 16:50:13 -0800639 mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments());
Jeff Brownfa25bf52012-07-23 19:26:30 -0700640 outSize.set(0, 0, mTempMetrics.widthPixels, mTempMetrics.heightPixels);
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700641 }
642 }
643
644 /**
Dianne Hackborn68c33ca2012-04-19 14:51:25 -0700645 * Return the range of display sizes an application can expect to encounter
646 * under normal operation, as long as there is no physical change in screen
647 * size. This is basically the sizes you will see as the orientation
648 * changes, taking into account whatever screen decoration there is in
649 * each rotation. For example, the status bar is always at the top of the
650 * screen, so it will reduce the height both in landscape and portrait, and
651 * the smallest height returned here will be the smaller of the two.
652 *
653 * This is intended for applications to get an idea of the range of sizes
654 * they will encounter while going through device rotations, to provide a
655 * stable UI through rotation. The sizes here take into account all standard
656 * system decorations that reduce the size actually available to the
657 * application: the status bar, navigation bar, system bar, etc. It does
658 * <em>not</em> take into account more transient elements like an IME
659 * soft keyboard.
660 *
661 * @param outSmallestSize Filled in with the smallest width and height
662 * that the application will encounter, in pixels (not dp units). The x
663 * (width) dimension here directly corresponds to
664 * {@link android.content.res.Configuration#smallestScreenWidthDp
665 * Configuration.smallestScreenWidthDp}, except the value here is in raw
666 * screen pixels rather than dp units. Your application may of course
667 * still get smaller space yet if, for example, a soft keyboard is
668 * being displayed.
669 * @param outLargestSize Filled in with the largest width and height
670 * that the application will encounter, in pixels (not dp units). Your
671 * application may of course still get larger space than this if,
672 * for example, screen decorations like the status bar are being hidden.
673 */
674 public void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize) {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700675 synchronized (this) {
676 updateDisplayInfoLocked();
677 outSmallestSize.x = mDisplayInfo.smallestNominalAppWidth;
678 outSmallestSize.y = mDisplayInfo.smallestNominalAppHeight;
679 outLargestSize.x = mDisplayInfo.largestNominalAppWidth;
680 outLargestSize.y = mDisplayInfo.largestNominalAppHeight;
Dianne Hackborn68c33ca2012-04-19 14:51:25 -0700681 }
682 }
683
684 /**
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700685 * Return the maximum screen size dimension that will happen. This is
686 * mostly for wallpapers.
687 * @hide
688 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100689 @UnsupportedAppUsage
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700690 public int getMaximumSizeDimension() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700691 synchronized (this) {
692 updateDisplayInfoLocked();
693 return Math.max(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight);
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700694 }
695 }
696
697 /**
698 * @deprecated Use {@link #getSize(Point)} instead.
699 */
700 @Deprecated
701 public int getWidth() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700702 synchronized (this) {
703 updateCachedAppSizeIfNeededLocked();
704 return mCachedAppWidthCompat;
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700705 }
706 }
707
708 /**
709 * @deprecated Use {@link #getSize(Point)} instead.
710 */
711 @Deprecated
712 public int getHeight() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700713 synchronized (this) {
714 updateCachedAppSizeIfNeededLocked();
715 return mCachedAppHeightCompat;
Dianne Hackbornac8dea12011-04-20 18:18:51 -0700716 }
717 }
718
Jeff Brownbc68a592011-07-25 12:58:12 -0700719 /**
Dianne Hackbornc652de82013-02-15 16:32:56 -0800720 * @hide
721 * Return a rectangle defining the insets of the overscan region of the display.
722 * Each field of the rectangle is the number of pixels the overscan area extends
723 * into the display on that side.
724 */
725 public void getOverscanInsets(Rect outRect) {
726 synchronized (this) {
727 updateDisplayInfoLocked();
728 outRect.set(mDisplayInfo.overscanLeft, mDisplayInfo.overscanTop,
729 mDisplayInfo.overscanRight, mDisplayInfo.overscanBottom);
730 }
731 }
732
733 /**
Dianne Hackborn5cb70b52010-02-25 17:01:14 -0800734 * Returns the rotation of the screen from its "natural" orientation.
735 * The returned value may be {@link Surface#ROTATION_0 Surface.ROTATION_0}
736 * (no rotation), {@link Surface#ROTATION_90 Surface.ROTATION_90},
737 * {@link Surface#ROTATION_180 Surface.ROTATION_180}, or
738 * {@link Surface#ROTATION_270 Surface.ROTATION_270}. For
739 * example, if a device has a naturally tall screen, and the user has
740 * turned it on its side to go into a landscape orientation, the value
741 * returned here may be either {@link Surface#ROTATION_90 Surface.ROTATION_90}
742 * or {@link Surface#ROTATION_270 Surface.ROTATION_270} depending on
743 * the direction it was turned. The angle is the rotation of the drawn
744 * graphics on the screen, which is the opposite direction of the physical
745 * rotation of the device. For example, if the device is rotated 90
746 * degrees counter-clockwise, to compensate rendering will be rotated by
747 * 90 degrees clockwise and thus the returned value here will be
748 * {@link Surface#ROTATION_90 Surface.ROTATION_90}.
749 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700750 @Surface.Rotation
Dianne Hackborn5cb70b52010-02-25 17:01:14 -0800751 public int getRotation() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700752 synchronized (this) {
753 updateDisplayInfoLocked();
754 return mDisplayInfo.rotation;
755 }
Dianne Hackborn5cb70b52010-02-25 17:01:14 -0800756 }
Jeff Brownfa25bf52012-07-23 19:26:30 -0700757
Dianne Hackborn5cb70b52010-02-25 17:01:14 -0800758 /**
Joe Onorato4c904a32010-02-26 12:35:55 -0800759 * @deprecated use {@link #getRotation}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 * @return orientation of this display.
761 */
Jeff Brownfa25bf52012-07-23 19:26:30 -0700762 @Deprecated
Tor Norbyed9273d62013-05-30 15:59:53 -0700763 @Surface.Rotation
Jeff Brownfa25bf52012-07-23 19:26:30 -0700764 public int getOrientation() {
765 return getRotation();
766 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800767
768 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -0700769 * Gets the pixel format of the display.
770 * @return One of the constants defined in {@link android.graphics.PixelFormat}.
771 *
772 * @deprecated This method is no longer supported.
773 * The result is always {@link PixelFormat#RGBA_8888}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800774 */
Jeff Brownfa25bf52012-07-23 19:26:30 -0700775 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800776 public int getPixelFormat() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700777 return PixelFormat.RGBA_8888;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800778 }
Jeff Brownfa25bf52012-07-23 19:26:30 -0700779
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800780 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -0700781 * Gets the refresh rate of this display in frames per second.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800782 */
783 public float getRefreshRate() {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700784 synchronized (this) {
785 updateDisplayInfoLocked();
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700786 return mDisplayInfo.getMode().getRefreshRate();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700787 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788 }
Jeff Brownfa25bf52012-07-23 19:26:30 -0700789
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 /**
Michael Wright3f145a22014-07-22 19:46:03 -0700791 * Get the supported refresh rates of this display in frames per second.
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700792 * <p>
793 * This method only returns refresh rates for the display's default modes. For more options, use
794 * {@link #getSupportedModes()}.
795 *
796 * @deprecated use {@link #getSupportedModes()} instead
Michael Wright3f145a22014-07-22 19:46:03 -0700797 */
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700798 @Deprecated
Michael Wright3f145a22014-07-22 19:46:03 -0700799 public float[] getSupportedRefreshRates() {
800 synchronized (this) {
801 updateDisplayInfoLocked();
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700802 return mDisplayInfo.getDefaultRefreshRates();
803 }
804 }
805
806 /**
807 * Returns the active mode of the display.
808 */
809 public Mode getMode() {
810 synchronized (this) {
811 updateDisplayInfoLocked();
812 return mDisplayInfo.getMode();
813 }
814 }
815
816 /**
817 * Gets the supported modes of this display.
818 */
819 public Mode[] getSupportedModes() {
820 synchronized (this) {
821 updateDisplayInfoLocked();
822 final Display.Mode[] modes = mDisplayInfo.supportedModes;
823 return Arrays.copyOf(modes, modes.length);
Michael Wright3f145a22014-07-22 19:46:03 -0700824 }
825 }
826
827 /**
Michael Wright1c9977b2016-07-12 13:30:10 -0700828 * Request the display applies a color mode.
Michael Wright58e829f2015-09-15 00:13:26 +0100829 * @hide
830 */
Michael Wright1c9977b2016-07-12 13:30:10 -0700831 @RequiresPermission(CONFIGURE_DISPLAY_COLOR_MODE)
832 public void requestColorMode(int colorMode) {
833 mGlobal.requestColorMode(mDisplayId, colorMode);
Michael Wright58e829f2015-09-15 00:13:26 +0100834 }
835
836 /**
Michael Wright1c9977b2016-07-12 13:30:10 -0700837 * Returns the active color mode of this display
Michael Wright58e829f2015-09-15 00:13:26 +0100838 * @hide
839 */
Michael Wright1c9977b2016-07-12 13:30:10 -0700840 public int getColorMode() {
Michael Wright58e829f2015-09-15 00:13:26 +0100841 synchronized (this) {
842 updateDisplayInfoLocked();
Michael Wright1c9977b2016-07-12 13:30:10 -0700843 return mDisplayInfo.colorMode;
Michael Wright58e829f2015-09-15 00:13:26 +0100844 }
845 }
846
847 /**
Andrii Kulian250d6532017-02-08 23:30:45 -0800848 * @hide
849 * Get current remove mode of the display - what actions should be performed with the display's
850 * content when it is removed. Default behavior for public displays in this case is to move all
851 * activities to the primary display and make it focused. For private display - destroy all
852 * activities.
853 *
854 * @see #REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY
855 * @see #REMOVE_MODE_DESTROY_CONTENT
856 */
857 public int getRemoveMode() {
858 return mDisplayInfo.removeMode;
859 }
860
861 /**
Ronghua Wuf173c322016-02-29 13:57:18 -0800862 * Returns the display's HDR capabilities.
Romain Guy6d228c22017-01-20 18:41:06 -0800863 *
864 * @see #isHdr()
Ronghua Wuf173c322016-02-29 13:57:18 -0800865 */
866 public HdrCapabilities getHdrCapabilities() {
Michael Wright9ff94c02016-03-30 18:05:40 -0700867 synchronized (this) {
868 updateDisplayInfoLocked();
869 return mDisplayInfo.hdrCapabilities;
870 }
Ronghua Wuf173c322016-02-29 13:57:18 -0800871 }
872
873 /**
Romain Guy6d228c22017-01-20 18:41:06 -0800874 * Returns whether this display supports any HDR type.
875 *
876 * @see #getHdrCapabilities()
877 * @see HdrCapabilities#getSupportedHdrTypes()
878 */
879 public boolean isHdr() {
880 synchronized (this) {
881 updateDisplayInfoLocked();
Romain Guy408afbf2017-01-25 10:23:03 -0800882 return mDisplayInfo.isHdr();
Romain Guy6d228c22017-01-20 18:41:06 -0800883 }
884 }
885
886 /**
887 * Returns whether this display can be used to display wide color gamut content.
Romain Guye89d0bb2017-06-20 12:23:42 -0700888 * This does not necessarily mean the device itself can render wide color gamut
889 * content. To ensure wide color gamut content can be produced, refer to
890 * {@link Configuration#isScreenWideColorGamut()}.
Romain Guy6d228c22017-01-20 18:41:06 -0800891 */
892 public boolean isWideColorGamut() {
893 synchronized (this) {
894 updateDisplayInfoLocked();
Romain Guy408afbf2017-01-25 10:23:03 -0800895 return mDisplayInfo.isWideColorGamut();
Romain Guy6d228c22017-01-20 18:41:06 -0800896 }
897 }
898
899 /**
Michael Wright1c9977b2016-07-12 13:30:10 -0700900 * Gets the supported color modes of this device.
Michael Wright58e829f2015-09-15 00:13:26 +0100901 * @hide
902 */
Michael Wright1c9977b2016-07-12 13:30:10 -0700903 public int[] getSupportedColorModes() {
Michael Wright58e829f2015-09-15 00:13:26 +0100904 synchronized (this) {
905 updateDisplayInfoLocked();
Michael Wright1c9977b2016-07-12 13:30:10 -0700906 int[] colorModes = mDisplayInfo.supportedColorModes;
907 return Arrays.copyOf(colorModes, colorModes.length);
Michael Wright58e829f2015-09-15 00:13:26 +0100908 }
909 }
910
911 /**
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700912 * Gets the app VSYNC offset, in nanoseconds. This is a positive value indicating
913 * the phase offset of the VSYNC events provided by Choreographer relative to the
914 * display refresh. For example, if Choreographer reports that the refresh occurred
915 * at time N, it actually occurred at (N - appVsyncOffset).
916 * <p>
917 * Apps generally do not need to be aware of this. It's only useful for fine-grained
918 * A/V synchronization.
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700919 */
920 public long getAppVsyncOffsetNanos() {
921 synchronized (this) {
922 updateDisplayInfoLocked();
923 return mDisplayInfo.appVsyncOffsetNanos;
924 }
925 }
926
927 /**
928 * This is how far in advance a buffer must be queued for presentation at
929 * a given time. If you want a buffer to appear on the screen at
930 * time N, you must submit the buffer before (N - presentationDeadline).
931 * <p>
932 * The desired presentation time for GLES rendering may be set with
933 * {@link android.opengl.EGLExt#eglPresentationTimeANDROID}. For video decoding, use
934 * {@link android.media.MediaCodec#releaseOutputBuffer(int, long)}. Times are
935 * expressed in nanoseconds, using the system monotonic clock
936 * ({@link System#nanoTime}).
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700937 */
938 public long getPresentationDeadlineNanos() {
939 synchronized (this) {
940 updateDisplayInfoLocked();
941 return mDisplayInfo.presentationDeadlineNanos;
942 }
943 }
944
945 /**
Jeff Brownbc68a592011-07-25 12:58:12 -0700946 * Gets display metrics that describe the size and density of this display.
Jeff Brownbc68a592011-07-25 12:58:12 -0700947 * The size returned by this method does not necessarily represent the
Andrii Kuliana4bb9d32016-03-11 11:52:22 -0800948 * actual raw size (native resolution) of the display.
949 * <p>
950 * 1. The returned size may be adjusted to exclude certain system decor elements
951 * that are always visible.
952 * </p><p>
953 * 2. It may be scaled to provide compatibility with older applications that
Jeff Brownbc68a592011-07-25 12:58:12 -0700954 * were originally designed for smaller displays.
Andrii Kuliana4bb9d32016-03-11 11:52:22 -0800955 * </p><p>
956 * 3. It can be different depending on the WindowManager to which the display belongs.
Andrii Kulian5f57a3d2016-06-28 18:41:42 -0700957 * </p><p>
Andrii Kuliana4bb9d32016-03-11 11:52:22 -0800958 * - If requested from non-Activity context (e.g. Application context via
959 * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)})
Andrii Kulian5f57a3d2016-06-28 18:41:42 -0700960 * metrics will report the size of the entire display based on current rotation and with
961 * subtracted system decoration areas.
962 * </p><p>
963 * - If requested from activity (either using {@code getWindowManager()} or
964 * {@code (WindowManager) getSystemService(Context.WINDOW_SERVICE)}) resulting metrics will
965 * correspond to current app window metrics. In this case the size can be smaller than physical
966 * size in multi-window mode.
Jeff Brownbc68a592011-07-25 12:58:12 -0700967 * </p>
968 *
969 * @param outMetrics A {@link DisplayMetrics} object to receive the metrics.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800970 */
971 public void getMetrics(DisplayMetrics outMetrics) {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700972 synchronized (this) {
973 updateDisplayInfoLocked();
Bryce Lee609bf652017-02-09 16:50:13 -0800974 mDisplayInfo.getAppMetrics(outMetrics, getDisplayAdjustments());
Dianne Hackborn68066c22011-04-21 17:26:39 -0700975 }
Jeff Brownfa25bf52012-07-23 19:26:30 -0700976 }
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700977
Jeff Brownfa25bf52012-07-23 19:26:30 -0700978 /**
979 * Gets the real size of the display without subtracting any window decor or
980 * applying any compatibility scale factors.
981 * <p>
982 * The size is adjusted based on the current rotation of the display.
983 * </p><p>
984 * The real size may be smaller than the physical size of the screen when the
Andrii Kuliancd097992017-03-23 18:31:59 -0700985 * window manager is emulating a smaller display (using adb shell wm size).
Jeff Brownfa25bf52012-07-23 19:26:30 -0700986 * </p>
987 *
988 * @param outSize Set to the real size of the display.
989 */
990 public void getRealSize(Point outSize) {
991 synchronized (this) {
992 updateDisplayInfoLocked();
993 outSize.x = mDisplayInfo.logicalWidth;
994 outSize.y = mDisplayInfo.logicalHeight;
995 }
Dianne Hackborn68066c22011-04-21 17:26:39 -0700996 }
997
998 /**
Jeff Brownbc68a592011-07-25 12:58:12 -0700999 * Gets display metrics based on the real size of this display.
Jeff Brownfa25bf52012-07-23 19:26:30 -07001000 * <p>
1001 * The size is adjusted based on the current rotation of the display.
1002 * </p><p>
1003 * The real size may be smaller than the physical size of the screen when the
Andrii Kuliana4bb9d32016-03-11 11:52:22 -08001004 * window manager is emulating a smaller display (using adb shell wm size).
Jeff Brownfa25bf52012-07-23 19:26:30 -07001005 * </p>
1006 *
1007 * @param outMetrics A {@link DisplayMetrics} object to receive the metrics.
Dianne Hackborn68066c22011-04-21 17:26:39 -07001008 */
1009 public void getRealMetrics(DisplayMetrics outMetrics) {
Jeff Brownfa25bf52012-07-23 19:26:30 -07001010 synchronized (this) {
1011 updateDisplayInfoLocked();
Craig Mautner48d0d182013-06-11 07:53:06 -07001012 mDisplayInfo.getLogicalMetrics(outMetrics,
Andrii Kuliana4bb9d32016-03-11 11:52:22 -08001013 CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
Jeff Brownbc68a592011-07-25 12:58:12 -07001014 }
Dianne Hackborn68066c22011-04-21 17:26:39 -07001015 }
1016
Jeff Browna506a6e2013-06-04 00:02:38 -07001017 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001018 * Gets the state of the display, such as whether it is on or off.
1019 *
1020 * @return The state of the display: one of {@link #STATE_OFF}, {@link #STATE_ON},
Chris Phoenix10a4a642017-09-25 13:21:00 -07001021 * {@link #STATE_DOZE}, {@link #STATE_DOZE_SUSPEND}, {@link #STATE_ON_SUSPEND}, or
Santos Cordon3107d292016-09-20 15:50:35 -07001022 * {@link #STATE_UNKNOWN}.
Jeff Brown037c33e2014-04-09 00:31:55 -07001023 */
1024 public int getState() {
1025 synchronized (this) {
1026 updateDisplayInfoLocked();
1027 return mIsValid ? mDisplayInfo.state : STATE_UNKNOWN;
1028 }
1029 }
1030
1031 /**
Jeff Browna506a6e2013-06-04 00:02:38 -07001032 * Returns true if the specified UID has access to this display.
1033 * @hide
1034 */
1035 public boolean hasAccess(int uid) {
1036 return Display.hasAccess(uid, mFlags, mOwnerUid);
1037 }
1038
1039 /** @hide */
1040 public static boolean hasAccess(int uid, int flags, int ownerUid) {
1041 return (flags & Display.FLAG_PRIVATE) == 0
1042 || uid == ownerUid
1043 || uid == Process.SYSTEM_UID
1044 || uid == 0;
1045 }
1046
Jeff Brown69b07162013-11-07 00:30:16 -08001047 /**
1048 * Returns true if the display is a public presentation display.
1049 * @hide
1050 */
1051 public boolean isPublicPresentation() {
1052 return (mFlags & (Display.FLAG_PRIVATE | Display.FLAG_PRESENTATION)) ==
1053 Display.FLAG_PRESENTATION;
1054 }
1055
Jeff Brownfa25bf52012-07-23 19:26:30 -07001056 private void updateDisplayInfoLocked() {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001057 // Note: The display manager caches display info objects on our behalf.
1058 DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId);
1059 if (newInfo == null) {
1060 // Preserve the old mDisplayInfo after the display is removed.
1061 if (mIsValid) {
1062 mIsValid = false;
1063 if (DEBUG) {
1064 Log.d(TAG, "Logical display " + mDisplayId + " was removed.");
1065 }
1066 }
1067 } else {
1068 // Use the new display info. (It might be the same object if nothing changed.)
1069 mDisplayInfo = newInfo;
1070 if (!mIsValid) {
1071 mIsValid = true;
1072 if (DEBUG) {
1073 Log.d(TAG, "Logical display " + mDisplayId + " was recreated.");
1074 }
1075 }
Jeff Brownfa25bf52012-07-23 19:26:30 -07001076 }
Jeff Brownbc68a592011-07-25 12:58:12 -07001077 }
1078
Jeff Brownfa25bf52012-07-23 19:26:30 -07001079 private void updateCachedAppSizeIfNeededLocked() {
1080 long now = SystemClock.uptimeMillis();
1081 if (now > mLastCachedAppSizeUpdate + CACHED_APP_SIZE_DURATION_MILLIS) {
1082 updateDisplayInfoLocked();
Bryce Lee609bf652017-02-09 16:50:13 -08001083 mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments());
Jeff Brownfa25bf52012-07-23 19:26:30 -07001084 mCachedAppWidthCompat = mTempMetrics.widthPixels;
1085 mCachedAppHeightCompat = mTempMetrics.heightPixels;
1086 mLastCachedAppSizeUpdate = now;
1087 }
Jeff Brownbc68a592011-07-25 12:58:12 -07001088 }
Jeff Brownbf5740e2012-08-19 23:20:02 -07001089
1090 // For debugging purposes
1091 @Override
1092 public String toString() {
1093 synchronized (this) {
1094 updateDisplayInfoLocked();
Bryce Lee609bf652017-02-09 16:50:13 -08001095 mDisplayInfo.getAppMetrics(mTempMetrics, getDisplayAdjustments());
Jeff Brownbf5740e2012-08-19 23:20:02 -07001096 return "Display id " + mDisplayId + ": " + mDisplayInfo
Jeff Brownbd6e1502012-08-28 03:27:37 -07001097 + ", " + mTempMetrics + ", isValid=" + mIsValid;
Jeff Brownbf5740e2012-08-19 23:20:02 -07001098 }
1099 }
Jeff Brown92130f62012-10-24 21:28:33 -07001100
1101 /**
1102 * @hide
1103 */
1104 public static String typeToString(int type) {
1105 switch (type) {
1106 case TYPE_UNKNOWN:
1107 return "UNKNOWN";
1108 case TYPE_BUILT_IN:
1109 return "BUILT_IN";
1110 case TYPE_HDMI:
1111 return "HDMI";
1112 case TYPE_WIFI:
1113 return "WIFI";
1114 case TYPE_OVERLAY:
1115 return "OVERLAY";
Jeff Browna506a6e2013-06-04 00:02:38 -07001116 case TYPE_VIRTUAL:
1117 return "VIRTUAL";
Jeff Brown92130f62012-10-24 21:28:33 -07001118 default:
1119 return Integer.toString(type);
1120 }
1121 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001122
Jeff Brown037c33e2014-04-09 00:31:55 -07001123 /**
1124 * @hide
1125 */
1126 public static String stateToString(int state) {
1127 switch (state) {
1128 case STATE_UNKNOWN:
1129 return "UNKNOWN";
1130 case STATE_OFF:
1131 return "OFF";
1132 case STATE_ON:
1133 return "ON";
Jeff Brown5dc21912014-07-17 18:50:18 -07001134 case STATE_DOZE:
1135 return "DOZE";
1136 case STATE_DOZE_SUSPEND:
1137 return "DOZE_SUSPEND";
Santos Cordon3107d292016-09-20 15:50:35 -07001138 case STATE_VR:
1139 return "VR";
Chris Phoenix10a4a642017-09-25 13:21:00 -07001140 case STATE_ON_SUSPEND:
1141 return "ON_SUSPEND";
Jeff Brown037c33e2014-04-09 00:31:55 -07001142 default:
1143 return Integer.toString(state);
1144 }
1145 }
Jeff Brown970d4132014-07-19 11:33:47 -07001146
1147 /**
1148 * Returns true if display updates may be suspended while in the specified
Chris Phoenix10a4a642017-09-25 13:21:00 -07001149 * display power state. In SUSPEND states, updates are absolutely forbidden.
Jeff Brown970d4132014-07-19 11:33:47 -07001150 * @hide
1151 */
1152 public static boolean isSuspendedState(int state) {
Chris Phoenix10a4a642017-09-25 13:21:00 -07001153 return state == STATE_OFF || state == STATE_DOZE_SUSPEND || state == STATE_ON_SUSPEND;
Jeff Brown970d4132014-07-19 11:33:47 -07001154 }
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -07001155
1156 /**
Michael Wright05e76fe2017-07-20 18:18:33 +01001157 * Returns true if the display may be in a reduced operating mode while in the
1158 * specified display power state.
1159 * @hide
1160 */
1161 public static boolean isDozeState(int state) {
1162 return state == STATE_DOZE || state == STATE_DOZE_SUSPEND;
1163 }
1164
1165 /**
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -07001166 * A mode supported by a given display.
1167 *
1168 * @see Display#getSupportedModes()
1169 */
1170 public static final class Mode implements Parcelable {
1171 /**
1172 * @hide
1173 */
1174 public static final Mode[] EMPTY_ARRAY = new Mode[0];
1175
1176 private final int mModeId;
1177 private final int mWidth;
1178 private final int mHeight;
1179 private final float mRefreshRate;
1180
1181 /**
1182 * @hide
1183 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001184 @UnsupportedAppUsage
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -07001185 public Mode(int modeId, int width, int height, float refreshRate) {
1186 mModeId = modeId;
1187 mWidth = width;
1188 mHeight = height;
1189 mRefreshRate = refreshRate;
1190 }
1191
1192 /**
1193 * Returns this mode's id.
1194 */
1195 public int getModeId() {
1196 return mModeId;
1197 }
1198
1199 /**
1200 * Returns the physical width of the display in pixels when configured in this mode's
1201 * resolution.
1202 * <p>
1203 * Note that due to application UI scaling, the number of pixels made available to
1204 * applications when the mode is active (as reported by {@link Display#getWidth()} may
1205 * differ from the mode's actual resolution (as reported by this function).
1206 * <p>
1207 * For example, applications running on a 4K display may have their UI laid out and rendered
1208 * in 1080p and then scaled up. Applications can take advantage of the extra resolution by
1209 * rendering content through a {@link android.view.SurfaceView} using full size buffers.
1210 */
1211 public int getPhysicalWidth() {
1212 return mWidth;
1213 }
1214
1215 /**
1216 * Returns the physical height of the display in pixels when configured in this mode's
1217 * resolution.
1218 * <p>
1219 * Note that due to application UI scaling, the number of pixels made available to
1220 * applications when the mode is active (as reported by {@link Display#getHeight()} may
1221 * differ from the mode's actual resolution (as reported by this function).
1222 * <p>
1223 * For example, applications running on a 4K display may have their UI laid out and rendered
1224 * in 1080p and then scaled up. Applications can take advantage of the extra resolution by
1225 * rendering content through a {@link android.view.SurfaceView} using full size buffers.
1226 */
1227 public int getPhysicalHeight() {
1228 return mHeight;
1229 }
1230
1231 /**
1232 * Returns the refresh rate in frames per second.
1233 */
1234 public float getRefreshRate() {
1235 return mRefreshRate;
1236 }
1237
1238 /**
1239 * Returns {@code true} if this mode matches the given parameters.
1240 *
1241 * @hide
1242 */
1243 public boolean matches(int width, int height, float refreshRate) {
1244 return mWidth == width &&
1245 mHeight == height &&
1246 Float.floatToIntBits(mRefreshRate) == Float.floatToIntBits(refreshRate);
1247 }
1248
1249 @Override
1250 public boolean equals(Object other) {
1251 if (this == other) {
1252 return true;
1253 }
1254 if (!(other instanceof Mode)) {
1255 return false;
1256 }
1257 Mode that = (Mode) other;
1258 return mModeId == that.mModeId && matches(that.mWidth, that.mHeight, that.mRefreshRate);
1259 }
1260
1261 @Override
1262 public int hashCode() {
1263 int hash = 1;
1264 hash = hash * 17 + mModeId;
1265 hash = hash * 17 + mWidth;
1266 hash = hash * 17 + mHeight;
1267 hash = hash * 17 + Float.floatToIntBits(mRefreshRate);
1268 return hash;
1269 }
1270
1271 @Override
1272 public String toString() {
1273 return new StringBuilder("{")
1274 .append("id=").append(mModeId)
1275 .append(", width=").append(mWidth)
1276 .append(", height=").append(mHeight)
1277 .append(", fps=").append(mRefreshRate)
1278 .append("}")
1279 .toString();
1280 }
1281
1282 @Override
1283 public int describeContents() {
1284 return 0;
1285 }
1286
1287 private Mode(Parcel in) {
1288 this(in.readInt(), in.readInt(), in.readInt(), in.readFloat());
1289 }
1290
1291 @Override
1292 public void writeToParcel(Parcel out, int parcelableFlags) {
1293 out.writeInt(mModeId);
1294 out.writeInt(mWidth);
1295 out.writeInt(mHeight);
1296 out.writeFloat(mRefreshRate);
1297 }
1298
1299 @SuppressWarnings("hiding")
1300 public static final Parcelable.Creator<Mode> CREATOR
1301 = new Parcelable.Creator<Mode>() {
1302 @Override
1303 public Mode createFromParcel(Parcel in) {
1304 return new Mode(in);
1305 }
1306
1307 @Override
1308 public Mode[] newArray(int size) {
1309 return new Mode[size];
1310 }
1311 };
1312 }
Michael Wright58e829f2015-09-15 00:13:26 +01001313
1314 /**
Ronghua Wuf173c322016-02-29 13:57:18 -08001315 * Encapsulates the HDR capabilities of a given display.
1316 * For example, what HDR types it supports and details about the desired luminance data.
1317 * <p>You can get an instance for a given {@link Display} object with
1318 * {@link Display#getHdrCapabilities getHdrCapabilities()}.
Ronghua Wuf173c322016-02-29 13:57:18 -08001319 */
1320 public static final class HdrCapabilities implements Parcelable {
1321 /**
1322 * Invalid luminance value.
1323 */
1324 public static final float INVALID_LUMINANCE = -1;
1325 /**
1326 * Dolby Vision high dynamic range (HDR) display.
1327 */
1328 public static final int HDR_TYPE_DOLBY_VISION = 1;
1329 /**
1330 * HDR10 display.
1331 */
1332 public static final int HDR_TYPE_HDR10 = 2;
1333 /**
1334 * Hybrid Log-Gamma HDR display.
1335 */
1336 public static final int HDR_TYPE_HLG = 3;
1337
Hangyu Kuangda802f52016-04-06 18:02:17 -07001338 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07001339 @IntDef(prefix = { "HDR_TYPE_" }, value = {
1340 HDR_TYPE_DOLBY_VISION,
1341 HDR_TYPE_HDR10,
1342 HDR_TYPE_HLG,
Ronghua Wuf173c322016-02-29 13:57:18 -08001343 })
1344 @Retention(RetentionPolicy.SOURCE)
1345 public @interface HdrType {}
1346
1347 private @HdrType int[] mSupportedHdrTypes = new int[0];
1348 private float mMaxLuminance = INVALID_LUMINANCE;
1349 private float mMaxAverageLuminance = INVALID_LUMINANCE;
1350 private float mMinLuminance = INVALID_LUMINANCE;
1351
Hangyu Kuangda802f52016-04-06 18:02:17 -07001352 /**
1353 * @hide
1354 */
Ronghua Wuf173c322016-02-29 13:57:18 -08001355 public HdrCapabilities() {
1356 }
1357
Hangyu Kuang1e7d1aa2016-05-17 14:21:01 -07001358 /**
1359 * @hide
1360 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001361 @UnsupportedAppUsage
Hangyu Kuang54ac2192016-04-25 13:22:02 -07001362 public HdrCapabilities(int[] supportedHdrTypes, float maxLuminance,
1363 float maxAverageLuminance, float minLuminance) {
1364 mSupportedHdrTypes = supportedHdrTypes;
1365 mMaxLuminance = maxLuminance;
1366 mMaxAverageLuminance = maxAverageLuminance;
1367 mMinLuminance = minLuminance;
1368 }
1369
Ronghua Wuf173c322016-02-29 13:57:18 -08001370 /**
1371 * Gets the supported HDR types of this display.
1372 * Returns empty array if HDR is not supported by the display.
1373 */
1374 public @HdrType int[] getSupportedHdrTypes() {
1375 return mSupportedHdrTypes;
1376 }
1377 /**
1378 * Returns the desired content max luminance data in cd/m2 for this display.
1379 */
1380 public float getDesiredMaxLuminance() {
1381 return mMaxLuminance;
1382 }
1383 /**
1384 * Returns the desired content max frame-average luminance data in cd/m2 for this display.
1385 */
1386 public float getDesiredMaxAverageLuminance() {
1387 return mMaxAverageLuminance;
1388 }
1389 /**
1390 * Returns the desired content min luminance data in cd/m2 for this display.
1391 */
1392 public float getDesiredMinLuminance() {
1393 return mMinLuminance;
1394 }
1395
Michael Wright16ae0422016-07-26 18:18:53 +01001396 @Override
1397 public boolean equals(Object other) {
1398 if (this == other) {
1399 return true;
1400 }
1401
1402 if (!(other instanceof HdrCapabilities)) {
1403 return false;
1404 }
1405 HdrCapabilities that = (HdrCapabilities) other;
1406
1407 return Arrays.equals(mSupportedHdrTypes, that.mSupportedHdrTypes)
1408 && mMaxLuminance == that.mMaxLuminance
1409 && mMaxAverageLuminance == that.mMaxAverageLuminance
1410 && mMinLuminance == that.mMinLuminance;
1411 }
1412
1413 @Override
1414 public int hashCode() {
1415 int hash = 23;
1416 hash = hash * 17 + Arrays.hashCode(mSupportedHdrTypes);
1417 hash = hash * 17 + Float.floatToIntBits(mMaxLuminance);
1418 hash = hash * 17 + Float.floatToIntBits(mMaxAverageLuminance);
1419 hash = hash * 17 + Float.floatToIntBits(mMinLuminance);
1420 return hash;
1421 }
1422
Ronghua Wuf173c322016-02-29 13:57:18 -08001423 public static final Creator<HdrCapabilities> CREATOR = new Creator<HdrCapabilities>() {
1424 @Override
1425 public HdrCapabilities createFromParcel(Parcel source) {
1426 return new HdrCapabilities(source);
1427 }
1428
1429 @Override
1430 public HdrCapabilities[] newArray(int size) {
1431 return new HdrCapabilities[size];
1432 }
1433 };
1434
1435 private HdrCapabilities(Parcel source) {
1436 readFromParcel(source);
1437 }
1438
Hangyu Kuangda802f52016-04-06 18:02:17 -07001439 /**
1440 * @hide
1441 */
Ronghua Wuf173c322016-02-29 13:57:18 -08001442 public void readFromParcel(Parcel source) {
1443 int types = source.readInt();
1444 mSupportedHdrTypes = new int[types];
1445 for (int i = 0; i < types; ++i) {
1446 mSupportedHdrTypes[i] = source.readInt();
1447 }
1448 mMaxLuminance = source.readFloat();
1449 mMaxAverageLuminance = source.readFloat();
1450 mMinLuminance = source.readFloat();
1451 }
1452
1453 @Override
1454 public void writeToParcel(Parcel dest, int flags) {
1455 dest.writeInt(mSupportedHdrTypes.length);
1456 for (int i = 0; i < mSupportedHdrTypes.length; ++i) {
1457 dest.writeInt(mSupportedHdrTypes[i]);
1458 }
1459 dest.writeFloat(mMaxLuminance);
1460 dest.writeFloat(mMaxAverageLuminance);
1461 dest.writeFloat(mMinLuminance);
1462 }
1463
1464 @Override
1465 public int describeContents() {
1466 return 0;
1467 }
1468 }
Jeff Brown037c33e2014-04-09 00:31:55 -07001469}