From a706700a316b63eb7f95ea458544bf67bde41ca1 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 7 May 2019 11:50:42 -0700 Subject: [PATCH] Clean up system ui state flags - Move setting of the flags to the responsible components, updating them directly instead of duplicating the logic in OverviewProxyService - Add flags for tracking keyguard state, overview disabled state, and screen pinning state - Ensure the notification expanded state excludes quicksettings - Add logging for states and both back/assistant disabled states Bug: 132107485 Bug: 131698989 Test: Immersive mode - ensure you can't swipe back, ensure you can't swipe up or open the assistant Test: Expanded notification - ensure back doesn't work when locked/unlocked Test: Expanded QS - ensure back works when locked/unlocked Test: A11Y - ensure that 2 finger swipe up shows accessibility menu Test: A11Y - ensure that 2 finger swipe up & hold works Test: Bouncer - launch notification over launcher, ensure back works, ensure assistant doesn't work Test: Screen pinning - ensure back/assistant doesn't work Change-Id: Ife37bf40602b997e6c2b534d9fa274ce07c53b07 Signed-off-by: Winson Chung --- .../shared/system/QuickStepContract.java | 66 ++++++++++++++++++- .../recents/OverviewProxyService.java | 39 +++++++---- .../phone/EdgeBackGestureHandler.java | 8 +-- .../phone/NavigationBarFragment.java | 36 ++++++---- .../statusbar/phone/NavigationBarView.java | 22 ++++++- .../systemui/statusbar/phone/StatusBar.java | 15 ++++- 6 files changed, 147 insertions(+), 39 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 b89b9ef3cad78..cc3a67cd27887 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 @@ -28,6 +28,7 @@ import com.android.internal.policy.ScreenDecorationsUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.StringJoiner; /** * Various shared constants between Launcher and SysUI as part of quickstep @@ -35,7 +36,6 @@ import java.lang.annotation.RetentionPolicy; public class QuickStepContract { public static final String KEY_EXTRA_SYSUI_PROXY = "extra_sysui_proxy"; - public static final String KEY_EXTRA_INPUT_CHANNEL = "extra_input_channel"; public static final String KEY_EXTRA_INPUT_MONITOR = "extra_input_monitor"; public static final String KEY_EXTRA_WINDOW_CORNER_RADIUS = "extra_window_corner_radius"; public static final String KEY_EXTRA_SUPPORTS_WINDOW_CORNERS = "extra_supports_window_corners"; @@ -47,12 +47,26 @@ public class QuickStepContract { public static final String NAV_BAR_MODE_GESTURAL_OVERLAY = WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY; + // Overview is disabled, either because the device is in lock task mode, or because the device + // policy has disabled the feature public static final int SYSUI_STATE_SCREEN_PINNING = 1 << 0; + // The navigation bar is hidden due to immersive mode public static final int SYSUI_STATE_NAV_BAR_HIDDEN = 1 << 1; + // The notification panel is expanded and interactive (either locked or unlocked), and the + // quick settings is not expanded public static final int SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED = 1 << 2; + // The keyguard bouncer is showing public static final int SYSUI_STATE_BOUNCER_SHOWING = 1 << 3; + // The navigation bar a11y button should be shown public static final int SYSUI_STATE_A11Y_BUTTON_CLICKABLE = 1 << 4; + // The navigation bar a11y button shortcut is available public static final int SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE = 1 << 5; + // The keyguard is showing + public static final int SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING = 1 << 6; + // The recents feature is disabled (either by SUW/SysUI/device policy) + public static final int SYSUI_STATE_OVERVIEW_DISABLED = 1 << 7; + // The home feature is disabled (either by SUW/SysUI/device policy) + public static final int SYSUI_STATE_HOME_DISABLED = 1 << 8; @Retention(RetentionPolicy.SOURCE) @IntDef({SYSUI_STATE_SCREEN_PINNING, @@ -60,10 +74,27 @@ public class QuickStepContract { SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED, SYSUI_STATE_BOUNCER_SHOWING, SYSUI_STATE_A11Y_BUTTON_CLICKABLE, - SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE + SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, + SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING, + SYSUI_STATE_OVERVIEW_DISABLED, + SYSUI_STATE_HOME_DISABLED }) public @interface SystemUiStateFlags {} + public static String getSystemUiStateString(int flags) { + StringJoiner str = new StringJoiner("|"); + str.add((flags & SYSUI_STATE_SCREEN_PINNING) != 0 ? "screen_pinned" : ""); + str.add((flags & SYSUI_STATE_OVERVIEW_DISABLED) != 0 ? "overview_disabled" : ""); + str.add((flags & SYSUI_STATE_HOME_DISABLED) != 0 ? "home_disabled" : ""); + str.add((flags & SYSUI_STATE_NAV_BAR_HIDDEN) != 0 ? "navbar_hidden" : ""); + str.add((flags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) != 0 ? "notif_visible" : ""); + str.add((flags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING) != 0 ? "keygrd_visible" : ""); + str.add((flags & SYSUI_STATE_BOUNCER_SHOWING) != 0 ? "bouncer_visible" : ""); + str.add((flags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0 ? "a11y_click" : ""); + str.add((flags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0 ? "a11y_long_click" : ""); + return str.toString(); + } + /** * Touch slopes and thresholds for quick step operations. Drag slop is the point where the * home button press/long press over are ignored and will start to drag when exceeded and the @@ -86,6 +117,37 @@ public class QuickStepContract { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } + /** + * Returns whether the specified sysui state is such that the assistant gesture should be + * disabled. + */ + public static boolean isAssistantGestureDisabled(int sysuiStateFlags) { + // Disable when in screen pinning, immersive, the bouncer is showing, or the notifications + // are interactive + int disableFlags = SYSUI_STATE_SCREEN_PINNING + | SYSUI_STATE_NAV_BAR_HIDDEN + | SYSUI_STATE_BOUNCER_SHOWING + | SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; + return (sysuiStateFlags & disableFlags) != 0; + } + + /** + * Returns whether the specified sysui state is such that the back gesture should be + * disabled. + */ + public static boolean isBackGestureDisabled(int sysuiStateFlags) { + // Always allow when the bouncer is showing (even on top of the keyguard) + if ((sysuiStateFlags & SYSUI_STATE_BOUNCER_SHOWING) != 0) { + return false; + } + // Disable when in screen pinning, immersive, or the notifications are interactive + int disableFlags = SYSUI_STATE_SCREEN_PINNING + | SYSUI_STATE_NAV_BAR_HIDDEN + | SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED + | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING; + return (sysuiStateFlags & disableFlags) != 0; + } + /** * @return whether this nav bar mode is edge to edge */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index 738f893e98b37..1848219606db9 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -27,9 +27,6 @@ import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_INP import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SUPPORTS_WINDOW_CORNERS; 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_NAV_BAR_HIDDEN; -import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; import android.annotation.FloatRange; import android.app.ActivityTaskManager; @@ -69,6 +66,7 @@ import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.NavigationBarController; import com.android.systemui.statusbar.phone.NavigationBarFragment; +import com.android.systemui.statusbar.phone.NavigationBarView; import com.android.systemui.statusbar.phone.NavigationModeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.CallbackController; @@ -505,6 +503,7 @@ public class OverviewProxyService implements CallbackController= 0; --i) { + mConnectionCallbacks.get(i).onSystemUiStateChanged(sysuiStateFlags); + } + } + private void notifyStartAssistant(Bundle bundle) { for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) { mConnectionCallbacks.get(i).startAssistant(bundle); @@ -742,6 +749,11 @@ public class OverviewProxyService implements CallbackController setUpDisableFlags(disabledFlags1, disabledFlags2)); + updateSystemUiStateFlags(); } // ================================================================================ @@ -3412,6 +3414,7 @@ public class StatusBar extends SystemUI implements DemoMode, updateDozingState(); checkBarModes(); updateScrimController(); + updateSystemUiStateFlags(); mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), mUnlockMethodCache.isMethodSecure(), @@ -3578,10 +3581,16 @@ public class StatusBar extends SystemUI implements DemoMode, if (!mBouncerShowing) { updatePanelExpansionForKeyguard(); } + updateSystemUiStateFlags(); + } - // Notify overview proxy service of the new states - Dependency.get(OverviewProxyService.class).setSystemUiStateFlag(SYSUI_STATE_BOUNCER_SHOWING, - isBouncerShowing(), mContext.getDisplayId()); + public void updateSystemUiStateFlags() { + OverviewProxyService overviewProxyService = Dependency.get(OverviewProxyService.class); + overviewProxyService.setSystemUiStateFlag(SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING, + mStatusBarStateController.getState() == StatusBarState.KEYGUARD, + mDisplayId); + overviewProxyService.setSystemUiStateFlag(SYSUI_STATE_BOUNCER_SHOWING, + isBouncerShowing(), mDisplayId); } /**