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

Unverified Commit 3233111e 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 841adbbd
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 android.content.Context;
import android.content.pm.ActivityInfo;
@@ -78,6 +77,7 @@ public class NavigationBarController implements
        Callbacks,
        ConfigurationController.ConfigurationListener,
        NavigationModeController.ModeChangedListener,
        OverviewProxyService.OverviewProxyListener,
        Dumpable {

    private static final String TAG = NavigationBarController.class.getSimpleName();
@@ -92,7 +92,7 @@ public class NavigationBarController implements
    private final TaskbarDelegate mTaskbarDelegate;
    private final NavBarHelper mNavBarHelper;
    private int mNavMode;
    @VisibleForTesting boolean mIsLargeScreen;
    @VisibleForTesting boolean mTaskbarShowing;

    /** A displayId - nav bar maps. */
    @VisibleForTesting
@@ -140,16 +140,15 @@ public class NavigationBarController implements
                navBarHelper, navigationModeController, sysUiFlagsContainer,
                dumpManager, autoHideController, lightBarController, pipOptional,
                backAnimation.orElse(null), taskStackChangeListeners);
        mIsLargeScreen = isLargeScreen(mContext);
        overviewProxyService.addCallback(this);
        dumpManager.registerDumpable(this);
    }

    @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/243765256): Disable this logging once b/243765256 is fixed.
        Log.i(DEBUG_MISSING_GESTURE_TAG, "NavbarController: newConfig=" + newConfig
                + " mTaskbarDelegate initialized=" + mTaskbarDelegate.isInitialized()
@@ -198,6 +197,16 @@ public class NavigationBarController 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,
@@ -250,7 +259,7 @@ public class NavigationBarController implements
    /** @return {@code true} if taskbar is enabled, false otherwise */
    private boolean initializeTaskbarIfNecessary() {
        // Enable for large screens or (phone AND flag is set); assuming phone = !mIsLargeScreen
        boolean taskbarEnabled = (mIsLargeScreen || mFeatureFlags.isEnabled(
        boolean taskbarEnabled = (shouldShowTaskbar() || mFeatureFlags.isEnabled(
                Flags.HIDE_NAVBAR_WINDOW)) && shouldCreateNavBarAndTaskBar(mContext.getDisplayId());

        if (taskbarEnabled) {
@@ -278,7 +287,6 @@ public class NavigationBarController implements
    @Override
    public void onDisplayReady(int displayId) {
        Display display = mDisplayManager.getDisplay(displayId);
        mIsLargeScreen = isLargeScreen(mContext);
        createNavigationBar(display, null /* savedState */, null /* result */);
    }

@@ -475,6 +483,10 @@ public class NavigationBarController implements
        }
    }

    private boolean shouldShowTaskbar() {
        return mTaskbarShowing;
    }

    /** @return {@link NavigationBar} on the default display. */
    @Nullable
    public NavigationBar getDefaultNavigationBar() {
@@ -483,7 +495,7 @@ public class NavigationBarController implements

    @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
@@ -274,6 +274,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", () ->
@@ -872,6 +878,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);
@@ -1058,6 +1070,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) {}
+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ public class NavigationBarControllerTest extends SysuiTestCase {
    @Test
    public void testCreateNavigationBarsIncludeDefaultTrue() {
        // 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);