From c9a7b45ed6c10a3f7e41616a341abf854a0dd69e Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 1 Jun 2021 16:42:44 -0700 Subject: [PATCH] Pass nav button disable and AOD events to launcher Bug: 180046394 Change-Id: Ic6f552f57b48fc15b9873e59e3d8b53a17e312d6 --- .../shared/system/QuickStepContract.java | 6 +++- .../systemui/accessibility/SystemActions.java | 2 +- .../systemui/dagger/DependencyProvider.java | 7 +++-- .../NavigationBarController.java | 6 ++-- .../navigationbar/TaskbarDelegate.java | 15 +++++++--- .../recents/OverviewProxyService.java | 28 ++++++++++--------- ...NotificationShadeWindowControllerImpl.java | 3 +- .../phone/StatusBarWindowCallback.java | 3 +- .../NavigationBarControllerTest.java | 12 ++++++-- 9 files changed, 55 insertions(+), 27 deletions(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java index 153708a19d220..4663a9afcd3d3 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java @@ -114,6 +114,8 @@ public class QuickStepContract { public static final int SYSUI_STATE_MAGNIFICATION_OVERLAP = 1 << 19; // ImeSwitcher is showing public static final int SYSUI_STATE_IME_SWITCHER_SHOWING = 1 << 20; + // Device dozing/AOD state + public static final int SYSUI_STATE_DEVICE_DOZING = 1 << 21; @Retention(RetentionPolicy.SOURCE) @IntDef({SYSUI_STATE_SCREEN_PINNING, @@ -136,7 +138,8 @@ public class QuickStepContract { SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY, SYSUI_STATE_IME_SHOWING, SYSUI_STATE_MAGNIFICATION_OVERLAP, - SYSUI_STATE_IME_SWITCHER_SHOWING + SYSUI_STATE_IME_SWITCHER_SHOWING, + SYSUI_STATE_DEVICE_DOZING }) public @interface SystemUiStateFlags {} @@ -166,6 +169,7 @@ public class QuickStepContract { str.add((flags & SYSUI_STATE_IME_SHOWING) != 0 ? "ime_visible" : ""); str.add((flags & SYSUI_STATE_MAGNIFICATION_OVERLAP) != 0 ? "magnification_overlap" : ""); str.add((flags & SYSUI_STATE_IME_SWITCHER_SHOWING) != 0 ? "ime_switcher_showing" : ""); + str.add((flags & SYSUI_STATE_DEVICE_DOZING) != 0 ? "device_dozing" : ""); return str.toString(); } diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java index ca2c034c5d326..fa56453a89929 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java @@ -161,7 +161,7 @@ public class SystemActions extends SystemUI { mNotificationShadeController = notificationShadeController; // Saving in instance variable since to prevent GC since // NotificationShadeWindowController.registerCallback() only keeps weak references. - mNotificationShadeCallback = (keyguardShowing, keyguardOccluded, bouncerShowing) -> + mNotificationShadeCallback = (keyguardShowing, keyguardOccluded, bouncerShowing, mDozing) -> registerOrUnregisterDismissNotificationShadeAction(); mStatusBar = statusBar; } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java b/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java index 9a121ba8dc2dc..509ae7f92e10d 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java @@ -64,6 +64,7 @@ import com.android.systemui.navigationbar.NavigationBarA11yHelper; import com.android.systemui.navigationbar.NavigationBarController; import com.android.systemui.navigationbar.NavigationBarOverlayController; import com.android.systemui.navigationbar.NavigationModeController; +import com.android.systemui.navigationbar.TaskbarDelegate; import com.android.systemui.plugins.PluginInitializerImpl; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.qs.ReduceBrightColorsController; @@ -233,7 +234,8 @@ public class DependencyProvider { UiEventLogger uiEventLogger, NavigationBarOverlayController navBarOverlayController, ConfigurationController configurationController, - NavigationBarA11yHelper navigationBarA11yHelper) { + NavigationBarA11yHelper navigationBarA11yHelper, + TaskbarDelegate taskbarDelegate) { return new NavigationBarController(context, windowManager, assistManagerLazy, @@ -259,7 +261,8 @@ public class DependencyProvider { uiEventLogger, navBarOverlayController, configurationController, - navigationBarA11yHelper); + navigationBarA11yHelper, + taskbarDelegate); } /** */ diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java index 30eb645e43928..3eb0c310bc913 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java @@ -153,7 +153,8 @@ public class NavigationBarController implements Callbacks, UiEventLogger uiEventLogger, NavigationBarOverlayController navBarOverlayController, ConfigurationController configurationController, - NavigationBarA11yHelper navigationBarA11yHelper) { + NavigationBarA11yHelper navigationBarA11yHelper, + TaskbarDelegate taskbarDelegate) { mContext = context; mWindowManager = windowManager; mAssistManagerLazy = assistManagerLazy; @@ -185,7 +186,8 @@ public class NavigationBarController implements Callbacks, mNavBarOverlayController = navBarOverlayController; mNavMode = mNavigationModeController.addListener(this); mNavigationModeController.addListener(this); - mTaskbarDelegate = new TaskbarDelegate(mOverviewProxyService, + mTaskbarDelegate = taskbarDelegate; + mTaskbarDelegate.setOverviewProxyService(overviewProxyService, navigationBarA11yHelper, mSysUiFlagsContainer); mIsTablet = isTablet(mContext.getResources().getConfiguration()); } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java b/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java index e9674c9acedeb..40afed30f4e22 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java @@ -33,19 +33,26 @@ import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.shared.recents.utilities.Utilities; import com.android.systemui.statusbar.CommandQueue; +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton public class TaskbarDelegate implements CommandQueue.Callbacks { - private final OverviewProxyService mOverviewProxyService; - private final NavigationBarA11yHelper mNavigationBarA11yHelper; - private final SysUiState mSysUiState; + private OverviewProxyService mOverviewProxyService; + private NavigationBarA11yHelper mNavigationBarA11yHelper; + private SysUiState mSysUiState; private int mDisplayId; private int mNavigationIconHints; private final NavigationBarA11yHelper.NavA11yEventListener mNavA11yEventListener = this::updateSysuiFlags; + @Inject + public TaskbarDelegate() { /* no-op */ } - public TaskbarDelegate(OverviewProxyService overviewProxyService, + public void setOverviewProxyService(OverviewProxyService overviewProxyService, NavigationBarA11yHelper navigationBarA11yHelper, SysUiState sysUiState) { + // TODO: adding this in the ctor results in a dagger dependency cycle :( mOverviewProxyService = overviewProxyService; mNavigationBarA11yHelper = navigationBarA11yHelper; mSysUiState = sysUiState; diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index c0831a4688172..960ddde2da3a0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -34,6 +34,7 @@ import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SUP import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SYSUI_PROXY; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_WINDOW_CORNER_RADIUS; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING; +import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DOZING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TRACING_ENABLED; @@ -739,12 +740,13 @@ public class OverviewProxyService extends CurrentUserTracker implements } private void onStatusBarStateChanged(boolean keyguardShowing, boolean keyguardOccluded, - boolean bouncerShowing) { + boolean bouncerShowing, boolean isDozing) { mSysUiState.setFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING, keyguardShowing && !keyguardOccluded) .setFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED, keyguardShowing && keyguardOccluded) .setFlag(SYSUI_STATE_BOUNCER_SHOWING, bouncerShowing) + .setFlag(SYSUI_STATE_DEVICE_DOZING, isDozing) .commitUpdate(mContext.getDisplayId()); } @@ -974,18 +976,6 @@ public class OverviewProxyService extends CurrentUserTracker implements } } - public void onRotationProposal(int rotation, boolean isValid) { - try { - if (mOverviewProxy != null) { - mOverviewProxy.onRotationProposal(rotation, isValid); - } else { - Log.e(TAG_OPS, "Failed to get overview proxy for proposing rotation."); - } - } catch (RemoteException e) { - Log.e(TAG_OPS, "Failed to call onRotationProposal()", e); - } - } - public void disable(int displayId, int state1, int state2, boolean animate) { try { if (mOverviewProxy != null) { @@ -998,6 +988,18 @@ public class OverviewProxyService extends CurrentUserTracker implements } } + public void onRotationProposal(int rotation, boolean isValid) { + try { + if (mOverviewProxy != null) { + mOverviewProxy.onRotationProposal(rotation, isValid); + } else { + Log.e(TAG_OPS, "Failed to get overview proxy for proposing rotation."); + } + } catch (RemoteException e) { + Log.e(TAG_OPS, "Failed to call onRotationProposal()", e); + } + } + public void onSystemBarAttributesChanged(int displayId, int behavior) { try { if (mOverviewProxy != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java index 52f9aca827838..a5c4ffd91ccdb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java @@ -435,7 +435,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW if (cb != null) { cb.onStateChanged(mCurrentState.mKeyguardShowing, mCurrentState.mKeyguardOccluded, - mCurrentState.mBouncerShowing); + mCurrentState.mBouncerShowing, + mCurrentState.mDozing); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowCallback.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowCallback.java index f33ff2732cdaa..ac43b679da0f0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowCallback.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowCallback.java @@ -16,5 +16,6 @@ package com.android.systemui.statusbar.phone; public interface StatusBarWindowCallback { - void onStateChanged(boolean keyguardShowing, boolean keyguardOccluded, boolean bouncerShowing); + void onStateChanged(boolean keyguardShowing, boolean keyguardOccluded, boolean bouncerShowing, + boolean isDozing); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerTest.java index 3b5431f1445ac..bde44d68599da 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerTest.java @@ -79,6 +79,8 @@ public class NavigationBarControllerTest extends SysuiTestCase { private NavigationBar mDefaultNavBar; private NavigationBar mSecondaryNavBar; + private CommandQueue mCommandQueue = mock(CommandQueue.class); + private static final int SECONDARY_DISPLAY = 1; @Before @@ -97,7 +99,7 @@ public class NavigationBarControllerTest extends SysuiTestCase { mock(StatusBarStateController.class), mock(SysUiState.class), mock(BroadcastDispatcher.class), - mock(CommandQueue.class), + mCommandQueue, Optional.of(mock(Pip.class)), Optional.of(mock(LegacySplitScreen.class)), Optional.of(mock(Recents.class)), @@ -109,7 +111,8 @@ public class NavigationBarControllerTest extends SysuiTestCase { mock(UiEventLogger.class), mock(NavigationBarOverlayController.class), mock(ConfigurationController.class), - mock(NavigationBarA11yHelper.class))); + mock(NavigationBarA11yHelper.class), + mock(TaskbarDelegate.class))); initializeNavigationBars(); } @@ -272,4 +275,9 @@ public class NavigationBarControllerTest extends SysuiTestCase { verify(mSecondaryNavBar).disableAnimationsDuringHide(eq(500L)); } + + @Test + public void test3ButtonTaskbarFlagDisabledNoRegister() { + verify(mCommandQueue, never()).addCallback(any(TaskbarDelegate.class)); + } }