From c8beebf5a3cf665a0aa7c91bcbaec93ca5bdb956 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Thu, 23 Sep 2021 10:18:11 -0700 Subject: [PATCH] Consolidate isTablet logic across Launcher and SysUI Fixes: 197960261 Test: Change display size; no nav bar and task bar showing at the same time Change-Id: I56753e9389a49ca3ee455b248a041b3c1569f153 --- src/com/android/launcher3/InvariantDeviceProfile.java | 2 +- src/com/android/launcher3/util/DisplayController.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 1799f26e06..5f441d183d 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -172,7 +172,7 @@ public class InvariantDeviceProfile { } new DeviceGridState(this).writeToPrefs(context); - DisplayController.INSTANCE.get(context).addChangeListener( + DisplayController.INSTANCE.get(context).setPriorityListener( (displayContext, info, flags) -> { if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS)) != 0) { onConfigChanged(displayContext); diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index 3a2b96182c..d05ba3d345 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -79,6 +79,8 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S // Null for SDK < S private final Context mWindowContext; + // The callback in this listener updates DeviceProfile, which other listeners might depend on + private DisplayInfoChangeListener mPriorityListener; private final ArrayList mListeners = new ArrayList<>(); private Info mInfo; @@ -207,6 +209,10 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S @Override public final void onLowMemory() { } + public void setPriorityListener(DisplayInfoChangeListener listener) { + mPriorityListener = listener; + } + public void addChangeListener(DisplayInfoChangeListener listener) { mListeners.add(listener); } @@ -261,6 +267,9 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S } private void notifyChange(Context context, int flags) { + if (mPriorityListener != null) { + mPriorityListener.onDisplayInfoChanged(context, mInfo, flags); + } for (int i = mListeners.size() - 1; i >= 0; i--) { mListeners.get(i).onDisplayInfoChanged(context, mInfo, flags); }