Use Diplay.getMetrics in DisplayController
- This is a workaround of b/163815566, where DisplayMetrics is stale
when onDisplayChanged is called.
- Instead of relying on stale DisplayConext, get the DisplayMetrics
from the Display directly.
- Also optimized how DisplayController.Info is created by passing in
Display only
- Use mDisplayContext.getDisplay directly if availalbe
Bug: 163815566, 160544577
Test: DPI looks correct on device boot
Change-Id: I2a7454bb8cf2073ce592e8662781b87fc998444f
(cherry picked from commit 177c38243dc3bf245d1f7db3c265dfb56522f441)
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 370bd6f..ff53b5f 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -201,7 +201,7 @@
DisplayController.getDefaultDisplay(context).getInfo(),
getPredefinedDeviceProfiles(context, gridName));
- Info myInfo = new Info(context, display);
+ Info myInfo = new Info(display);
DisplayOption myDisplayOption = invDistWeightedInterpolate(
myInfo, getPredefinedDeviceProfiles(context, gridName));