From 79dcb872898927a1a722b393e9f5b910216b993d Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 6 Aug 2020 19:43:36 -0700 Subject: [PATCH] Ignore nav bar alpha changes while user is not yet setup - SUW can change the display configuration which causes the nav bar fragment to be recreated which adds a listener to OverviewProxyService which calls back this method with the last alpha (default 1). When in 2/3 button, it's not an issue because the back button is visible anyways. But since we switched to gesture nav during SUW with the artifical back button, this code was causing the home handle to be updated as well to alpha 1. Bug: 161081668 Test: Start SUW > Change font size > verify bar doesn't show Change-Id: If0271d78d319f89f25d4c51da29e6676e8218812 --- .../phone/NavigationBarFragment.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 6297052550c31..892ff159d60b8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -120,7 +120,6 @@ import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.AutoHideUiElement; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue.Callbacks; -import com.android.systemui.statusbar.NavigationBarController; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.stack.StackStateAnimator; @@ -132,7 +131,6 @@ import com.android.systemui.util.LifecycleFragment; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.lang.ref.WeakReference; import java.util.List; import java.util.Locale; import java.util.Optional; @@ -194,6 +192,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback private int mLayoutDirection; private boolean mForceNavBarHandleOpaque; + private boolean mIsCurrentUserSetup; /** @see android.view.WindowInsetsController#setSystemBarsAppearance(int) */ private @Appearance int mAppearance; @@ -313,6 +312,10 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback @Override public void onNavBarButtonAlphaChanged(float alpha, boolean animate) { + if (!mIsCurrentUserSetup) { + // If the current user is not yet setup, then don't update any button alphas + return; + } ButtonDispatcher buttonDispatcher = null; boolean forceVisible = false; if (QuickStepContract.isSwipeUpMode(mNavBarMode)) { @@ -386,6 +389,14 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback } }; + private final DeviceProvisionedController.DeviceProvisionedListener mUserSetupListener = + new DeviceProvisionedController.DeviceProvisionedListener() { + @Override + public void onUserSetupChanged() { + mIsCurrentUserSetup = mDeviceProvisionedController.isCurrentUserSetup(); + } + }; + @Inject public NavigationBarFragment(AccessibilityManagerWrapper accessibilityManagerWrapper, DeviceProvisionedController deviceProvisionedController, MetricsLogger metricsLogger, @@ -453,6 +464,9 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback /* defaultValue = */ true); DeviceConfig.addOnPropertiesChangedListener( DeviceConfig.NAMESPACE_SYSTEMUI, mHandler::post, mOnPropertiesChangedListener); + + mIsCurrentUserSetup = mDeviceProvisionedController.isCurrentUserSetup(); + mDeviceProvisionedController.addCallback(mUserSetupListener); } @Override @@ -461,6 +475,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback mNavigationModeController.removeListener(this); mAccessibilityManagerWrapper.removeCallback(mAccessibilityListener); mContentResolver.unregisterContentObserver(mAssistContentObserver); + mDeviceProvisionedController.removeCallback(mUserSetupListener); DeviceConfig.removeOnPropertiesChangedListener(mOnPropertiesChangedListener); }