Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 36e9bcd8 authored by Danny Lin's avatar Danny Lin Committed by Michael Bestas
Browse files

SystemUI: Add API for runtime taskbar config

Allow Launcher3 to override the taskbar state at runtime based on user
preference.

Change-Id: Ic2616ff974e98e03edbcdbdf677fa40b40b37abb
parent e6bbee06
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@ interface ISystemUiProxy {
    /** Sets home rotation enabled. */
    oneway void setHomeRotationEnabled(boolean enabled) = 45;

    /** Notifies when taskbar is enabled or disabled */
    oneway void setTaskbarEnabled(boolean enabled) = 500;

    /** Notifies when taskbar status updated */
    oneway void notifyTaskbarStatus(boolean visible, boolean stashed) = 47;

+21 −9
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR;

import static com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler.DEBUG_MISSING_GESTURE_TAG;
import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen;
import static com.android.wm.shell.Flags.enableTaskbarNavbarUnification;

import android.content.Context;
@@ -78,6 +77,7 @@ import javax.inject.Inject;
public class NavigationBarControllerImpl implements
        ConfigurationController.ConfigurationListener,
        NavigationModeController.ModeChangedListener,
        OverviewProxyService.OverviewProxyListener,
        Dumpable, NavigationBarController {

    private static final String TAG = NavigationBarControllerImpl.class.getSimpleName();
@@ -95,7 +95,7 @@ public class NavigationBarControllerImpl implements
     * Indicates whether the active display is a large screen, e.g. tablets, foldable devices in
     * the unfolded state.
     */
    @VisibleForTesting boolean mIsLargeScreen;
    @VisibleForTesting boolean mTaskbarShowing;
    /**
     * Indicates whether the device is a phone, rather than everything else (e.g. foldables,
     * tablets) is considered not a handheld device.
@@ -149,7 +149,7 @@ public class NavigationBarControllerImpl implements
                navBarHelper, navigationModeController, sysUiFlagsContainer,
                dumpManager, autoHideController, lightBarController, pipOptional,
                backAnimation.orElse(null), taskStackChangeListeners);
        mIsLargeScreen = isLargeScreen(mContext);
        overviewProxyService.addCallback(this);
        mIsPhone =
                mContext.getResources().getIntArray(R.array.config_foldedDeviceStates).length == 0;
        dumpManager.registerDumpable(this);
@@ -157,10 +157,9 @@ public class NavigationBarControllerImpl implements

    @Override
    public void onConfigChanged(Configuration newConfig) {
        boolean isOldConfigLargeScreen = mIsLargeScreen;
        mIsLargeScreen = isLargeScreen(mContext);
        boolean oldShouldShowTaskbar = shouldShowTaskbar();
        boolean willApplyConfig = mConfigChanges.applyNewConfig(mContext.getResources());
        boolean largeScreenChanged = mIsLargeScreen != isOldConfigLargeScreen;
        boolean largeScreenChanged = shouldShowTaskbar() != oldShouldShowTaskbar;
        // TODO(b/332635834): Disable this logging once b/332635834 is fixed.
        Log.i(DEBUG_MISSING_GESTURE_TAG, "NavbarController: newConfig=" + newConfig
                + " mTaskbarDelegate initialized=" + mTaskbarDelegate.isInitialized()
@@ -206,6 +205,16 @@ public class NavigationBarControllerImpl implements
        });
    }

    @Override
    public void onTaskbarEnabled(boolean enabled) {
        boolean oldShouldShowTaskbar = shouldShowTaskbar();
        mTaskbarShowing = enabled;
        boolean largeScreenChanged = shouldShowTaskbar() != oldShouldShowTaskbar;
        if (largeScreenChanged) {
            updateNavbarForTaskbar();
        }
    }

    private void updateAccessibilityButtonModeIfNeeded() {
        final int mode = mSecureSettings.getIntForUser(
                Settings.Secure.ACCESSIBILITY_BUTTON_MODE,
@@ -286,7 +295,7 @@ public class NavigationBarControllerImpl implements
    @VisibleForTesting
    boolean supportsTaskbar() {
        // Enable for tablets, unfolded state on a foldable device or (non handheld AND flag is set)
        return mIsLargeScreen || (!mIsPhone && enableTaskbarNavbarUnification());
        return shouldShowTaskbar() || (!mIsPhone && enableTaskbarNavbarUnification());
    }

    private final CommandQueue.Callbacks mCommandQueueCallbacks = new CommandQueue.Callbacks() {
@@ -299,7 +308,6 @@ public class NavigationBarControllerImpl implements
        @Override
        public void onDisplayReady(int displayId) {
            Display display = mDisplayManager.getDisplay(displayId);
            mIsLargeScreen = isLargeScreen(mContext);
            createNavigationBar(display, null /* savedState */, null /* result */);
        }

