Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.view; |
| 18 | |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 19 | import static android.view.DisplayInfoProto.APP_HEIGHT; |
| 20 | import static android.view.DisplayInfoProto.APP_WIDTH; |
Yan Zhu | 39b0e9a | 2019-07-22 11:23:13 -0700 | [diff] [blame] | 21 | import static android.view.DisplayInfoProto.FLAGS; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 22 | import static android.view.DisplayInfoProto.LOGICAL_HEIGHT; |
| 23 | import static android.view.DisplayInfoProto.LOGICAL_WIDTH; |
Andrii Kulian | 764e104 | 2018-02-08 15:12:14 -0800 | [diff] [blame] | 24 | import static android.view.DisplayInfoProto.NAME; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 25 | |
Adrian Roos | a490479 | 2018-05-31 19:48:39 +0200 | [diff] [blame] | 26 | import android.annotation.Nullable; |
Artur Satayev | ad9254c | 2019-12-10 17:47:54 +0000 | [diff] [blame] | 27 | import android.compat.annotation.UnsupportedAppUsage; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 28 | import android.content.res.CompatibilityInfo; |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 29 | import android.content.res.Configuration; |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 30 | import android.graphics.Rect; |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 31 | import android.hardware.display.DeviceProductInfo; |
Sumir Kataria | 47ed9ee | 2019-02-06 13:34:28 -0800 | [diff] [blame] | 32 | import android.os.Build; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 33 | import android.os.Parcel; |
| 34 | import android.os.Parcelable; |
Dominik Laskowski | 1039ea50 | 2020-02-28 15:27:12 -0800 | [diff] [blame] | 35 | import android.os.Process; |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 36 | import android.util.ArraySet; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 37 | import android.util.DisplayMetrics; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 38 | import android.util.proto.ProtoOutputStream; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 39 | |
Aurimas Liutikas | 67e2ae8 | 2016-10-11 18:17:42 -0700 | [diff] [blame] | 40 | import java.util.Arrays; |
Narayan Kamath | 607223f | 2018-02-19 14:09:02 +0000 | [diff] [blame] | 41 | import java.util.Objects; |
Aurimas Liutikas | 67e2ae8 | 2016-10-11 18:17:42 -0700 | [diff] [blame] | 42 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 43 | /** |
| 44 | * Describes the characteristics of a particular logical display. |
| 45 | * @hide |
| 46 | */ |
| 47 | public final class DisplayInfo implements Parcelable { |
| 48 | /** |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 49 | * The surface flinger layer stack associated with this logical display. |
| 50 | */ |
| 51 | public int layerStack; |
| 52 | |
| 53 | /** |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 54 | * Display flags. |
| 55 | */ |
| 56 | public int flags; |
| 57 | |
| 58 | /** |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 59 | * Display type. |
| 60 | */ |
| 61 | public int type; |
| 62 | |
| 63 | /** |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 64 | * Logical display identifier. |
| 65 | */ |
| 66 | public int displayId; |
| 67 | |
| 68 | /** |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 69 | * Display address, or null if none. |
| 70 | * Interpretation varies by display type. |
| 71 | */ |
Dominik Laskowski | db84596 | 2019-01-27 21:20:00 -0800 | [diff] [blame] | 72 | public DisplayAddress address; |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 75 | * Product-specific information about the display or the directly connected device on the |
| 76 | * display chain. For example, if the display is transitively connected, this field may contain |
| 77 | * product information about the intermediate device. |
| 78 | */ |
| 79 | public DeviceProductInfo deviceProductInfo; |
| 80 | |
| 81 | /** |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 82 | * The human-readable name of the display. |
| 83 | */ |
| 84 | public String name; |
| 85 | |
| 86 | /** |
Wale Ogunwale | 361ca21 | 2014-11-20 11:42:38 -0800 | [diff] [blame] | 87 | * Unique identifier for the display. Shouldn't be displayed to the user. |
| 88 | */ |
| 89 | public String uniqueId; |
| 90 | |
| 91 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 92 | * The width of the portion of the display that is available to applications, in pixels. |
| 93 | * Represents the size of the display minus any system decorations. |
| 94 | */ |
| 95 | public int appWidth; |
| 96 | |
| 97 | /** |
| 98 | * The height of the portion of the display that is available to applications, in pixels. |
| 99 | * Represents the size of the display minus any system decorations. |
| 100 | */ |
| 101 | public int appHeight; |
| 102 | |
| 103 | /** |
| 104 | * The smallest value of {@link #appWidth} that an application is likely to encounter, |
| 105 | * in pixels, excepting cases where the width may be even smaller due to the presence |
| 106 | * of a soft keyboard, for example. |
| 107 | */ |
| 108 | public int smallestNominalAppWidth; |
| 109 | |
| 110 | /** |
| 111 | * The smallest value of {@link #appHeight} that an application is likely to encounter, |
| 112 | * in pixels, excepting cases where the height may be even smaller due to the presence |
| 113 | * of a soft keyboard, for example. |
| 114 | */ |
| 115 | public int smallestNominalAppHeight; |
| 116 | |
| 117 | /** |
| 118 | * The largest value of {@link #appWidth} that an application is likely to encounter, |
| 119 | * in pixels, excepting cases where the width may be even larger due to system decorations |
| 120 | * such as the status bar being hidden, for example. |
| 121 | */ |
| 122 | public int largestNominalAppWidth; |
| 123 | |
| 124 | /** |
| 125 | * The largest value of {@link #appHeight} that an application is likely to encounter, |
| 126 | * in pixels, excepting cases where the height may be even larger due to system decorations |
| 127 | * such as the status bar being hidden, for example. |
| 128 | */ |
| 129 | public int largestNominalAppHeight; |
| 130 | |
| 131 | /** |
| 132 | * The logical width of the display, in pixels. |
| 133 | * Represents the usable size of the display which may be smaller than the |
| 134 | * physical size when the system is emulating a smaller display. |
| 135 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 136 | @UnsupportedAppUsage |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 137 | public int logicalWidth; |
| 138 | |
| 139 | /** |
| 140 | * The logical height of the display, in pixels. |
| 141 | * Represents the usable size of the display which may be smaller than the |
| 142 | * physical size when the system is emulating a smaller display. |
| 143 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 144 | @UnsupportedAppUsage |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 145 | public int logicalHeight; |
| 146 | |
| 147 | /** |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 148 | * The {@link DisplayCutout} if present, otherwise {@code null}. |
| 149 | * |
| 150 | * @hide |
| 151 | */ |
Sergey Vasilinets | 669ad67 | 2019-02-07 13:42:33 +0000 | [diff] [blame] | 152 | // Remark on @UnsupportedAppUsage: Display.getCutout should be used instead |
Adrian Roos | a490479 | 2018-05-31 19:48:39 +0200 | [diff] [blame] | 153 | @Nullable |
Sergey Vasilinets | 669ad67 | 2019-02-07 13:42:33 +0000 | [diff] [blame] | 154 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 155 | public DisplayCutout displayCutout; |
| 156 | |
| 157 | /** |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 158 | * The rotation of the display relative to its natural orientation. |
| 159 | * May be one of {@link android.view.Surface#ROTATION_0}, |
| 160 | * {@link android.view.Surface#ROTATION_90}, {@link android.view.Surface#ROTATION_180}, |
| 161 | * {@link android.view.Surface#ROTATION_270}. |
| 162 | * <p> |
| 163 | * The value of this field is indeterminate if the logical display is presented on |
| 164 | * more than one physical display. |
| 165 | * </p> |
| 166 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 167 | @Surface.Rotation |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 168 | @UnsupportedAppUsage |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 169 | public int rotation; |
| 170 | |
| 171 | /** |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 172 | * The active display mode. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 173 | */ |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 174 | public int modeId; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 175 | |
| 176 | /** |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 177 | * The default display mode. |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 178 | */ |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 179 | public int defaultModeId; |
| 180 | |
| 181 | /** |
| 182 | * The supported modes of this display. |
| 183 | */ |
| 184 | public Display.Mode[] supportedModes = Display.Mode.EMPTY_ARRAY; |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 185 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 186 | /** The active color mode. */ |
| 187 | public int colorMode; |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 188 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 189 | /** The list of supported color modes */ |
| 190 | public int[] supportedColorModes = { Display.COLOR_MODE_DEFAULT }; |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 191 | |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 192 | /** The display's HDR capabilities */ |
| 193 | public Display.HdrCapabilities hdrCapabilities; |
| 194 | |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 195 | /** |
Galia Peycheva | 056b3ee | 2019-06-26 14:05:12 +0200 | [diff] [blame] | 196 | * Indicates whether the display can be switched into a mode with minimal post |
| 197 | * processing. |
| 198 | * |
| 199 | * @see android.view.Display#isMinimalPostProcessingSupported |
| 200 | */ |
| 201 | public boolean minimalPostProcessingSupported; |
| 202 | |
| 203 | /** |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 204 | * The logical display density which is the basis for density-independent |
| 205 | * pixels. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 206 | */ |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 207 | public int logicalDensityDpi; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 208 | |
| 209 | /** |
| 210 | * The exact physical pixels per inch of the screen in the X dimension. |
| 211 | * <p> |
| 212 | * The value of this field is indeterminate if the logical display is presented on |
| 213 | * more than one physical display. |
| 214 | * </p> |
| 215 | */ |
| 216 | public float physicalXDpi; |
| 217 | |
| 218 | /** |
| 219 | * The exact physical pixels per inch of the screen in the Y dimension. |
| 220 | * <p> |
| 221 | * The value of this field is indeterminate if the logical display is presented on |
| 222 | * more than one physical display. |
| 223 | * </p> |
| 224 | */ |
| 225 | public float physicalYDpi; |
| 226 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 227 | /** |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 228 | * This is a positive value indicating the phase offset of the VSYNC events provided by |
| 229 | * Choreographer relative to the display refresh. For example, if Choreographer reports |
| 230 | * that the refresh occurred at time N, it actually occurred at (N - appVsyncOffsetNanos). |
| 231 | */ |
| 232 | public long appVsyncOffsetNanos; |
| 233 | |
| 234 | /** |
| 235 | * This is how far in advance a buffer must be queued for presentation at |
| 236 | * a given time. If you want a buffer to appear on the screen at |
| 237 | * time N, you must submit the buffer before (N - bufferDeadlineNanos). |
| 238 | */ |
| 239 | public long presentationDeadlineNanos; |
| 240 | |
| 241 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 242 | * The state of the display, such as {@link android.view.Display#STATE_ON}. |
| 243 | */ |
| 244 | public int state; |
| 245 | |
| 246 | /** |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 247 | * The UID of the application that owns this display, or zero if it is owned by the system. |
| 248 | * <p> |
| 249 | * If the display is private, then only the owner can use it. |
| 250 | * </p> |
| 251 | */ |
| 252 | public int ownerUid; |
| 253 | |
| 254 | /** |
| 255 | * The package name of the application that owns this display, or null if it is |
| 256 | * owned by the system. |
| 257 | * <p> |
| 258 | * If the display is private, then only the owner can use it. |
| 259 | * </p> |
| 260 | */ |
| 261 | public String ownerPackageName; |
| 262 | |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 263 | /** |
| 264 | * @hide |
| 265 | * Get current remove mode of the display - what actions should be performed with the display's |
| 266 | * content when it is removed. |
| 267 | * |
| 268 | * @see Display#getRemoveMode() |
| 269 | */ |
Chilun | 8753ad3 | 2018-10-09 15:56:45 +0800 | [diff] [blame] | 270 | // TODO (b/114338689): Remove the flag and use IWindowManager#getRemoveContentMode |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 271 | public int removeMode = Display.REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY; |
| 272 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 273 | public static final @android.annotation.NonNull Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() { |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 274 | @Override |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 275 | public DisplayInfo createFromParcel(Parcel source) { |
| 276 | return new DisplayInfo(source); |
| 277 | } |
| 278 | |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 279 | @Override |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 280 | public DisplayInfo[] newArray(int size) { |
| 281 | return new DisplayInfo[size]; |
| 282 | } |
| 283 | }; |
| 284 | |
Sumir Kataria | 47ed9ee | 2019-02-06 13:34:28 -0800 | [diff] [blame] | 285 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769467) |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 286 | public DisplayInfo() { |
| 287 | } |
| 288 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 289 | public DisplayInfo(DisplayInfo other) { |
| 290 | copyFrom(other); |
| 291 | } |
| 292 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 293 | private DisplayInfo(Parcel source) { |
| 294 | readFromParcel(source); |
| 295 | } |
| 296 | |
| 297 | @Override |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 298 | public boolean equals(Object o) { |
| 299 | return o instanceof DisplayInfo && equals((DisplayInfo)o); |
| 300 | } |
| 301 | |
| 302 | public boolean equals(DisplayInfo other) { |
| 303 | return other != null |
| 304 | && layerStack == other.layerStack |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 305 | && flags == other.flags |
| 306 | && type == other.type |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 307 | && displayId == other.displayId |
Narayan Kamath | 607223f | 2018-02-19 14:09:02 +0000 | [diff] [blame] | 308 | && Objects.equals(address, other.address) |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 309 | && Objects.equals(deviceProductInfo, other.deviceProductInfo) |
Narayan Kamath | 607223f | 2018-02-19 14:09:02 +0000 | [diff] [blame] | 310 | && Objects.equals(uniqueId, other.uniqueId) |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 311 | && appWidth == other.appWidth |
| 312 | && appHeight == other.appHeight |
| 313 | && smallestNominalAppWidth == other.smallestNominalAppWidth |
| 314 | && smallestNominalAppHeight == other.smallestNominalAppHeight |
| 315 | && largestNominalAppWidth == other.largestNominalAppWidth |
| 316 | && largestNominalAppHeight == other.largestNominalAppHeight |
| 317 | && logicalWidth == other.logicalWidth |
| 318 | && logicalHeight == other.logicalHeight |
Narayan Kamath | 607223f | 2018-02-19 14:09:02 +0000 | [diff] [blame] | 319 | && Objects.equals(displayCutout, other.displayCutout) |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 320 | && rotation == other.rotation |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 321 | && modeId == other.modeId |
| 322 | && defaultModeId == other.defaultModeId |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 323 | && colorMode == other.colorMode |
Michael Wright | 16ae042 | 2016-07-26 18:18:53 +0100 | [diff] [blame] | 324 | && Arrays.equals(supportedColorModes, other.supportedColorModes) |
Narayan Kamath | 607223f | 2018-02-19 14:09:02 +0000 | [diff] [blame] | 325 | && Objects.equals(hdrCapabilities, other.hdrCapabilities) |
Galia Peycheva | 056b3ee | 2019-06-26 14:05:12 +0200 | [diff] [blame] | 326 | && minimalPostProcessingSupported == other.minimalPostProcessingSupported |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 327 | && logicalDensityDpi == other.logicalDensityDpi |
| 328 | && physicalXDpi == other.physicalXDpi |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 329 | && physicalYDpi == other.physicalYDpi |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 330 | && appVsyncOffsetNanos == other.appVsyncOffsetNanos |
| 331 | && presentationDeadlineNanos == other.presentationDeadlineNanos |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 332 | && state == other.state |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 333 | && ownerUid == other.ownerUid |
Narayan Kamath | 607223f | 2018-02-19 14:09:02 +0000 | [diff] [blame] | 334 | && Objects.equals(ownerPackageName, other.ownerPackageName) |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 335 | && removeMode == other.removeMode; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public int hashCode() { |
| 340 | return 0; // don't care |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | public void copyFrom(DisplayInfo other) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 344 | layerStack = other.layerStack; |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 345 | flags = other.flags; |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 346 | type = other.type; |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 347 | displayId = other.displayId; |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 348 | address = other.address; |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 349 | deviceProductInfo = other.deviceProductInfo; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 350 | name = other.name; |
Wale Ogunwale | 361ca21 | 2014-11-20 11:42:38 -0800 | [diff] [blame] | 351 | uniqueId = other.uniqueId; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 352 | appWidth = other.appWidth; |
| 353 | appHeight = other.appHeight; |
| 354 | smallestNominalAppWidth = other.smallestNominalAppWidth; |
| 355 | smallestNominalAppHeight = other.smallestNominalAppHeight; |
| 356 | largestNominalAppWidth = other.largestNominalAppWidth; |
| 357 | largestNominalAppHeight = other.largestNominalAppHeight; |
| 358 | logicalWidth = other.logicalWidth; |
| 359 | logicalHeight = other.logicalHeight; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 360 | displayCutout = other.displayCutout; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 361 | rotation = other.rotation; |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 362 | modeId = other.modeId; |
| 363 | defaultModeId = other.defaultModeId; |
| 364 | supportedModes = Arrays.copyOf(other.supportedModes, other.supportedModes.length); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 365 | colorMode = other.colorMode; |
| 366 | supportedColorModes = Arrays.copyOf( |
| 367 | other.supportedColorModes, other.supportedColorModes.length); |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 368 | hdrCapabilities = other.hdrCapabilities; |
Galia Peycheva | 056b3ee | 2019-06-26 14:05:12 +0200 | [diff] [blame] | 369 | minimalPostProcessingSupported = other.minimalPostProcessingSupported; |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 370 | logicalDensityDpi = other.logicalDensityDpi; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 371 | physicalXDpi = other.physicalXDpi; |
| 372 | physicalYDpi = other.physicalYDpi; |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 373 | appVsyncOffsetNanos = other.appVsyncOffsetNanos; |
| 374 | presentationDeadlineNanos = other.presentationDeadlineNanos; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 375 | state = other.state; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 376 | ownerUid = other.ownerUid; |
| 377 | ownerPackageName = other.ownerPackageName; |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 378 | removeMode = other.removeMode; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | public void readFromParcel(Parcel source) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 382 | layerStack = source.readInt(); |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 383 | flags = source.readInt(); |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 384 | type = source.readInt(); |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 385 | displayId = source.readInt(); |
Dominik Laskowski | db84596 | 2019-01-27 21:20:00 -0800 | [diff] [blame] | 386 | address = source.readParcelable(null); |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 387 | deviceProductInfo = source.readParcelable(null); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 388 | name = source.readString(); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 389 | appWidth = source.readInt(); |
| 390 | appHeight = source.readInt(); |
| 391 | smallestNominalAppWidth = source.readInt(); |
| 392 | smallestNominalAppHeight = source.readInt(); |
| 393 | largestNominalAppWidth = source.readInt(); |
| 394 | largestNominalAppHeight = source.readInt(); |
| 395 | logicalWidth = source.readInt(); |
| 396 | logicalHeight = source.readInt(); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 397 | displayCutout = DisplayCutout.ParcelableWrapper.readCutoutFromParcel(source); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 398 | rotation = source.readInt(); |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 399 | modeId = source.readInt(); |
| 400 | defaultModeId = source.readInt(); |
| 401 | int nModes = source.readInt(); |
| 402 | supportedModes = new Display.Mode[nModes]; |
| 403 | for (int i = 0; i < nModes; i++) { |
| 404 | supportedModes[i] = Display.Mode.CREATOR.createFromParcel(source); |
| 405 | } |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 406 | colorMode = source.readInt(); |
| 407 | int nColorModes = source.readInt(); |
| 408 | supportedColorModes = new int[nColorModes]; |
| 409 | for (int i = 0; i < nColorModes; i++) { |
| 410 | supportedColorModes[i] = source.readInt(); |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 411 | } |
Michael Wright | b082890 | 2016-04-27 19:26:16 -0400 | [diff] [blame] | 412 | hdrCapabilities = source.readParcelable(null); |
Galia Peycheva | 056b3ee | 2019-06-26 14:05:12 +0200 | [diff] [blame] | 413 | minimalPostProcessingSupported = source.readBoolean(); |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 414 | logicalDensityDpi = source.readInt(); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 415 | physicalXDpi = source.readFloat(); |
| 416 | physicalYDpi = source.readFloat(); |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 417 | appVsyncOffsetNanos = source.readLong(); |
| 418 | presentationDeadlineNanos = source.readLong(); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 419 | state = source.readInt(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 420 | ownerUid = source.readInt(); |
| 421 | ownerPackageName = source.readString(); |
Wale Ogunwale | 361ca21 | 2014-11-20 11:42:38 -0800 | [diff] [blame] | 422 | uniqueId = source.readString(); |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 423 | removeMode = source.readInt(); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | @Override |
| 427 | public void writeToParcel(Parcel dest, int flags) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 428 | dest.writeInt(layerStack); |
Jeff Brown | 3f2ba62 | 2012-10-04 14:57:44 -0700 | [diff] [blame] | 429 | dest.writeInt(this.flags); |
Jeff Brown | 92130f6 | 2012-10-24 21:28:33 -0700 | [diff] [blame] | 430 | dest.writeInt(type); |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 431 | dest.writeInt(displayId); |
Dominik Laskowski | db84596 | 2019-01-27 21:20:00 -0800 | [diff] [blame] | 432 | dest.writeParcelable(address, flags); |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 433 | dest.writeParcelable(deviceProductInfo, flags); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 434 | dest.writeString(name); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 435 | dest.writeInt(appWidth); |
| 436 | dest.writeInt(appHeight); |
| 437 | dest.writeInt(smallestNominalAppWidth); |
| 438 | dest.writeInt(smallestNominalAppHeight); |
| 439 | dest.writeInt(largestNominalAppWidth); |
| 440 | dest.writeInt(largestNominalAppHeight); |
| 441 | dest.writeInt(logicalWidth); |
| 442 | dest.writeInt(logicalHeight); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 443 | DisplayCutout.ParcelableWrapper.writeCutoutToParcel(displayCutout, dest, flags); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 444 | dest.writeInt(rotation); |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 445 | dest.writeInt(modeId); |
| 446 | dest.writeInt(defaultModeId); |
| 447 | dest.writeInt(supportedModes.length); |
| 448 | for (int i = 0; i < supportedModes.length; i++) { |
| 449 | supportedModes[i].writeToParcel(dest, flags); |
| 450 | } |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 451 | dest.writeInt(colorMode); |
| 452 | dest.writeInt(supportedColorModes.length); |
| 453 | for (int i = 0; i < supportedColorModes.length; i++) { |
| 454 | dest.writeInt(supportedColorModes[i]); |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 455 | } |
Michael Wright | b082890 | 2016-04-27 19:26:16 -0400 | [diff] [blame] | 456 | dest.writeParcelable(hdrCapabilities, flags); |
Galia Peycheva | 056b3ee | 2019-06-26 14:05:12 +0200 | [diff] [blame] | 457 | dest.writeBoolean(minimalPostProcessingSupported); |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 458 | dest.writeInt(logicalDensityDpi); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 459 | dest.writeFloat(physicalXDpi); |
| 460 | dest.writeFloat(physicalYDpi); |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 461 | dest.writeLong(appVsyncOffsetNanos); |
| 462 | dest.writeLong(presentationDeadlineNanos); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 463 | dest.writeInt(state); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 464 | dest.writeInt(ownerUid); |
| 465 | dest.writeString(ownerPackageName); |
Wale Ogunwale | 361ca21 | 2014-11-20 11:42:38 -0800 | [diff] [blame] | 466 | dest.writeString(uniqueId); |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 467 | dest.writeInt(removeMode); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 468 | } |
| 469 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 470 | @Override |
| 471 | public int describeContents() { |
| 472 | return 0; |
| 473 | } |
| 474 | |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 475 | public Display.Mode getMode() { |
| 476 | return findMode(modeId); |
| 477 | } |
| 478 | |
| 479 | public Display.Mode getDefaultMode() { |
| 480 | return findMode(defaultModeId); |
| 481 | } |
| 482 | |
| 483 | private Display.Mode findMode(int id) { |
| 484 | for (int i = 0; i < supportedModes.length; i++) { |
| 485 | if (supportedModes[i].getModeId() == id) { |
| 486 | return supportedModes[i]; |
| 487 | } |
| 488 | } |
| 489 | throw new IllegalStateException("Unable to locate mode " + id); |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * Returns the id of the "default" mode with the given refresh rate, or {@code 0} if no suitable |
| 494 | * mode could be found. |
| 495 | */ |
| 496 | public int findDefaultModeByRefreshRate(float refreshRate) { |
| 497 | Display.Mode[] modes = supportedModes; |
| 498 | Display.Mode defaultMode = getDefaultMode(); |
| 499 | for (int i = 0; i < modes.length; i++) { |
| 500 | if (modes[i].matches( |
| 501 | defaultMode.getPhysicalWidth(), defaultMode.getPhysicalHeight(), refreshRate)) { |
| 502 | return modes[i].getModeId(); |
| 503 | } |
| 504 | } |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Returns the list of supported refresh rates in the default mode. |
| 510 | */ |
| 511 | public float[] getDefaultRefreshRates() { |
| 512 | Display.Mode[] modes = supportedModes; |
| 513 | ArraySet<Float> rates = new ArraySet<>(); |
| 514 | Display.Mode defaultMode = getDefaultMode(); |
| 515 | for (int i = 0; i < modes.length; i++) { |
| 516 | Display.Mode mode = modes[i]; |
| 517 | if (mode.getPhysicalWidth() == defaultMode.getPhysicalWidth() |
| 518 | && mode.getPhysicalHeight() == defaultMode.getPhysicalHeight()) { |
| 519 | rates.add(mode.getRefreshRate()); |
| 520 | } |
| 521 | } |
| 522 | float[] result = new float[rates.size()]; |
| 523 | int i = 0; |
| 524 | for (Float rate : rates) { |
| 525 | result[i++] = rate; |
| 526 | } |
| 527 | return result; |
| 528 | } |
| 529 | |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 530 | public void getAppMetrics(DisplayMetrics outMetrics) { |
| 531 | getAppMetrics(outMetrics, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 534 | public void getAppMetrics(DisplayMetrics outMetrics, DisplayAdjustments displayAdjustments) { |
| 535 | getMetricsWithSize(outMetrics, displayAdjustments.getCompatibilityInfo(), |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 536 | displayAdjustments.getConfiguration(), appWidth, appHeight); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 537 | } |
| 538 | |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 539 | public void getAppMetrics(DisplayMetrics outMetrics, CompatibilityInfo ci, |
| 540 | Configuration configuration) { |
| 541 | getMetricsWithSize(outMetrics, ci, configuration, appWidth, appHeight); |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | public void getLogicalMetrics(DisplayMetrics outMetrics, CompatibilityInfo compatInfo, |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 545 | Configuration configuration) { |
| 546 | getMetricsWithSize(outMetrics, compatInfo, configuration, logicalWidth, logicalHeight); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 549 | public int getNaturalWidth() { |
| 550 | return rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180 ? |
| 551 | logicalWidth : logicalHeight; |
| 552 | } |
| 553 | |
| 554 | public int getNaturalHeight() { |
| 555 | return rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180 ? |
| 556 | logicalHeight : logicalWidth; |
| 557 | } |
| 558 | |
Romain Guy | 408afbf | 2017-01-25 10:23:03 -0800 | [diff] [blame] | 559 | public boolean isHdr() { |
Andrii Kulian | 4acfd85 | 2017-01-26 19:43:13 -0800 | [diff] [blame] | 560 | int[] types = hdrCapabilities != null ? hdrCapabilities.getSupportedHdrTypes() : null; |
Romain Guy | 408afbf | 2017-01-25 10:23:03 -0800 | [diff] [blame] | 561 | return types != null && types.length > 0; |
| 562 | } |
| 563 | |
| 564 | public boolean isWideColorGamut() { |
| 565 | for (int colorMode : supportedColorModes) { |
| 566 | if (colorMode == Display.COLOR_MODE_DCI_P3 || colorMode > Display.COLOR_MODE_SRGB) { |
| 567 | return true; |
| 568 | } |
| 569 | } |
| 570 | return false; |
| 571 | } |
| 572 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 573 | /** |
| 574 | * Returns true if the specified UID has access to this display. |
| 575 | */ |
| 576 | public boolean hasAccess(int uid) { |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 577 | return Display.hasAccess(uid, flags, ownerUid, displayId); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 580 | private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfo compatInfo, |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 581 | Configuration configuration, int width, int height) { |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 582 | outMetrics.densityDpi = outMetrics.noncompatDensityDpi = logicalDensityDpi; |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 583 | outMetrics.density = outMetrics.noncompatDensity = |
| 584 | logicalDensityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 585 | outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density; |
| 586 | outMetrics.xdpi = outMetrics.noncompatXdpi = physicalXDpi; |
| 587 | outMetrics.ydpi = outMetrics.noncompatYdpi = physicalYDpi; |
| 588 | |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 589 | final Rect appBounds = configuration != null |
| 590 | ? configuration.windowConfiguration.getAppBounds() : null; |
| 591 | width = appBounds != null ? appBounds.width() : width; |
| 592 | height = appBounds != null ? appBounds.height() : height; |
Wale Ogunwale | 7c72668 | 2015-02-06 17:34:28 -0800 | [diff] [blame] | 593 | |
| 594 | outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width; |
| 595 | outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height; |
| 596 | |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 597 | if (!compatInfo.equals(CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO)) { |
| 598 | compatInfo.applyToDisplayMetrics(outMetrics); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 599 | } |
| 600 | } |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 601 | |
| 602 | // For debugging purposes |
| 603 | @Override |
| 604 | public String toString() { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 605 | StringBuilder sb = new StringBuilder(); |
| 606 | sb.append("DisplayInfo{\""); |
| 607 | sb.append(name); |
Dominik Laskowski | 1039ea50 | 2020-02-28 15:27:12 -0800 | [diff] [blame] | 608 | sb.append("\", displayId "); |
lumark | ec75b42 | 2019-01-07 15:58:38 +0800 | [diff] [blame] | 609 | sb.append(displayId); |
Dominik Laskowski | 1039ea50 | 2020-02-28 15:27:12 -0800 | [diff] [blame] | 610 | sb.append(flagsToString(flags)); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 611 | sb.append(", real "); |
| 612 | sb.append(logicalWidth); |
| 613 | sb.append(" x "); |
| 614 | sb.append(logicalHeight); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 615 | sb.append(", largest app "); |
| 616 | sb.append(largestNominalAppWidth); |
| 617 | sb.append(" x "); |
| 618 | sb.append(largestNominalAppHeight); |
| 619 | sb.append(", smallest app "); |
| 620 | sb.append(smallestNominalAppWidth); |
| 621 | sb.append(" x "); |
| 622 | sb.append(smallestNominalAppHeight); |
Dominik Laskowski | 1039ea50 | 2020-02-28 15:27:12 -0800 | [diff] [blame] | 623 | sb.append(", appVsyncOff "); |
| 624 | sb.append(appVsyncOffsetNanos); |
| 625 | sb.append(", presDeadline "); |
| 626 | sb.append(presentationDeadlineNanos); |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 627 | sb.append(", mode "); |
| 628 | sb.append(modeId); |
| 629 | sb.append(", defaultMode "); |
| 630 | sb.append(defaultModeId); |
| 631 | sb.append(", modes "); |
| 632 | sb.append(Arrays.toString(supportedModes)); |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 633 | sb.append(", hdrCapabilities "); |
| 634 | sb.append(hdrCapabilities); |
Galia Peycheva | 35f900a | 2020-01-09 14:31:05 +0100 | [diff] [blame] | 635 | sb.append(", minimalPostProcessingSupported "); |
| 636 | sb.append(minimalPostProcessingSupported); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 637 | sb.append(", rotation "); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 638 | sb.append(rotation); |
Dominik Laskowski | 1039ea50 | 2020-02-28 15:27:12 -0800 | [diff] [blame] | 639 | sb.append(", state "); |
| 640 | sb.append(Display.stateToString(state)); |
| 641 | |
| 642 | if (Process.myUid() != Process.SYSTEM_UID) { |
| 643 | sb.append("}"); |
| 644 | return sb.toString(); |
| 645 | } |
| 646 | |
| 647 | sb.append(", type "); |
| 648 | sb.append(Display.typeToString(type)); |
| 649 | sb.append(", uniqueId \""); |
| 650 | sb.append(uniqueId); |
| 651 | sb.append("\", app "); |
| 652 | sb.append(appWidth); |
| 653 | sb.append(" x "); |
| 654 | sb.append(appHeight); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 655 | sb.append(", density "); |
| 656 | sb.append(logicalDensityDpi); |
| 657 | sb.append(" ("); |
| 658 | sb.append(physicalXDpi); |
| 659 | sb.append(" x "); |
| 660 | sb.append(physicalYDpi); |
| 661 | sb.append(") dpi, layerStack "); |
| 662 | sb.append(layerStack); |
Dominik Laskowski | 1039ea50 | 2020-02-28 15:27:12 -0800 | [diff] [blame] | 663 | sb.append(", colorMode "); |
| 664 | sb.append(colorMode); |
| 665 | sb.append(", supportedColorModes "); |
| 666 | sb.append(Arrays.toString(supportedColorModes)); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 667 | if (address != null) { |
| 668 | sb.append(", address ").append(address); |
| 669 | } |
Marin Shalamanov | 98af159 | 2019-10-08 10:48:08 +0200 | [diff] [blame] | 670 | sb.append(", deviceProductInfo "); |
| 671 | sb.append(deviceProductInfo); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 672 | if (ownerUid != 0 || ownerPackageName != null) { |
| 673 | sb.append(", owner ").append(ownerPackageName); |
| 674 | sb.append(" (uid ").append(ownerUid).append(")"); |
| 675 | } |
Andrii Kulian | 250d653 | 2017-02-08 23:30:45 -0800 | [diff] [blame] | 676 | sb.append(", removeMode "); |
| 677 | sb.append(removeMode); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 678 | sb.append("}"); |
| 679 | return sb.toString(); |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 680 | } |
| 681 | |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 682 | /** |
| 683 | * Write to a protocol buffer output stream. |
| 684 | * Protocol buffer message definition at {@link android.view.DisplayInfoProto} |
| 685 | * |
| 686 | * @param protoOutputStream Stream to write the Rect object to. |
| 687 | * @param fieldId Field Id of the DisplayInfoProto as defined in the parent message |
| 688 | */ |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 689 | public void dumpDebug(ProtoOutputStream protoOutputStream, long fieldId) { |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 690 | final long token = protoOutputStream.start(fieldId); |
| 691 | protoOutputStream.write(LOGICAL_WIDTH, logicalWidth); |
| 692 | protoOutputStream.write(LOGICAL_HEIGHT, logicalHeight); |
| 693 | protoOutputStream.write(APP_WIDTH, appWidth); |
| 694 | protoOutputStream.write(APP_HEIGHT, appHeight); |
Andrii Kulian | 764e104 | 2018-02-08 15:12:14 -0800 | [diff] [blame] | 695 | protoOutputStream.write(NAME, name); |
Yan Zhu | 39b0e9a | 2019-07-22 11:23:13 -0700 | [diff] [blame] | 696 | protoOutputStream.write(FLAGS, flags); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 697 | protoOutputStream.end(token); |
| 698 | } |
| 699 | |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 700 | private static String flagsToString(int flags) { |
| 701 | StringBuilder result = new StringBuilder(); |
Jeff Brown | f0681b3 | 2012-10-23 17:35:57 -0700 | [diff] [blame] | 702 | if ((flags & Display.FLAG_SECURE) != 0) { |
| 703 | result.append(", FLAG_SECURE"); |
| 704 | } |
Jeff Brown | 77aebfd | 2012-10-01 21:07:03 -0700 | [diff] [blame] | 705 | if ((flags & Display.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) { |
| 706 | result.append(", FLAG_SUPPORTS_PROTECTED_BUFFERS"); |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 707 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 708 | if ((flags & Display.FLAG_PRIVATE) != 0) { |
| 709 | result.append(", FLAG_PRIVATE"); |
| 710 | } |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 711 | if ((flags & Display.FLAG_PRESENTATION) != 0) { |
| 712 | result.append(", FLAG_PRESENTATION"); |
| 713 | } |
Jeff Brown | d46747a | 2015-04-15 19:02:36 -0700 | [diff] [blame] | 714 | if ((flags & Display.FLAG_SCALING_DISABLED) != 0) { |
| 715 | result.append(", FLAG_SCALING_DISABLED"); |
| 716 | } |
Adam Powell | 49e7ff9 | 2015-05-14 16:18:53 -0700 | [diff] [blame] | 717 | if ((flags & Display.FLAG_ROUND) != 0) { |
| 718 | result.append(", FLAG_ROUND"); |
| 719 | } |
Jeff Brown | c5df37c | 2012-09-13 11:45:07 -0700 | [diff] [blame] | 720 | return result.toString(); |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 721 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 722 | } |