Pass config changes through to TaskbarDelegate

* Previously TaskbarDelegate was listening for config
changes, but there was a race condition between when
it was initialized and when the config change
callback happened. The callback didn't re-fire after
TaskbarDelegate became a listener for it.
* Rely on NavigationBarController, whose lifecycle
outlives TaskbarDelegate, to pass through config
changes to TaskbarDelegate (similar to how it's doing
for NavigationBar today)

* One caveat is that previously TaskbarDelegate was
relying on WM.ComponentCallbacks#onConfigChanged()
whereas NavigationBarController gets its config
changes from Application#onConfigurationChanged()

Fixes: 243765256
Test: Repro in bug no longer happens
Change-Id: Ifa7ea26946e6e68f74d095cbdf1e274d6a39b6b7
This commit is contained in:
Vinit Nayak
2022-10-04 16:54:37 -07:00
parent a04b35b697
commit 91374458b0
3 changed files with 11 additions and 14 deletions

View File

@@ -142,6 +142,9 @@ public class NavigationBarController implements
boolean isOldConfigTablet = mIsTablet;
mIsTablet = isTablet(mContext);
boolean largeScreenChanged = mIsTablet != isOldConfigTablet;
if (mTaskbarDelegate.isInitialized()) {
mTaskbarDelegate.onConfigurationChanged(newConfig);
}
// If we folded/unfolded while in 3 button, show navbar in folded state, hide in unfolded
if (largeScreenChanged && updateNavbarForTaskbar()) {
return;

View File

@@ -40,7 +40,6 @@ import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode
import android.app.StatusBarManager;
import android.app.StatusBarManager.WindowVisibleState;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
@@ -87,7 +86,7 @@ import javax.inject.Inject;
@SysUISingleton
public class TaskbarDelegate implements CommandQueue.Callbacks,
OverviewProxyService.OverviewProxyListener, NavigationModeController.ModeChangedListener,
ComponentCallbacks, Dumpable {
Dumpable {
private static final String TAG = TaskbarDelegate.class.getSimpleName();
private final EdgeBackGestureHandler mEdgeBackGestureHandler;
@@ -225,7 +224,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
// Initialize component callback
Display display = mDisplayManager.getDisplay(displayId);
mWindowContext = mContext.createWindowContext(display, TYPE_APPLICATION, null);
mWindowContext.registerComponentCallbacks(this);
mScreenPinningNotify = new ScreenPinningNotify(mWindowContext);
// Set initial state for any listeners
updateSysuiFlags();
@@ -233,6 +231,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
mLightBarController.setNavigationBar(mLightBarTransitionsController);
mPipOptional.ifPresent(this::addPipExclusionBoundsChangeListener);
mEdgeBackGestureHandler.setBackAnimation(mBackAnimation);
mEdgeBackGestureHandler.onConfigurationChanged(mContext.getResources().getConfiguration());
mInitialized = true;
}
@@ -247,10 +246,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
mNavBarHelper.destroy();
mEdgeBackGestureHandler.onNavBarDetached();
mScreenPinningNotify = null;
if (mWindowContext != null) {
mWindowContext.unregisterComponentCallbacks(this);
mWindowContext = null;
}
mWindowContext = null;
mAutoHideController.setNavigationBar(null);
mLightBarTransitionsController.destroy();
mLightBarController.setNavigationBar(null);
@@ -267,8 +263,9 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
}
/**
* Returns {@code true} if this taskBar is {@link #init(int)}. Returns {@code false} if this
* taskbar has not yet been {@link #init(int)} or has been {@link #destroy()}.
* Returns {@code true} if this taskBar is {@link #init(int)}.
* Returns {@code false} if this taskbar has not yet been {@link #init(int)}
* or has been {@link #destroy()}.
*/
public boolean isInitialized() {
return mInitialized;
@@ -460,14 +457,10 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
return mBehavior == BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
}
@Override
public void onConfigurationChanged(Configuration configuration) {
mEdgeBackGestureHandler.onConfigurationChanged(configuration);
}
@Override
public void onLowMemory() {}
@Override
public void showPinningEnterExitToast(boolean entering) {
updateSysuiFlags();

View File

@@ -19,6 +19,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_
import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
@@ -955,7 +956,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
mStartingQuickstepRotation != rotation;
}
public void onConfigurationChanged(Configuration newConfig) {
public void onConfigurationChanged(@NonNull Configuration newConfig) {
if (mStartingQuickstepRotation > -1) {
updateDisabledForQuickstep(newConfig);
}