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(); } // ================================================================================ @@ -3416,6 +3418,7 @@ public class StatusBar extends SystemUI implements DemoMode, updateDozingState(); checkBarModes(); updateScrimController(); + updateSystemUiStateFlags(); mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), mUnlockMethodCache.isMethodSecure(), @@ -3582,10 +3585,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); } /**