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

Unverified Commit 16ba639a 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 dbe86598
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -142,6 +142,9 @@ interface ISystemUiProxy {
    /** Notifies that a swipe-up gesture has started */
    oneway void notifySwipeUpGestureStarted() = 46;

    /** 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;

+22 −11
Original line number Diff line number Diff line
@@ -21,8 +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 android.view.Display.DEFAULT_DISPLAY;

import static com.android.systemui.shared.recents.utilities.Utilities.isTablet;

import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ActivityInfo;
@@ -76,6 +74,7 @@ public class NavigationBarController implements
        Callbacks,
        ConfigurationController.ConfigurationListener,
        NavigationModeController.ModeChangedListener,
        OverviewProxyService.OverviewProxyListener,
        Dumpable {

    private static final String TAG = NavigationBarController.class.getSimpleName();
@@ -87,7 +86,7 @@ public class NavigationBarController implements
    private final TaskbarDelegate mTaskbarDelegate;
    private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
    private int mNavMode;
    @VisibleForTesting boolean mIsTablet;
    private boolean mTaskbarShowing;

    /** A displayId - nav bar maps. */
    @VisibleForTesting
@@ -129,15 +128,14 @@ public class NavigationBarController implements
                navBarHelper, navigationModeController, sysUiFlagsContainer,
                dumpManager, autoHideController, lightBarController, pipOptional,
                backAnimation.orElse(null));
        mIsTablet = isTablet(mContext);
        overviewProxyService.addCallback(this);
        dumpManager.registerDumpable(this);
    }

    @Override
    public void onConfigChanged(Configuration newConfig) {
        boolean isOldConfigTablet = mIsTablet;
        mIsTablet = isTablet(mContext);
        boolean largeScreenChanged = mIsTablet != isOldConfigTablet;
        boolean oldShouldShowTaskbar = shouldShowTaskbar();
        boolean largeScreenChanged = shouldShowTaskbar() != oldShouldShowTaskbar;
        // If we folded/unfolded while in 3 button, show navbar in folded state, hide in unfolded
        if (largeScreenChanged && updateNavbarForTaskbar()) {
            return;
@@ -178,6 +176,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() {
        ContentResolver contentResolver = mContext.getContentResolver();
        final int mode = Settings.Secure.getIntForUser(contentResolver,
@@ -218,7 +226,7 @@ public class NavigationBarController implements

    /** @return {@code true} if taskbar is enabled, false otherwise */
    private boolean initializeTaskbarIfNecessary() {
        if (mIsTablet) {
        if (shouldShowTaskbar()) {
            Trace.beginSection("NavigationBarController#initializeTaskbarIfNecessary");
            // Remove navigation bar when taskbar is showing
            removeNavigationBar(mContext.getDisplayId());
@@ -227,7 +235,7 @@ public class NavigationBarController implements
        } else {
            mTaskbarDelegate.destroy();
        }
        return mIsTablet;
        return shouldShowTaskbar();
    }

    @Override
@@ -238,7 +246,6 @@ public class NavigationBarController implements
    @Override
    public void onDisplayReady(int displayId) {
        Display display = mDisplayManager.getDisplay(displayId);
        mIsTablet = isTablet(mContext);
        createNavigationBar(display, null /* savedState */, null /* result */);
    }

@@ -304,7 +311,7 @@ public class NavigationBarController implements

        // We may show TaskBar on the default display for large screen device. Don't need to create
        // navigation bar for this case.
        if (mIsTablet && isOnDefaultDisplay) {
        if (shouldShowTaskbar() && isOnDefaultDisplay) {
            return;
        }

@@ -439,6 +446,10 @@ public class NavigationBarController implements
        }
    }

    private boolean shouldShowTaskbar() {
        return mTaskbarShowing;
    }

    /** @return {@link NavigationBar} on the default display. */
    @Nullable
    public NavigationBar getDefaultNavigationBar() {
+13 −0
Original line number Diff line number Diff line
@@ -263,6 +263,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
                    mHandler.post(() -> notifyHomeRotationEnabled(enabled)));
        }

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

        @Override
        public void notifyTaskbarStatus(boolean visible, boolean stashed) {
            verifyCallerAndClearCallingIdentityPostMain("notifyTaskbarStatus", () ->
@@ -877,6 +883,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
        }
    }

    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);
@@ -1082,6 +1094,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
        /** Notify changes in the nav bar button alpha */
        default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
        default void onHomeRotationEnabled(boolean enabled) {}
        default void onTaskbarEnabled(boolean enabled) {}
        default void onTaskbarStatusUpdated(boolean visible, boolean stashed) {}
        default void onTaskbarAutohideSuspend(boolean suspend) {}
        default void onSystemUiStateChanged(int sysuiStateFlags) {}