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