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

Commit 1e4473b1 authored by Vinit Nayak's avatar Vinit Nayak Committed by Automerger Merge Worker
Browse files

Merge "Add API to allow launcher to suspend AutoHideController" into sc-v2-dev am: dc8a13d6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16008929

Change-Id: I3c9f83c44474f5587a6f29041435169bad694b45
parents 89360346 dc8a13d6
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -143,5 +143,12 @@ interface ISystemUiProxy {
    /** Notifies when taskbar status updated */
    oneway void notifyTaskbarStatus(boolean visible, boolean stashed) = 47;

    // Next id = 48
    /**
     * Notifies sysui when taskbar requests autoHide to stop auto-hiding
     * If called to suspend, caller is also responsible for calling this method to un-suspend
     * @param suspend should be true to stop auto-hide, false to resume normal behavior
     */
    oneway void notifyTaskbarAutohideSuspend(boolean suspend) = 48;

    // Next id = 49
}
+5 −3
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue.Callbacks;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.BarTransitions.TransitionMode;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -160,7 +161,8 @@ public class NavigationBarController implements
            NavigationBarA11yHelper navigationBarA11yHelper,
            TaskbarDelegate taskbarDelegate,
            UserTracker userTracker,
            DumpManager dumpManager) {
            DumpManager dumpManager,
            AutoHideController autoHideController) {
        mContext = context;
        mWindowManager = windowManager;
        mAssistManagerLazy = assistManagerLazy;
@@ -194,9 +196,9 @@ public class NavigationBarController implements
        mNavMode = mNavigationModeController.addListener(this);
        mNavigationModeController.addListener(this);
        mTaskbarDelegate = taskbarDelegate;
        mTaskbarDelegate.setOverviewProxyService(commandQueue, overviewProxyService,
        mTaskbarDelegate.setDependencies(commandQueue, overviewProxyService,
                navigationBarA11yHelper, navigationModeController, sysUiFlagsContainer,
                dumpManager);
                dumpManager, autoHideController);
        mIsTablet = isTablet(mContext);
        mUserTracker = userTracker;

+78 −14
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.systemui.navigationbar;
import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.containsType;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

@@ -57,7 +59,9 @@ import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.statusbar.AutoHideUiElement;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.AutoHideController;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -77,6 +81,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
    private NavigationBarA11yHelper mNavigationBarA11yHelper;
    private NavigationModeController mNavigationModeController;
    private SysUiState mSysUiState;
    private AutoHideController mAutoHideController;
    private int mDisplayId;
    private int mNavigationIconHints;
    private final NavigationBarA11yHelper.NavA11yEventListener mNavA11yEventListener =
@@ -87,6 +92,28 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
    private final Context mContext;
    private final DisplayManager mDisplayManager;
    private Context mWindowContext;
    /**
     * Tracks the system calls for when taskbar should transiently show or hide so we can return
     * this value in {@link AutoHideUiElement#isVisible()} below.
     *
     * This also gets set by {@link #onTaskbarAutohideSuspend(boolean)} to force show the transient
     * taskbar if launcher has requested to suspend auto-hide behavior.
     */
    private boolean mTaskbarTransientShowing;
    private final AutoHideUiElement mAutoHideUiElement = new AutoHideUiElement() {
        @Override
        public void synchronizeState() {
        }

        @Override
        public boolean isVisible() {
            return mTaskbarTransientShowing;
        }

        @Override
        public void hide() {
        }
    };

    @Inject
    public TaskbarDelegate(Context context) {
@@ -96,11 +123,12 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
        mDisplayManager = mContext.getSystemService(DisplayManager.class);
    }

    public void setOverviewProxyService(CommandQueue commandQueue,
    public void setDependencies(CommandQueue commandQueue,
            OverviewProxyService overviewProxyService,
            NavigationBarA11yHelper navigationBarA11yHelper,
            NavigationModeController navigationModeController,
            SysUiState sysUiState, DumpManager dumpManager) {
            SysUiState sysUiState, DumpManager dumpManager,
            AutoHideController autoHideController) {
        // TODO: adding this in the ctor results in a dagger dependency cycle :(
        mCommandQueue = commandQueue;
        mOverviewProxyService = overviewProxyService;
@@ -108,18 +136,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
        mNavigationModeController = navigationModeController;
        mSysUiState = sysUiState;
        dumpManager.registerDumpable(this);
    }

    public void destroy() {
        mCommandQueue.removeCallback(this);
        mOverviewProxyService.removeCallback(this);
        mNavigationModeController.removeListener(this);
        mNavigationBarA11yHelper.removeA11yEventListener(mNavA11yEventListener);
        mEdgeBackGestureHandler.onNavBarDetached();
        if (mWindowContext != null) {
            mWindowContext.unregisterComponentCallbacks(this);
            mWindowContext = null;
        }
        mAutoHideController = autoHideController;
    }

    public void init(int displayId) {
@@ -136,6 +153,20 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
        mWindowContext.registerComponentCallbacks(this);
        // Set initial state for any listeners
        updateSysuiFlags();
        mAutoHideController.setNavigationBar(mAutoHideUiElement);
    }

    public void destroy() {
        mCommandQueue.removeCallback(this);
        mOverviewProxyService.removeCallback(this);
        mNavigationModeController.removeListener(this);
        mNavigationBarA11yHelper.removeA11yEventListener(mNavA11yEventListener);
        mEdgeBackGestureHandler.onNavBarDetached();
        if (mWindowContext != null) {
            mWindowContext.unregisterComponentCallbacks(this);
            mWindowContext = null;
        }
        mAutoHideController.setNavigationBar(null);
    }

    private void updateSysuiFlags() {
@@ -208,6 +239,38 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
        }
    }

    @Override
    public void showTransient(int displayId, int[] types) {
        if (displayId != mDisplayId) {
            return;
        }
        if (!containsType(types, ITYPE_NAVIGATION_BAR)) {
            return;
        }
        mTaskbarTransientShowing = true;
    }

    @Override
    public void abortTransient(int displayId, int[] types) {
        if (displayId != mDisplayId) {
            return;
        }
        if (!containsType(types, ITYPE_NAVIGATION_BAR)) {
            return;
        }
        mTaskbarTransientShowing = false;
    }

    @Override
    public void onTaskbarAutohideSuspend(boolean suspend) {
        mTaskbarTransientShowing = suspend;
        if (suspend) {
            mAutoHideController.suspendAutoHide();
        } else {
            mAutoHideController.resumeSuspendedAutoHide();
        }
    }

    @Override
    public void onNavigationModeChanged(int mode) {
        mEdgeBackGestureHandler.onNavigationModeChanged(mode);
@@ -236,6 +299,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
        pw.println("  mDisabledFlags=" + mDisabledFlags);
        pw.println("  mTaskBarWindowState=" + mTaskBarWindowState);
        pw.println("  mBehavior=" + mBehavior);
        pw.println("  mTaskbarTransientShowing=" + mTaskbarTransientShowing);
        mEdgeBackGestureHandler.dump(pw);
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -248,6 +248,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
                    onTaskbarStatusUpdated(visible, stashed));
        }

        @Override
        public void notifyTaskbarAutohideSuspend(boolean suspend) {
            verifyCallerAndClearCallingIdentityPostMain("notifyTaskbarAutohideSuspend", () ->
                    onTaskbarAutohideSuspend(suspend));
        }

        private boolean sendEvent(int action, int code) {
            long when = SystemClock.uptimeMillis();
            final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */,
@@ -818,6 +824,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
        }
    }

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

    private void notifyConnectionChanged() {
        for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
            mConnectionCallbacks.get(i).onConnectionChanged(mOverviewProxy != null);
@@ -1000,6 +1012,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
        default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
        default void onHomeRotationEnabled(boolean enabled) {}
        default void onTaskbarStatusUpdated(boolean visible, boolean stashed) {}
        default void onTaskbarAutohideSuspend(boolean suspend) {}
        default void onSystemUiStateChanged(int sysuiStateFlags) {}
        default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
        default void onAssistantGestureCompletion(float velocity) {}
+3 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class AutoHideController {
    private final Handler mHandler;

    private AutoHideUiElement mStatusBar;
    /** For tablets, this will represent the Taskbar */
    private AutoHideUiElement mNavigationBar;
    private int mDisplayId;

@@ -89,7 +90,7 @@ public class AutoHideController {
        }
    }

    void resumeSuspendedAutoHide() {
    public void resumeSuspendedAutoHide() {
        if (mAutoHideSuspended) {
            scheduleAutoHide();
            Runnable checkBarModesRunnable = getCheckBarModesRunnable();
@@ -99,7 +100,7 @@ public class AutoHideController {
        }
    }

    void suspendAutoHide() {
    public void suspendAutoHide() {
        mHandler.removeCallbacks(mAutoHide);
        Runnable checkBarModesRunnable = getCheckBarModesRunnable();
        if (checkBarModesRunnable != null) {
Loading