2121import android .os .Parcelable ;
2222import android .util .DisplayMetrics ;
2323
24+ import libcore .util .Objects ;
25+
2426/**
2527 * Describes the characteristics of a particular logical display.
2628 * @hide
2729 */
2830public final class DisplayInfo implements Parcelable {
31+ /**
32+ * The surface flinger layer stack associated with this logical display.
33+ */
34+ public int layerStack ;
35+
36+ /**
37+ * The human-readable name of the display.
38+ */
39+ public String name ;
40+
2941 /**
3042 * The width of the portion of the display that is available to applications, in pixels.
3143 * Represents the size of the display minus any system decorations.
@@ -147,11 +159,37 @@ private DisplayInfo(Parcel source) {
147159 }
148160
149161 @ Override
150- public int describeContents () {
151- return 0 ;
162+ public boolean equals (Object o ) {
163+ return o instanceof DisplayInfo && equals ((DisplayInfo )o );
164+ }
165+
166+ public boolean equals (DisplayInfo other ) {
167+ return other != null
168+ && layerStack == other .layerStack
169+ && Objects .equal (name , other .name )
170+ && appWidth == other .appWidth
171+ && appHeight == other .appHeight
172+ && smallestNominalAppWidth == other .smallestNominalAppWidth
173+ && smallestNominalAppHeight == other .smallestNominalAppHeight
174+ && largestNominalAppWidth == other .largestNominalAppWidth
175+ && largestNominalAppHeight == other .largestNominalAppHeight
176+ && logicalWidth == other .logicalWidth
177+ && logicalHeight == other .logicalHeight
178+ && rotation == other .rotation
179+ && refreshRate == other .refreshRate
180+ && logicalDensityDpi == other .logicalDensityDpi
181+ && physicalXDpi == other .physicalXDpi
182+ && physicalYDpi == other .physicalYDpi ;
183+ }
184+
185+ @ Override
186+ public int hashCode () {
187+ return 0 ; // don't care
152188 }
153189
154190 public void copyFrom (DisplayInfo other ) {
191+ layerStack = other .layerStack ;
192+ name = other .name ;
155193 appWidth = other .appWidth ;
156194 appHeight = other .appHeight ;
157195 smallestNominalAppWidth = other .smallestNominalAppWidth ;
@@ -168,6 +206,8 @@ public void copyFrom(DisplayInfo other) {
168206 }
169207
170208 public void readFromParcel (Parcel source ) {
209+ layerStack = source .readInt ();
210+ name = source .readString ();
171211 appWidth = source .readInt ();
172212 appHeight = source .readInt ();
173213 smallestNominalAppWidth = source .readInt ();
@@ -185,6 +225,8 @@ public void readFromParcel(Parcel source) {
185225
186226 @ Override
187227 public void writeToParcel (Parcel dest , int flags ) {
228+ dest .writeInt (layerStack );
229+ dest .writeString (name );
188230 dest .writeInt (appWidth );
189231 dest .writeInt (appHeight );
190232 dest .writeInt (smallestNominalAppWidth );
@@ -200,6 +242,11 @@ public void writeToParcel(Parcel dest, int flags) {
200242 dest .writeFloat (physicalYDpi );
201243 }
202244
245+ @ Override
246+ public int describeContents () {
247+ return 0 ;
248+ }
249+
203250 public void getAppMetrics (DisplayMetrics outMetrics , CompatibilityInfoHolder cih ) {
204251 getMetricsWithSize (outMetrics , cih , appWidth , appHeight );
205252 }
@@ -231,13 +278,14 @@ private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfoHold
231278 // For debugging purposes
232279 @ Override
233280 public String toString () {
234- return "app " + appWidth + " x " + appHeight
281+ return "DisplayInfo{ \" " + name + " \" , app " + appWidth + " x " + appHeight
235282 + ", real " + logicalWidth + " x " + logicalHeight
236283 + ", largest app " + largestNominalAppWidth + " x " + largestNominalAppHeight
237284 + ", smallest app " + smallestNominalAppWidth + " x " + smallestNominalAppHeight
238285 + ", " + refreshRate + " fps"
239286 + ", rotation " + rotation
240287 + ", density " + logicalDensityDpi
241- + ", " + physicalXDpi + " x " + physicalYDpi + " dpi" ;
288+ + ", " + physicalXDpi + " x " + physicalYDpi + " dpi"
289+ + ", layerStack " + layerStack + "}" ;
242290 }
243291}
0 commit comments