From 4bf5a1d199516d3c12360adc22378ca7e808f73f Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 15 Jun 2021 13:13:57 -0700 Subject: [PATCH] Enable 3 button nav for taskbar Bug: 180046394 Test: Switched between gesture and button nav on phone and tablet. Change-Id: I14d05d050e766f9a8a2d44c4ec786af9dc24dd8c --- .../NavigationBarController.java | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java index 3eb0c310bc913..d4f82513fc3de 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java @@ -27,7 +27,6 @@ import android.hardware.display.DisplayManager; import android.os.Bundle; import android.os.Handler; import android.os.RemoteException; -import android.os.SystemProperties; import android.util.DisplayMetrics; import android.util.Log; import android.util.SparseArray; @@ -235,27 +234,28 @@ public class NavigationBarController implements Callbacks, }); } - /** - * @return {@code true} if navbar was added/removed, false otherwise - */ - public boolean updateNavbarForTaskbar() { - if (!isThreeButtonTaskbarFlagEnabled()) { - return false; + /** @see #initializeTaskbarIfNecessary() */ + private boolean updateNavbarForTaskbar() { + boolean taskbarShown = initializeTaskbarIfNecessary(); + if (!taskbarShown && mNavigationBars.get(mContext.getDisplayId()) == null) { + createNavigationBar(mContext.getDisplay(), null, null); } + return taskbarShown; + } - if (mIsTablet && mNavMode == NAV_BAR_MODE_3BUTTON) { + /** @return {@code true} if taskbar is enabled, false otherwise */ + private boolean initializeTaskbarIfNecessary() { + boolean isShowingTaskbar = mIsTablet && mNavMode == NAV_BAR_MODE_3BUTTON; + if (isShowingTaskbar) { // Remove navigation bar when taskbar is showing, currently only for 3 button mode removeNavigationBar(mContext.getDisplayId()); mCommandQueue.addCallback(mTaskbarDelegate); mTaskbarDelegate.init(mContext.getDisplayId()); - } else if (mNavigationBars.get(mContext.getDisplayId()) == null) { - // Add navigation bar after taskbar goes away - createNavigationBar(mContext.getDisplay(), null, null); + } else { mCommandQueue.removeCallback(mTaskbarDelegate); mTaskbarDelegate.destroy(); } - - return true; + return isShowingTaskbar; } @Override @@ -302,7 +302,7 @@ public class NavigationBarController implements Callbacks, */ public void createNavigationBars(final boolean includeDefaultDisplay, RegisterStatusBarResult result) { - if (updateNavbarForTaskbar()) { + if (initializeTaskbarIfNecessary()) { return; } @@ -326,7 +326,7 @@ public class NavigationBarController implements Callbacks, return; } - if (isThreeButtonTaskbarEnabled()) { + if (mIsTablet && mNavMode == NAV_BAR_MODE_3BUTTON) { return; } @@ -461,15 +461,6 @@ public class NavigationBarController implements Callbacks, return mNavigationBars.get(DEFAULT_DISPLAY); } - private boolean isThreeButtonTaskbarEnabled() { - return mIsTablet && mNavMode == NAV_BAR_MODE_3BUTTON && - isThreeButtonTaskbarFlagEnabled(); - } - - private boolean isThreeButtonTaskbarFlagEnabled() { - return SystemProperties.getBoolean("persist.debug.taskbar_three_button", false); - } - private boolean isTablet(Configuration newConfig) { float density = Resources.getSystem().getDisplayMetrics().density; int size = Math.min((int) (density * newConfig.screenWidthDp),