blob: ecf45b446e11abd604392900fc16e5ec77c0e2e3 [file] [log] [blame]
Jeff Brownfa25bf52012-07-23 19:26:30 -07001/*
2 * Copyright (C) 2012 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
19import android.content.res.CompatibilityInfo;
Wale Ogunwale7c726682015-02-06 17:34:28 -080020import android.content.res.Configuration;
Jeff Brownfa25bf52012-07-23 19:26:30 -070021import android.os.Parcel;
22import android.os.Parcelable;
23import android.util.DisplayMetrics;
24
Michael Wright3f145a22014-07-22 19:46:03 -070025import java.util.Arrays;
26
27import libcore.util.EmptyArray;
Jeff Brown4ed8fe72012-08-30 18:18:29 -070028import libcore.util.Objects;
29
Jeff Brownfa25bf52012-07-23 19:26:30 -070030/**
31 * Describes the characteristics of a particular logical display.
32 * @hide
33 */
34public final class DisplayInfo implements Parcelable {
35 /**
Jeff Brown4ed8fe72012-08-30 18:18:29 -070036 * The surface flinger layer stack associated with this logical display.
37 */
38 public int layerStack;
39
40 /**
Jeff Brownc5df37c2012-09-13 11:45:07 -070041 * Display flags.
42 */
43 public int flags;
44
45 /**
Jeff Brown92130f62012-10-24 21:28:33 -070046 * Display type.
47 */
48 public int type;
49
50 /**
51 * Display address, or null if none.
52 * Interpretation varies by display type.
53 */
54 public String address;
55
56 /**
Jeff Brown4ed8fe72012-08-30 18:18:29 -070057 * The human-readable name of the display.
58 */
59 public String name;
60
61 /**
Wale Ogunwale361ca212014-11-20 11:42:38 -080062 * Unique identifier for the display. Shouldn't be displayed to the user.
63 */
64 public String uniqueId;
65
66 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -070067 * The width of the portion of the display that is available to applications, in pixels.
68 * Represents the size of the display minus any system decorations.
69 */
70 public int appWidth;
71
72 /**
73 * The height of the portion of the display that is available to applications, in pixels.
74 * Represents the size of the display minus any system decorations.
75 */
76 public int appHeight;
77
78 /**
79 * The smallest value of {@link #appWidth} that an application is likely to encounter,
80 * in pixels, excepting cases where the width may be even smaller due to the presence
81 * of a soft keyboard, for example.
82 */
83 public int smallestNominalAppWidth;
84
85 /**
86 * The smallest value of {@link #appHeight} that an application is likely to encounter,
87 * in pixels, excepting cases where the height may be even smaller due to the presence
88 * of a soft keyboard, for example.
89 */
90 public int smallestNominalAppHeight;
91
92 /**
93 * The largest value of {@link #appWidth} that an application is likely to encounter,
94 * in pixels, excepting cases where the width may be even larger due to system decorations
95 * such as the status bar being hidden, for example.
96 */
97 public int largestNominalAppWidth;
98
99 /**
100 * The largest value of {@link #appHeight} that an application is likely to encounter,
101 * in pixels, excepting cases where the height may be even larger due to system decorations
102 * such as the status bar being hidden, for example.
103 */
104 public int largestNominalAppHeight;
105
106 /**
107 * The logical width of the display, in pixels.
108 * Represents the usable size of the display which may be smaller than the
109 * physical size when the system is emulating a smaller display.
110 */
111 public int logicalWidth;
112
113 /**
114 * The logical height of the display, in pixels.
115 * Represents the usable size of the display which may be smaller than the
116 * physical size when the system is emulating a smaller display.
117 */
118 public int logicalHeight;
119
120 /**
Dianne Hackbornc652de82013-02-15 16:32:56 -0800121 * @hide
122 * Number of overscan pixels on the left side of the display.
123 */
124 public int overscanLeft;
125
126 /**
127 * @hide
128 * Number of overscan pixels on the top side of the display.
129 */
130 public int overscanTop;
131
132 /**
133 * @hide
134 * Number of overscan pixels on the right side of the display.
135 */
136 public int overscanRight;
137
138 /**
139 * @hide
140 * Number of overscan pixels on the bottom side of the display.
141 */
142 public int overscanBottom;
143
144 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -0700145 * The rotation of the display relative to its natural orientation.
146 * May be one of {@link android.view.Surface#ROTATION_0},
147 * {@link android.view.Surface#ROTATION_90}, {@link android.view.Surface#ROTATION_180},
148 * {@link android.view.Surface#ROTATION_270}.
149 * <p>
150 * The value of this field is indeterminate if the logical display is presented on
151 * more than one physical display.
152 * </p>
153 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700154 @Surface.Rotation
Jeff Brownfa25bf52012-07-23 19:26:30 -0700155 public int rotation;
156
157 /**
158 * The refresh rate of this display in frames per second.
159 * <p>
160 * The value of this field is indeterminate if the logical display is presented on
161 * more than one physical display.
162 * </p>
163 */
164 public float refreshRate;
165
166 /**
Michael Wright3f145a22014-07-22 19:46:03 -0700167 * The supported refresh rates of this display at the current resolution in frames per second.
168 */
169 public float[] supportedRefreshRates = EmptyArray.FLOAT;
170
171 /**
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700172 * The logical display density which is the basis for density-independent
173 * pixels.
Jeff Brownfa25bf52012-07-23 19:26:30 -0700174 */
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700175 public int logicalDensityDpi;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700176
177 /**
178 * The exact physical pixels per inch of the screen in the X dimension.
179 * <p>
180 * The value of this field is indeterminate if the logical display is presented on
181 * more than one physical display.
182 * </p>
183 */
184 public float physicalXDpi;
185
186 /**
187 * The exact physical pixels per inch of the screen in the Y dimension.
188 * <p>
189 * The value of this field is indeterminate if the logical display is presented on
190 * more than one physical display.
191 * </p>
192 */
193 public float physicalYDpi;
194
Jeff Browna506a6e2013-06-04 00:02:38 -0700195 /**
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700196 * This is a positive value indicating the phase offset of the VSYNC events provided by
197 * Choreographer relative to the display refresh. For example, if Choreographer reports
198 * that the refresh occurred at time N, it actually occurred at (N - appVsyncOffsetNanos).
199 */
200 public long appVsyncOffsetNanos;
201
202 /**
203 * This is how far in advance a buffer must be queued for presentation at
204 * a given time. If you want a buffer to appear on the screen at
205 * time N, you must submit the buffer before (N - bufferDeadlineNanos).
206 */
207 public long presentationDeadlineNanos;
208
209 /**
Jeff Brown037c33e2014-04-09 00:31:55 -0700210 * The state of the display, such as {@link android.view.Display#STATE_ON}.
211 */
212 public int state;
213
214 /**
Jeff Browna506a6e2013-06-04 00:02:38 -0700215 * The UID of the application that owns this display, or zero if it is owned by the system.
216 * <p>
217 * If the display is private, then only the owner can use it.
218 * </p>
219 */
220 public int ownerUid;
221
222 /**
223 * The package name of the application that owns this display, or null if it is
224 * owned by the system.
225 * <p>
226 * If the display is private, then only the owner can use it.
227 * </p>
228 */
229 public String ownerPackageName;
230
Jeff Brownfa25bf52012-07-23 19:26:30 -0700231 public static final Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() {
Jeff Brown92130f62012-10-24 21:28:33 -0700232 @Override
Jeff Brownfa25bf52012-07-23 19:26:30 -0700233 public DisplayInfo createFromParcel(Parcel source) {
234 return new DisplayInfo(source);
235 }
236
Jeff Brown92130f62012-10-24 21:28:33 -0700237 @Override
Jeff Brownfa25bf52012-07-23 19:26:30 -0700238 public DisplayInfo[] newArray(int size) {
239 return new DisplayInfo[size];
240 }
241 };
242
243 public DisplayInfo() {
244 }
245
Jeff Brownbd6e1502012-08-28 03:27:37 -0700246 public DisplayInfo(DisplayInfo other) {
247 copyFrom(other);
248 }
249
Jeff Brownfa25bf52012-07-23 19:26:30 -0700250 private DisplayInfo(Parcel source) {
251 readFromParcel(source);
252 }
253
254 @Override
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700255 public boolean equals(Object o) {
256 return o instanceof DisplayInfo && equals((DisplayInfo)o);
257 }
258
259 public boolean equals(DisplayInfo other) {
260 return other != null
261 && layerStack == other.layerStack
Jeff Brown92130f62012-10-24 21:28:33 -0700262 && flags == other.flags
263 && type == other.type
264 && Objects.equal(address, other.address)
Wale Ogunwale361ca212014-11-20 11:42:38 -0800265 && Objects.equal(uniqueId, other.uniqueId)
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700266 && appWidth == other.appWidth
267 && appHeight == other.appHeight
268 && smallestNominalAppWidth == other.smallestNominalAppWidth
269 && smallestNominalAppHeight == other.smallestNominalAppHeight
270 && largestNominalAppWidth == other.largestNominalAppWidth
271 && largestNominalAppHeight == other.largestNominalAppHeight
272 && logicalWidth == other.logicalWidth
273 && logicalHeight == other.logicalHeight
Dianne Hackbornc652de82013-02-15 16:32:56 -0800274 && overscanLeft == other.overscanLeft
275 && overscanTop == other.overscanTop
276 && overscanRight == other.overscanRight
277 && overscanBottom == other.overscanBottom
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700278 && rotation == other.rotation
279 && refreshRate == other.refreshRate
280 && logicalDensityDpi == other.logicalDensityDpi
281 && physicalXDpi == other.physicalXDpi
Jeff Browna506a6e2013-06-04 00:02:38 -0700282 && physicalYDpi == other.physicalYDpi
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700283 && appVsyncOffsetNanos == other.appVsyncOffsetNanos
284 && presentationDeadlineNanos == other.presentationDeadlineNanos
Jeff Brown037c33e2014-04-09 00:31:55 -0700285 && state == other.state
Jeff Browna506a6e2013-06-04 00:02:38 -0700286 && ownerUid == other.ownerUid
287 && Objects.equal(ownerPackageName, other.ownerPackageName);
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700288 }
289
290 @Override
291 public int hashCode() {
292 return 0; // don't care
Jeff Brownfa25bf52012-07-23 19:26:30 -0700293 }
294
295 public void copyFrom(DisplayInfo other) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700296 layerStack = other.layerStack;
Jeff Brownc5df37c2012-09-13 11:45:07 -0700297 flags = other.flags;
Jeff Brown92130f62012-10-24 21:28:33 -0700298 type = other.type;
299 address = other.address;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700300 name = other.name;
Wale Ogunwale361ca212014-11-20 11:42:38 -0800301 uniqueId = other.uniqueId;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700302 appWidth = other.appWidth;
303 appHeight = other.appHeight;
304 smallestNominalAppWidth = other.smallestNominalAppWidth;
305 smallestNominalAppHeight = other.smallestNominalAppHeight;
306 largestNominalAppWidth = other.largestNominalAppWidth;
307 largestNominalAppHeight = other.largestNominalAppHeight;
308 logicalWidth = other.logicalWidth;
309 logicalHeight = other.logicalHeight;
Dianne Hackbornc652de82013-02-15 16:32:56 -0800310 overscanLeft = other.overscanLeft;
311 overscanTop = other.overscanTop;
312 overscanRight = other.overscanRight;
313 overscanBottom = other.overscanBottom;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700314 rotation = other.rotation;
315 refreshRate = other.refreshRate;
Michael Wright3f145a22014-07-22 19:46:03 -0700316 supportedRefreshRates = Arrays.copyOf(
317 other.supportedRefreshRates, other.supportedRefreshRates.length);
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700318 logicalDensityDpi = other.logicalDensityDpi;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700319 physicalXDpi = other.physicalXDpi;
320 physicalYDpi = other.physicalYDpi;
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700321 appVsyncOffsetNanos = other.appVsyncOffsetNanos;
322 presentationDeadlineNanos = other.presentationDeadlineNanos;
Jeff Brown037c33e2014-04-09 00:31:55 -0700323 state = other.state;
Jeff Browna506a6e2013-06-04 00:02:38 -0700324 ownerUid = other.ownerUid;
325 ownerPackageName = other.ownerPackageName;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700326 }
327
328 public void readFromParcel(Parcel source) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700329 layerStack = source.readInt();
Jeff Brownc5df37c2012-09-13 11:45:07 -0700330 flags = source.readInt();
Jeff Brown92130f62012-10-24 21:28:33 -0700331 type = source.readInt();
332 address = source.readString();
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700333 name = source.readString();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700334 appWidth = source.readInt();
335 appHeight = source.readInt();
336 smallestNominalAppWidth = source.readInt();
337 smallestNominalAppHeight = source.readInt();
338 largestNominalAppWidth = source.readInt();
339 largestNominalAppHeight = source.readInt();
340 logicalWidth = source.readInt();
341 logicalHeight = source.readInt();
Dianne Hackbornc652de82013-02-15 16:32:56 -0800342 overscanLeft = source.readInt();
343 overscanTop = source.readInt();
344 overscanRight = source.readInt();
345 overscanBottom = source.readInt();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700346 rotation = source.readInt();
347 refreshRate = source.readFloat();
Michael Wright3f145a22014-07-22 19:46:03 -0700348 supportedRefreshRates = source.createFloatArray();
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700349 logicalDensityDpi = source.readInt();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700350 physicalXDpi = source.readFloat();
351 physicalYDpi = source.readFloat();
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700352 appVsyncOffsetNanos = source.readLong();
353 presentationDeadlineNanos = source.readLong();
Jeff Brown037c33e2014-04-09 00:31:55 -0700354 state = source.readInt();
Jeff Browna506a6e2013-06-04 00:02:38 -0700355 ownerUid = source.readInt();
356 ownerPackageName = source.readString();
Wale Ogunwale361ca212014-11-20 11:42:38 -0800357 uniqueId = source.readString();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700358 }
359
360 @Override
361 public void writeToParcel(Parcel dest, int flags) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700362 dest.writeInt(layerStack);
Jeff Brown3f2ba622012-10-04 14:57:44 -0700363 dest.writeInt(this.flags);
Jeff Brown92130f62012-10-24 21:28:33 -0700364 dest.writeInt(type);
365 dest.writeString(address);
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700366 dest.writeString(name);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700367 dest.writeInt(appWidth);
368 dest.writeInt(appHeight);
369 dest.writeInt(smallestNominalAppWidth);
370 dest.writeInt(smallestNominalAppHeight);
371 dest.writeInt(largestNominalAppWidth);
372 dest.writeInt(largestNominalAppHeight);
373 dest.writeInt(logicalWidth);
374 dest.writeInt(logicalHeight);
Dianne Hackbornc652de82013-02-15 16:32:56 -0800375 dest.writeInt(overscanLeft);
376 dest.writeInt(overscanTop);
377 dest.writeInt(overscanRight);
378 dest.writeInt(overscanBottom);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700379 dest.writeInt(rotation);
380 dest.writeFloat(refreshRate);
Michael Wright3f145a22014-07-22 19:46:03 -0700381 dest.writeFloatArray(supportedRefreshRates);
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700382 dest.writeInt(logicalDensityDpi);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700383 dest.writeFloat(physicalXDpi);
384 dest.writeFloat(physicalYDpi);
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700385 dest.writeLong(appVsyncOffsetNanos);
386 dest.writeLong(presentationDeadlineNanos);
Jeff Brown037c33e2014-04-09 00:31:55 -0700387 dest.writeInt(state);
Jeff Browna506a6e2013-06-04 00:02:38 -0700388 dest.writeInt(ownerUid);
389 dest.writeString(ownerPackageName);
Wale Ogunwale361ca212014-11-20 11:42:38 -0800390 dest.writeString(uniqueId);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700391 }
392
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700393 @Override
394 public int describeContents() {
395 return 0;
396 }
397
Craig Mautner48d0d182013-06-11 07:53:06 -0700398 public void getAppMetrics(DisplayMetrics outMetrics) {
399 getAppMetrics(outMetrics, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700400 }
401
Craig Mautner48d0d182013-06-11 07:53:06 -0700402 public void getAppMetrics(DisplayMetrics outMetrics, DisplayAdjustments displayAdjustments) {
403 getMetricsWithSize(outMetrics, displayAdjustments.getCompatibilityInfo(),
Wale Ogunwale7c726682015-02-06 17:34:28 -0800404 displayAdjustments.getConfiguration(), appWidth, appHeight);
Craig Mautner48d0d182013-06-11 07:53:06 -0700405 }
406
Wale Ogunwale7c726682015-02-06 17:34:28 -0800407 public void getAppMetrics(DisplayMetrics outMetrics, CompatibilityInfo ci,
408 Configuration configuration) {
409 getMetricsWithSize(outMetrics, ci, configuration, appWidth, appHeight);
Craig Mautner48d0d182013-06-11 07:53:06 -0700410 }
411
412 public void getLogicalMetrics(DisplayMetrics outMetrics, CompatibilityInfo compatInfo,
Wale Ogunwale7c726682015-02-06 17:34:28 -0800413 Configuration configuration) {
414 getMetricsWithSize(outMetrics, compatInfo, configuration, logicalWidth, logicalHeight);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700415 }
416
Jeff Brown7f3994e2012-12-04 14:04:28 -0800417 public int getNaturalWidth() {
418 return rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180 ?
419 logicalWidth : logicalHeight;
420 }
421
422 public int getNaturalHeight() {
423 return rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180 ?
424 logicalHeight : logicalWidth;
425 }
426
Jeff Browna506a6e2013-06-04 00:02:38 -0700427 /**
428 * Returns true if the specified UID has access to this display.
429 */
430 public boolean hasAccess(int uid) {
431 return Display.hasAccess(uid, flags, ownerUid);
432 }
433
Craig Mautner48d0d182013-06-11 07:53:06 -0700434 private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfo compatInfo,
Wale Ogunwale7c726682015-02-06 17:34:28 -0800435 Configuration configuration, int width, int height) {
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700436 outMetrics.densityDpi = outMetrics.noncompatDensityDpi = logicalDensityDpi;
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700437 outMetrics.density = outMetrics.noncompatDensity =
438 logicalDensityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700439 outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density;
440 outMetrics.xdpi = outMetrics.noncompatXdpi = physicalXDpi;
441 outMetrics.ydpi = outMetrics.noncompatYdpi = physicalYDpi;
442
Wale Ogunwale7c726682015-02-06 17:34:28 -0800443 width = (configuration != null
444 && configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED)
445 ? (int)((configuration.screenWidthDp * outMetrics.density) + 0.5f) : width;
446 height = (configuration != null
447 && configuration.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED)
448 ? (int)((configuration.screenHeightDp * outMetrics.density) + 0.5f) : height;
449
450 outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width;
451 outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height;
452
Craig Mautner48d0d182013-06-11 07:53:06 -0700453 if (!compatInfo.equals(CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO)) {
454 compatInfo.applyToDisplayMetrics(outMetrics);
Jeff Brownfa25bf52012-07-23 19:26:30 -0700455 }
456 }
Jeff Brownbf5740e2012-08-19 23:20:02 -0700457
458 // For debugging purposes
459 @Override
460 public String toString() {
Dianne Hackbornc652de82013-02-15 16:32:56 -0800461 StringBuilder sb = new StringBuilder();
462 sb.append("DisplayInfo{\"");
463 sb.append(name);
Wale Ogunwale361ca212014-11-20 11:42:38 -0800464 sb.append("\", uniqueId \"");
465 sb.append(uniqueId);
Dianne Hackbornc652de82013-02-15 16:32:56 -0800466 sb.append("\", app ");
467 sb.append(appWidth);
468 sb.append(" x ");
469 sb.append(appHeight);
470 sb.append(", real ");
471 sb.append(logicalWidth);
472 sb.append(" x ");
473 sb.append(logicalHeight);
474 if (overscanLeft != 0 || overscanTop != 0 || overscanRight != 0 || overscanBottom != 0) {
475 sb.append(", overscan (");
476 sb.append(overscanLeft);
477 sb.append(",");
478 sb.append(overscanTop);
479 sb.append(",");
480 sb.append(overscanRight);
481 sb.append(",");
482 sb.append(overscanBottom);
483 sb.append(")");
484 }
485 sb.append(", largest app ");
486 sb.append(largestNominalAppWidth);
487 sb.append(" x ");
488 sb.append(largestNominalAppHeight);
489 sb.append(", smallest app ");
490 sb.append(smallestNominalAppWidth);
491 sb.append(" x ");
492 sb.append(smallestNominalAppHeight);
493 sb.append(", ");
494 sb.append(refreshRate);
Michael Wright3f145a22014-07-22 19:46:03 -0700495 sb.append(" fps, supportedRefreshRates ");
496 sb.append(Arrays.toString(supportedRefreshRates));
497 sb.append(", rotation ");
Dianne Hackbornc652de82013-02-15 16:32:56 -0800498 sb.append(rotation);
499 sb.append(", density ");
500 sb.append(logicalDensityDpi);
501 sb.append(" (");
502 sb.append(physicalXDpi);
503 sb.append(" x ");
504 sb.append(physicalYDpi);
505 sb.append(") dpi, layerStack ");
506 sb.append(layerStack);
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700507 sb.append(", appVsyncOff ");
508 sb.append(appVsyncOffsetNanos);
509 sb.append(", presDeadline ");
510 sb.append(presentationDeadlineNanos);
Dianne Hackbornc652de82013-02-15 16:32:56 -0800511 sb.append(", type ");
512 sb.append(Display.typeToString(type));
Jeff Browna506a6e2013-06-04 00:02:38 -0700513 if (address != null) {
514 sb.append(", address ").append(address);
515 }
Jeff Brown037c33e2014-04-09 00:31:55 -0700516 sb.append(", state ");
517 sb.append(Display.stateToString(state));
Jeff Browna506a6e2013-06-04 00:02:38 -0700518 if (ownerUid != 0 || ownerPackageName != null) {
519 sb.append(", owner ").append(ownerPackageName);
520 sb.append(" (uid ").append(ownerUid).append(")");
521 }
Dianne Hackbornc652de82013-02-15 16:32:56 -0800522 sb.append(flagsToString(flags));
523 sb.append("}");
524 return sb.toString();
Jeff Brownc5df37c2012-09-13 11:45:07 -0700525 }
526
527 private static String flagsToString(int flags) {
528 StringBuilder result = new StringBuilder();
Jeff Brownf0681b32012-10-23 17:35:57 -0700529 if ((flags & Display.FLAG_SECURE) != 0) {
530 result.append(", FLAG_SECURE");
531 }
Jeff Brown77aebfd2012-10-01 21:07:03 -0700532 if ((flags & Display.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) {
533 result.append(", FLAG_SUPPORTS_PROTECTED_BUFFERS");
Jeff Brownc5df37c2012-09-13 11:45:07 -0700534 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700535 if ((flags & Display.FLAG_PRIVATE) != 0) {
536 result.append(", FLAG_PRIVATE");
537 }
Jeff Brown7d00aff2013-08-02 19:03:49 -0700538 if ((flags & Display.FLAG_PRESENTATION) != 0) {
539 result.append(", FLAG_PRESENTATION");
540 }
Jeff Brownc5df37c2012-09-13 11:45:07 -0700541 return result.toString();
Jeff Brownbf5740e2012-08-19 23:20:02 -0700542 }
Jeff Brownfa25bf52012-07-23 19:26:30 -0700543}