Use mWindowContext instead of re-creating to avoid stale Resource
- ag/14286682 changed to re-create window context in onConfigChange, which regressed the stale Resource problem, changed back to use mWindowContext instead
- Removed unnecessary extraInternalDisplays empty check, as empty / before S is already handled inside Display Info CTOR
Test: Change display size between default and large, taskbar is enabled/disabled correctly
Bug: 181215299
Change-Id: I7397d2dc1a1ce8e132e706e9de592558df6a18e7
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index b751207..e2c0a32 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -106,12 +106,7 @@
extraInternalDisplays.add(new PortraitSize(size.x, size.y));
}
}
-
- if (extraInternalDisplays.isEmpty() || !Utilities.ATLEAST_S) {
- mInfo = new Info(createDisplayInfoContext(display), display, Collections.emptySet());
- } else {
- mInfo = new Info(mWindowContext, display, extraInternalDisplays);
- }
+ mInfo = new Info(getDisplayInfoContext(display), display, extraInternalDisplays);
mDM.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler());
}
@@ -201,10 +196,8 @@
return mInfo;
}
- private Context createDisplayInfoContext(Display display) {
- return Utilities.ATLEAST_S
- ? mContext.createWindowContext(display, TYPE_APPLICATION, null)
- : mContext.createDisplayContext(display);
+ private Context getDisplayInfoContext(Display display) {
+ return Utilities.ATLEAST_S ? mWindowContext : mContext.createDisplayContext(display);
}
@AnyThread
@@ -213,7 +206,7 @@
Set<PortraitSize> extraDisplaysSizes = oldInfo.mAllSizes.size() > 1
? oldInfo.mAllSizes : Collections.emptySet();
- Context displayContext = createDisplayInfoContext(display);
+ Context displayContext = getDisplayInfoContext(display);
Info newInfo = new Info(displayContext, display, extraDisplaysSizes);
int change = 0;
if (!newInfo.mScreenSizeDp.equals(oldInfo.mScreenSizeDp)) {