@@ -488,6 +496,10 @@ public class NavigationBarControllerImpl implements
        }
    }

    private boolean shouldShowTaskbar() {
        return mTaskbarShowing;
    }

    @Override
    @Nullable
    public NavigationBar getDefaultNavigationBar() {
@@ -497,7 +509,7 @@ public class NavigationBarControllerImpl implements
    @NeverCompile
    @Override
    public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
        pw.println("mIsLargeScreen=" + mIsLargeScreen);
        pw.println("mTaskbarShowing=" + mTaskbarShowing);
        pw.println("mNavMode=" + mNavMode);
        for (int i = 0; i < mNavigationBars.size(); i++) {
            if (i > 0) {
+13 −0
Original line number Diff line number Diff line
@@ -311,6 +311,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                    mHandler.post(() -> notifyHomeRotationEnabled(enabled)));
        }

        @Override
        public void setTaskbarEnabled(boolean enabled) {
            verifyCallerAndClearCallingIdentityPostMain("setTaskbarEnabled", () ->
                    onTaskbarEnabled(enabled));
        }

        @Override
        public void notifyTaskbarStatus(boolean visible, boolean stashed) {
            verifyCallerAndClearCallingIdentityPostMain("notifyTaskbarStatus", () ->
@@ -925,6 +931,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        }
    }

    private void onTaskbarEnabled(boolean enabled) {
        for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
            mConnectionCallbacks.get(i).onTaskbarEnabled(enabled);
        }
    }

    private void onTaskbarStatusUpdated(boolean visible, boolean stashed) {
        for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
            mConnectionCallbacks.get(i).onTaskbarStatusUpdated(visible, stashed);
@@ -1138,6 +1150,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        /** Notify the recents app (overview) is started by 3-button navigation. */
        default void onToggleRecentApps() {}
        default void onHomeRotationEnabled(boolean enabled) {}
        default void onTaskbarEnabled(boolean enabled) {}
        default void onTaskbarStatusUpdated(boolean visible, boolean stashed) {}
        default void onTaskbarAutohideSuspend(boolean suspend) {}
        default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
+4 −4
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public class NavigationBarControllerImplTest extends SysuiTestCase {
        assumeFalse(enableTaskbarNavbarUnification());

        // Large screens may be using taskbar and the logic is different
        mNavigationBarController.mIsLargeScreen = false;
        mNavigationBarController.mTaskbarShowing = false;
        doNothing().when(mNavigationBarController).createNavigationBar(any(), any(), any());

        mNavigationBarController.createNavigationBars(true, null);
@@ -291,14 +291,14 @@ public class NavigationBarControllerImplTest extends SysuiTestCase {

    @Test
    public void testShouldRenderTaskbar_taskbarNotRenderedOnPhone() {
        mNavigationBarController.mIsLargeScreen = false;
        mNavigationBarController.mTaskbarShowing = false;
        mNavigationBarController.mIsPhone = true;
        assertFalse(mNavigationBarController.supportsTaskbar());
    }

    @Test
    public void testShouldRenderTaskbar_taskbarRenderedOnTabletOrUnfolded() {
        mNavigationBarController.mIsLargeScreen = true;
        mNavigationBarController.mTaskbarShowing = true;
        mNavigationBarController.mIsPhone = false;
        assertTrue(mNavigationBarController.supportsTaskbar());
    }
@@ -307,7 +307,7 @@ public class NavigationBarControllerImplTest extends SysuiTestCase {
    public void testShouldRenderTaskbar_taskbarRenderedInFoldedState() {
        assumeTrue(enableTaskbarNavbarUnification());

        mNavigationBarController.mIsLargeScreen = false;
        mNavigationBarController.mTaskbarShowing = false;
        mNavigationBarController.mIsPhone = false;
        assertTrue(mNavigationBarController.supportsTaskbar());
    }