blob: d4377e4870a5374164088153b5acfd306ff542b5 [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 com.android.server.display;
18
Marin Shalamanov98af1592019-10-08 10:48:08 +020019import android.hardware.display.DeviceProductInfo;
Jeff Brown4ccb8232014-01-16 22:16:42 -080020import android.hardware.display.DisplayViewport;
Jeff Browncbad9762012-09-04 21:57:59 -070021import android.util.DisplayMetrics;
Jeff Brown92130f62012-10-24 21:28:33 -070022import android.view.Display;
Dominik Laskowskidb845962019-01-27 21:20:00 -080023import android.view.DisplayAddress;
Adrian Roos1cf585052018-01-03 18:43:27 +010024import android.view.DisplayCutout;
Jeff Brown27f1d672012-10-17 18:32:34 -070025import android.view.Surface;
Jeff Browncbad9762012-09-04 21:57:59 -070026
Michael Wright3f145a22014-07-22 19:46:03 -070027import java.util.Arrays;
Narayan Kamath607223f2018-02-19 14:09:02 +000028import java.util.Objects;
Jeff Brown4ed8fe72012-08-30 18:18:29 -070029
Jeff Brownfa25bf52012-07-23 19:26:30 -070030/**
31 * Describes the characteristics of a physical display device.
32 */
Jeff Brown4ed8fe72012-08-30 18:18:29 -070033final class DisplayDeviceInfo {
34 /**
35 * Flag: Indicates that this display device should be considered the default display
36 * device of the system.
37 */
Jeff Brownbd6e1502012-08-28 03:27:37 -070038 public static final int FLAG_DEFAULT_DISPLAY = 1 << 0;
Jeff Brown4ed8fe72012-08-30 18:18:29 -070039
40 /**
Jeff Brown27f1d672012-10-17 18:32:34 -070041 * Flag: Indicates that the orientation of this display device is coupled to the
42 * rotation of its associated logical display.
43 * <p>
44 * This flag should be applied to the default display to indicate that the user
45 * physically rotates the display when content is presented in a different orientation.
46 * The display manager will apply a coordinate transformation assuming that the
47 * physical orientation of the display matches the logical orientation of its content.
48 * </p><p>
49 * The flag should not be set when the display device is mounted in a fixed orientation
50 * such as on a desk. The display manager will apply a coordinate transformation
51 * such as a scale and translation to letterbox or pillarbox format under the
52 * assumption that the physical orientation of the display is invariant.
53 * </p>
Jeff Brown4ed8fe72012-08-30 18:18:29 -070054 */
Jeff Brown27f1d672012-10-17 18:32:34 -070055 public static final int FLAG_ROTATES_WITH_CONTENT = 1 << 1;
Jeff Brownc5df37c2012-09-13 11:45:07 -070056
57 /**
Jeff Brown77aebfd2012-10-01 21:07:03 -070058 * Flag: Indicates that this display device has secure video output, such as HDCP.
Jeff Brownc5df37c2012-09-13 11:45:07 -070059 */
Jeff Brown77aebfd2012-10-01 21:07:03 -070060 public static final int FLAG_SECURE = 1 << 2;
61
62 /**
63 * Flag: Indicates that this display device supports compositing
64 * from gralloc protected buffers.
65 */
66 public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 3;
Jeff Brown4ed8fe72012-08-30 18:18:29 -070067
68 /**
Jeff Browna506a6e2013-06-04 00:02:38 -070069 * Flag: Indicates that the display device is owned by a particular application
70 * and that no other application should be able to interact with it.
Jeff Brownd14c8c92014-01-07 18:13:09 -080071 * Should typically be used together with {@link #FLAG_OWN_CONTENT_ONLY}.
Jeff Browna506a6e2013-06-04 00:02:38 -070072 */
73 public static final int FLAG_PRIVATE = 1 << 4;
74
75 /**
76 * Flag: Indicates that the display device is not blanked automatically by
77 * the power manager.
78 */
79 public static final int FLAG_NEVER_BLANK = 1 << 5;
80
81 /**
Jeff Brown7d00aff2013-08-02 19:03:49 -070082 * Flag: Indicates that the display is suitable for presentations.
83 */
84 public static final int FLAG_PRESENTATION = 1 << 6;
85
86 /**
Jeff Brownd14c8c92014-01-07 18:13:09 -080087 * Flag: Only show this display's own content; do not mirror
88 * the content of another display.
89 */
90 public static final int FLAG_OWN_CONTENT_ONLY = 1 << 7;
91
92 /**
Adam Powell49e7ff92015-05-14 16:18:53 -070093 * Flag: This display device has a round shape.
94 */
95 public static final int FLAG_ROUND = 1 << 8;
96
97 /**
Andrii Kulianfc8f82b2017-01-26 13:17:27 -080098 * Flag: This display can show its content when non-secure keyguard is shown.
99 */
Chilun8753ad32018-10-09 15:56:45 +0800100 // TODO (b/114338689): Remove the flag and use IWindowManager#shouldShowWithInsecureKeyguard
Andrii Kulian7211d2e2017-01-27 15:58:05 -0800101 public static final int FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 9;
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800102
103 /**
rongliu1e90fc32017-10-04 17:30:30 -0700104 * Flag: This display will destroy its content on removal.
105 * @hide
106 */
Chilun8753ad32018-10-09 15:56:45 +0800107 // TODO (b/114338689): Remove the flag and use WindowManager#REMOVE_CONTENT_MODE_DESTROY
rongliu1e90fc32017-10-04 17:30:30 -0700108 public static final int FLAG_DESTROY_CONTENT_ON_REMOVAL = 1 << 10;
109
110 /**
Adrian Roos8c28c7c2018-08-20 13:43:38 +0200111 * Flag: The display cutout of this display is masked.
112 * @hide
113 */
114 public static final int FLAG_MASK_DISPLAY_CUTOUT = 1 << 11;
115
116 /**
Louis Changbd48dca2018-08-29 17:44:34 +0800117 * Flag: This flag identifies secondary displays that should show system decorations, such as
118 * status bar, navigation bar, home activity or IME.
Charles Chenb28fb722020-05-21 17:19:32 +0800119 * <p>Note that this flag doesn't work without {@link #FLAG_TRUSTED}</p>
Louis Changbd48dca2018-08-29 17:44:34 +0800120 * @hide
121 */
Chilun8753ad32018-10-09 15:56:45 +0800122 // TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
Louis Changbd48dca2018-08-29 17:44:34 +0800123 public static final int FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 12;
124
125 /**
Charles Chenb28fb722020-05-21 17:19:32 +0800126 * Flag: The display is trusted to show system decorations and receive inputs without users'
127 * touch.
128 * @see #FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
129 */
130 public static final int FLAG_TRUSTED = 1 << 13;
131
132 /**
Jeff Brownd728bf52012-09-08 18:05:28 -0700133 * Touch attachment: Display does not receive touch.
134 */
135 public static final int TOUCH_NONE = 0;
136
137 /**
138 * Touch attachment: Touch input is via the internal interface.
139 */
140 public static final int TOUCH_INTERNAL = 1;
141
142 /**
143 * Touch attachment: Touch input is via an external interface, such as USB.
144 */
145 public static final int TOUCH_EXTERNAL = 2;
146
147 /**
Santos Cordonee8931e2017-04-05 10:31:15 -0700148 * Touch attachment: Touch input is via an input device matching {@link VirtualDisplay}'s
149 * uniqueId.
150 * @hide
151 */
152 public static final int TOUCH_VIRTUAL = 3;
153
154 /**
Jeff Brown10acf6d2015-04-14 14:20:47 -0700155 * Diff result: The {@link #state} fields differ.
156 */
157 public static final int DIFF_STATE = 1 << 0;
158
159 /**
160 * Diff result: Other fields differ.
161 */
162 public static final int DIFF_OTHER = 1 << 1;
163
164 /**
Michael Wright1c9977b2016-07-12 13:30:10 -0700165 * Diff result: The color mode fields differ.
166 */
167 public static final int DIFF_COLOR_MODE = 1 << 2;
168
169 /**
Wale Ogunwale361ca212014-11-20 11:42:38 -0800170 * Gets the name of the display device, which may be derived from EDID or
171 * other sources. The name may be localized and displayed to the user.
Jeff Brown848c2dc2012-08-19 20:18:08 -0700172 */
173 public String name;
174
175 /**
Wale Ogunwale361ca212014-11-20 11:42:38 -0800176 * Unique Id of display device.
177 */
178 public String uniqueId;
179
180 /**
Jeff Brownfa25bf52012-07-23 19:26:30 -0700181 * The width of the display in its natural orientation, in pixels.
182 * This value is not affected by display rotation.
183 */
184 public int width;
185
186 /**
187 * The height of the display in its natural orientation, in pixels.
188 * This value is not affected by display rotation.
189 */
190 public int height;
191
Jeff Browncbad9762012-09-04 21:57:59 -0700192 /**
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700193 * The active mode of the display.
Jeff Browncbad9762012-09-04 21:57:59 -0700194 */
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700195 public int modeId;
Jeff Browncbad9762012-09-04 21:57:59 -0700196
197 /**
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700198 * The default mode of the display.
Michael Wright3f145a22014-07-22 19:46:03 -0700199 */
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700200 public int defaultModeId;
201
202 /**
203 * The supported modes of the display.
204 */
205 public Display.Mode[] supportedModes = Display.Mode.EMPTY_ARRAY;
Michael Wright3f145a22014-07-22 19:46:03 -0700206
Michael Wright1c9977b2016-07-12 13:30:10 -0700207 /** The active color mode of the display */
208 public int colorMode;
Michael Wright58e829f2015-09-15 00:13:26 +0100209
Michael Wright1c9977b2016-07-12 13:30:10 -0700210 /** The supported color modes of the display */
211 public int[] supportedColorModes = { Display.COLOR_MODE_DEFAULT };
Michael Wright58e829f2015-09-15 00:13:26 +0100212
Michael Wright3f145a22014-07-22 19:46:03 -0700213 /**
Michael Wright9ff94c02016-03-30 18:05:40 -0700214 * The HDR capabilities this display claims to support.
215 */
216 public Display.HdrCapabilities hdrCapabilities;
217
218 /**
Galia Peycheva056b3ee2019-06-26 14:05:12 +0200219 * Indicates whether this display supports Auto Low Latency Mode.
220 */
221 public boolean allmSupported;
222
223 /**
224 * Indicates whether this display suppors Game content type.
225 */
226 public boolean gameContentTypeSupported;
227
228 /**
Jeff Browncbad9762012-09-04 21:57:59 -0700229 * The nominal apparent density of the display in DPI used for layout calculations.
230 * This density is sensitive to the viewing distance. A big TV and a tablet may have
231 * the same apparent density even though the pixels on the TV are much bigger than
232 * those on the tablet.
233 */
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700234 public int densityDpi;
Jeff Browncbad9762012-09-04 21:57:59 -0700235
236 /**
237 * The physical density of the display in DPI in the X direction.
238 * This density should specify the physical size of each pixel.
239 */
Jeff Brownfa25bf52012-07-23 19:26:30 -0700240 public float xDpi;
Jeff Browncbad9762012-09-04 21:57:59 -0700241
242 /**
243 * The physical density of the display in DPI in the X direction.
244 * This density should specify the physical size of each pixel.
245 */
Jeff Brownfa25bf52012-07-23 19:26:30 -0700246 public float yDpi;
247
Jeff Browncbad9762012-09-04 21:57:59 -0700248 /**
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700249 * This is a positive value indicating the phase offset of the VSYNC events provided by
250 * Choreographer relative to the display refresh. For example, if Choreographer reports
251 * that the refresh occurred at time N, it actually occurred at (N - appVsyncOffsetNanos).
252 */
253 public long appVsyncOffsetNanos;
254
255 /**
256 * This is how far in advance a buffer must be queued for presentation at
257 * a given time. If you want a buffer to appear on the screen at
258 * time N, you must submit the buffer before (N - bufferDeadlineNanos).
259 */
260 public long presentationDeadlineNanos;
261
262 /**
Jeff Browncbad9762012-09-04 21:57:59 -0700263 * Display flags.
264 */
Jeff Brownbd6e1502012-08-28 03:27:37 -0700265 public int flags;
266
Jeff Brownd728bf52012-09-08 18:05:28 -0700267 /**
Adrian Roos1cf585052018-01-03 18:43:27 +0100268 * The {@link DisplayCutout} if present or {@code null} otherwise.
269 */
270 public DisplayCutout displayCutout;
271
272 /**
Jeff Brownd728bf52012-09-08 18:05:28 -0700273 * The touch attachment, per {@link DisplayViewport#touch}.
274 */
275 public int touch;
276
Jeff Brown27f1d672012-10-17 18:32:34 -0700277 /**
278 * The additional rotation to apply to all content presented on the display device
279 * relative to its physical coordinate system. Default is {@link Surface#ROTATION_0}.
280 * <p>
281 * This field can be used to compensate for the fact that the display has been
282 * physically rotated relative to its natural orientation such as an HDMI monitor
283 * that has been mounted sideways to appear to be portrait rather than landscape.
284 * </p>
285 */
286 public int rotation = Surface.ROTATION_0;
287
Jeff Brown92130f62012-10-24 21:28:33 -0700288 /**
289 * Display type.
290 */
291 public int type;
292
293 /**
294 * Display address, or null if none.
295 * Interpretation varies by display type.
296 */
Dominik Laskowskidb845962019-01-27 21:20:00 -0800297 public DisplayAddress address;
Jeff Brown92130f62012-10-24 21:28:33 -0700298
Jeff Browna506a6e2013-06-04 00:02:38 -0700299 /**
Marin Shalamanov98af1592019-10-08 10:48:08 +0200300 * Product-specific information about the display or the directly connected device on the
301 * display chain. For example, if the display is transitively connected, this field may contain
302 * product information about the intermediate device.
303 */
304 public DeviceProductInfo deviceProductInfo;
305
306 /**
Jeff Brown037c33e2014-04-09 00:31:55 -0700307 * Display state.
308 */
309 public int state = Display.STATE_ON;
310
311 /**
Jeff Browna506a6e2013-06-04 00:02:38 -0700312 * The UID of the application that owns this display, or zero if it is owned by the system.
313 * <p>
314 * If the display is private, then only the owner can use it.
315 * </p>
316 */
317 public int ownerUid;
318
319 /**
320 * The package name of the application that owns this display, or null if it is
321 * owned by the system.
322 * <p>
323 * If the display is private, then only the owner can use it.
324 * </p>
325 */
326 public String ownerPackageName;
327
Jeff Browncbad9762012-09-04 21:57:59 -0700328 public void setAssumedDensityForExternalDisplay(int width, int height) {
329 densityDpi = Math.min(width, height) * DisplayMetrics.DENSITY_XHIGH / 1080;
330 // Technically, these values should be smaller than the apparent density
331 // but we don't know the physical size of the display.
332 xDpi = densityDpi;
333 yDpi = densityDpi;
334 }
335
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700336 @Override
337 public boolean equals(Object o) {
338 return o instanceof DisplayDeviceInfo && equals((DisplayDeviceInfo)o);
339 }
340
341 public boolean equals(DisplayDeviceInfo other) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700342 return other != null && diff(other) == 0;
343 }
344
345 /**
346 * Computes the difference between display device infos.
347 * Assumes other is not null.
348 */
349 public int diff(DisplayDeviceInfo other) {
350 int diff = 0;
351 if (state != other.state) {
352 diff |= DIFF_STATE;
353 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700354 if (colorMode != other.colorMode) {
355 diff |= DIFF_COLOR_MODE;
356 }
Narayan Kamath607223f2018-02-19 14:09:02 +0000357 if (!Objects.equals(name, other.name)
358 || !Objects.equals(uniqueId, other.uniqueId)
Jeff Brown10acf6d2015-04-14 14:20:47 -0700359 || width != other.width
360 || height != other.height
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700361 || modeId != other.modeId
362 || defaultModeId != other.defaultModeId
363 || !Arrays.equals(supportedModes, other.supportedModes)
Michael Wright1c9977b2016-07-12 13:30:10 -0700364 || !Arrays.equals(supportedColorModes, other.supportedColorModes)
Narayan Kamath607223f2018-02-19 14:09:02 +0000365 || !Objects.equals(hdrCapabilities, other.hdrCapabilities)
Galia Peycheva056b3ee2019-06-26 14:05:12 +0200366 || allmSupported != other.allmSupported
367 || gameContentTypeSupported != other.gameContentTypeSupported
Jeff Brown10acf6d2015-04-14 14:20:47 -0700368 || densityDpi != other.densityDpi
369 || xDpi != other.xDpi
370 || yDpi != other.yDpi
371 || appVsyncOffsetNanos != other.appVsyncOffsetNanos
372 || presentationDeadlineNanos != other.presentationDeadlineNanos
373 || flags != other.flags
Narayan Kamath607223f2018-02-19 14:09:02 +0000374 || !Objects.equals(displayCutout, other.displayCutout)
Jeff Brown10acf6d2015-04-14 14:20:47 -0700375 || touch != other.touch
376 || rotation != other.rotation
377 || type != other.type
Narayan Kamath607223f2018-02-19 14:09:02 +0000378 || !Objects.equals(address, other.address)
Marin Shalamanov98af1592019-10-08 10:48:08 +0200379 || !Objects.equals(deviceProductInfo, other.deviceProductInfo)
Jeff Brown10acf6d2015-04-14 14:20:47 -0700380 || ownerUid != other.ownerUid
Narayan Kamath607223f2018-02-19 14:09:02 +0000381 || !Objects.equals(ownerPackageName, other.ownerPackageName)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700382 diff |= DIFF_OTHER;
383 }
384 return diff;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700385 }
386
387 @Override
388 public int hashCode() {
389 return 0; // don't care
390 }
391
Jeff Brownfa25bf52012-07-23 19:26:30 -0700392 public void copyFrom(DisplayDeviceInfo other) {
Jeff Brown848c2dc2012-08-19 20:18:08 -0700393 name = other.name;
Wale Ogunwale361ca212014-11-20 11:42:38 -0800394 uniqueId = other.uniqueId;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700395 width = other.width;
396 height = other.height;
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700397 modeId = other.modeId;
398 defaultModeId = other.defaultModeId;
399 supportedModes = other.supportedModes;
Michael Wright1c9977b2016-07-12 13:30:10 -0700400 colorMode = other.colorMode;
401 supportedColorModes = other.supportedColorModes;
Michael Wright9ff94c02016-03-30 18:05:40 -0700402 hdrCapabilities = other.hdrCapabilities;
Galia Peycheva056b3ee2019-06-26 14:05:12 +0200403 allmSupported = other.allmSupported;
404 gameContentTypeSupported = other.gameContentTypeSupported;
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700405 densityDpi = other.densityDpi;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700406 xDpi = other.xDpi;
407 yDpi = other.yDpi;
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700408 appVsyncOffsetNanos = other.appVsyncOffsetNanos;
409 presentationDeadlineNanos = other.presentationDeadlineNanos;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700410 flags = other.flags;
Adrian Roos1cf585052018-01-03 18:43:27 +0100411 displayCutout = other.displayCutout;
Jeff Brownd728bf52012-09-08 18:05:28 -0700412 touch = other.touch;
Jeff Brown27f1d672012-10-17 18:32:34 -0700413 rotation = other.rotation;
Jeff Brown92130f62012-10-24 21:28:33 -0700414 type = other.type;
415 address = other.address;
Marin Shalamanov98af1592019-10-08 10:48:08 +0200416 deviceProductInfo = other.deviceProductInfo;
Jeff Brown037c33e2014-04-09 00:31:55 -0700417 state = other.state;
Jeff Browna506a6e2013-06-04 00:02:38 -0700418 ownerUid = other.ownerUid;
419 ownerPackageName = other.ownerPackageName;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700420 }
421
Jeff Brown848c2dc2012-08-19 20:18:08 -0700422 // For debugging purposes
Jeff Brownfa25bf52012-07-23 19:26:30 -0700423 @Override
424 public String toString() {
Jeff Browna506a6e2013-06-04 00:02:38 -0700425 StringBuilder sb = new StringBuilder();
426 sb.append("DisplayDeviceInfo{\"");
Wale Ogunwale361ca212014-11-20 11:42:38 -0800427 sb.append(name).append("\": uniqueId=\"").append(uniqueId).append("\", ");
428 sb.append(width).append(" x ").append(height);
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700429 sb.append(", modeId ").append(modeId);
430 sb.append(", defaultModeId ").append(defaultModeId);
431 sb.append(", supportedModes ").append(Arrays.toString(supportedModes));
Michael Wright1c9977b2016-07-12 13:30:10 -0700432 sb.append(", colorMode ").append(colorMode);
433 sb.append(", supportedColorModes ").append(Arrays.toString(supportedColorModes));
Michael Wright9ff94c02016-03-30 18:05:40 -0700434 sb.append(", HdrCapabilities ").append(hdrCapabilities);
Galia Peycheva056b3ee2019-06-26 14:05:12 +0200435 sb.append(", allmSupported ").append(allmSupported);
436 sb.append(", gameContentTypeSupported ").append(gameContentTypeSupported);
Michael Wright3f145a22014-07-22 19:46:03 -0700437 sb.append(", density ").append(densityDpi);
Jeff Browna506a6e2013-06-04 00:02:38 -0700438 sb.append(", ").append(xDpi).append(" x ").append(yDpi).append(" dpi");
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700439 sb.append(", appVsyncOff ").append(appVsyncOffsetNanos);
440 sb.append(", presDeadline ").append(presentationDeadlineNanos);
Adrian Roos1cf585052018-01-03 18:43:27 +0100441 if (displayCutout != null) {
442 sb.append(", cutout ").append(displayCutout);
443 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700444 sb.append(", touch ").append(touchToString(touch));
445 sb.append(", rotation ").append(rotation);
446 sb.append(", type ").append(Display.typeToString(type));
447 if (address != null) {
448 sb.append(", address ").append(address);
449 }
Marin Shalamanov98af1592019-10-08 10:48:08 +0200450 sb.append(", deviceProductInfo ").append(deviceProductInfo);
Jeff Brown037c33e2014-04-09 00:31:55 -0700451 sb.append(", state ").append(Display.stateToString(state));
Jeff Browna506a6e2013-06-04 00:02:38 -0700452 if (ownerUid != 0 || ownerPackageName != null) {
453 sb.append(", owner ").append(ownerPackageName);
454 sb.append(" (uid ").append(ownerUid).append(")");
455 }
456 sb.append(flagsToString(flags));
457 sb.append("}");
458 return sb.toString();
Jeff Brownd728bf52012-09-08 18:05:28 -0700459 }
460
461 private static String touchToString(int touch) {
462 switch (touch) {
463 case TOUCH_NONE:
464 return "NONE";
465 case TOUCH_INTERNAL:
466 return "INTERNAL";
467 case TOUCH_EXTERNAL:
468 return "EXTERNAL";
Santos Cordonee8931e2017-04-05 10:31:15 -0700469 case TOUCH_VIRTUAL:
470 return "VIRTUAL";
Jeff Brownd728bf52012-09-08 18:05:28 -0700471 default:
472 return Integer.toString(touch);
473 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700474 }
475
476 private static String flagsToString(int flags) {
477 StringBuilder msg = new StringBuilder();
478 if ((flags & FLAG_DEFAULT_DISPLAY) != 0) {
479 msg.append(", FLAG_DEFAULT_DISPLAY");
480 }
Jeff Brown27f1d672012-10-17 18:32:34 -0700481 if ((flags & FLAG_ROTATES_WITH_CONTENT) != 0) {
482 msg.append(", FLAG_ROTATES_WITH_CONTENT");
Jeff Brownc5df37c2012-09-13 11:45:07 -0700483 }
Jeff Brown77aebfd2012-10-01 21:07:03 -0700484 if ((flags & FLAG_SECURE) != 0) {
485 msg.append(", FLAG_SECURE");
486 }
487 if ((flags & FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) {
488 msg.append(", FLAG_SUPPORTS_PROTECTED_BUFFERS");
Jeff Brownbd6e1502012-08-28 03:27:37 -0700489 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700490 if ((flags & FLAG_PRIVATE) != 0) {
491 msg.append(", FLAG_PRIVATE");
492 }
493 if ((flags & FLAG_NEVER_BLANK) != 0) {
494 msg.append(", FLAG_NEVER_BLANK");
495 }
Jeff Brown7d00aff2013-08-02 19:03:49 -0700496 if ((flags & FLAG_PRESENTATION) != 0) {
497 msg.append(", FLAG_PRESENTATION");
498 }
Jeff Brownd14c8c92014-01-07 18:13:09 -0800499 if ((flags & FLAG_OWN_CONTENT_ONLY) != 0) {
500 msg.append(", FLAG_OWN_CONTENT_ONLY");
501 }
Adam Powell49e7ff92015-05-14 16:18:53 -0700502 if ((flags & FLAG_ROUND) != 0) {
503 msg.append(", FLAG_ROUND");
504 }
Andrii Kulian7211d2e2017-01-27 15:58:05 -0800505 if ((flags & FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0) {
506 msg.append(", FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD");
Andrii Kulianfc8f82b2017-01-26 13:17:27 -0800507 }
Adrian Roos8c28c7c2018-08-20 13:43:38 +0200508 if ((flags & FLAG_MASK_DISPLAY_CUTOUT) != 0) {
509 msg.append(", FLAG_MASK_DISPLAY_CUTOUT");
510 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700511 return msg.toString();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700512 }
513}