@@ -232,19 +232,32 @@ public boolean equals(Object o) {
232232 * @return True if the display metrics are equal.
233233 */
234234 public boolean equals (DisplayMetrics other ) {
235+ return equalsPhysical (other )
236+ && scaledDensity == other .scaledDensity
237+ && noncompatScaledDensity == other .noncompatScaledDensity ;
238+ }
239+
240+ /**
241+ * Returns true if the physical aspects of the two display metrics
242+ * are equal. This ignores the scaled density, which is a logical
243+ * attribute based on the current desired font size.
244+ *
245+ * @param other The display metrics with which to compare.
246+ * @return True if the display metrics are equal.
247+ * @hide
248+ */
249+ public boolean equalsPhysical (DisplayMetrics other ) {
235250 return other != null
236251 && widthPixels == other .widthPixels
237252 && heightPixels == other .heightPixels
238253 && density == other .density
239254 && densityDpi == other .densityDpi
240- && scaledDensity == other .scaledDensity
241255 && xdpi == other .xdpi
242256 && ydpi == other .ydpi
243257 && noncompatWidthPixels == other .noncompatWidthPixels
244258 && noncompatHeightPixels == other .noncompatHeightPixels
245259 && noncompatDensity == other .noncompatDensity
246260 && noncompatDensityDpi == other .noncompatDensityDpi
247- && noncompatScaledDensity == other .noncompatScaledDensity
248261 && noncompatXdpi == other .noncompatXdpi
249262 && noncompatYdpi == other .noncompatYdpi ;
250263 }
0 commit comments