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 2b1c47f600701..630fb360cc14b 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 @@ -123,6 +123,8 @@ public class QuickStepContract { public static final int SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED = 1 << 23; // The current app is in immersive mode public static final int SYSUI_STATE_IMMERSIVE_MODE = 1 << 24; + // The voice interaction session window is showing + public static final int SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING = 1 << 25; @Retention(RetentionPolicy.SOURCE) @IntDef({SYSUI_STATE_SCREEN_PINNING, @@ -149,7 +151,8 @@ public class QuickStepContract { SYSUI_STATE_DEVICE_DOZING, SYSUI_STATE_BACK_DISABLED, SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED, - SYSUI_STATE_IMMERSIVE_MODE + SYSUI_STATE_IMMERSIVE_MODE, + SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING }) public @interface SystemUiStateFlags {} @@ -184,6 +187,7 @@ public class QuickStepContract { str.add((flags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0 ? "bubbles_mange_menu_expanded" : ""); str.add((flags & SYSUI_STATE_IMMERSIVE_MODE) != 0 ? "immersive_mode" : ""); + str.add((flags & SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING) != 0 ? "vis_win_showing" : ""); return str.toString(); } @@ -254,9 +258,11 @@ public class QuickStepContract { * disabled. */ public static boolean isBackGestureDisabled(int sysuiStateFlags) { - // Always allow when the bouncer/global actions is showing (even on top of the keyguard) + // Always allow when the bouncer/global actions/voice session is showing (even on top of + // the keyguard) if ((sysuiStateFlags & SYSUI_STATE_BOUNCER_SHOWING) != 0 - || (sysuiStateFlags & SYSUI_STATE_DIALOG_SHOWING) != 0) { + || (sysuiStateFlags & SYSUI_STATE_DIALOG_SHOWING) != 0 + || (sysuiStateFlags & SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING) != 0) { return false; } if ((sysuiStateFlags & SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY) != 0) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index c723fbb9a6e1a..9768e706764f6 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -41,6 +41,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_D 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; +import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING; import android.annotation.FloatRange; import android.app.ActivityTaskManager; @@ -77,6 +78,8 @@ import androidx.annotation.NonNull; import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.app.AssistUtils; +import com.android.internal.app.IVoiceInteractionSessionListener; import com.android.internal.logging.UiEventLogger; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.internal.util.ScreenshotHelper; @@ -551,6 +554,30 @@ public class OverviewProxyService extends CurrentUserTracker implements private final IBinder.DeathRecipient mOverviewServiceDeathRcpt = this::cleanupAfterDeath; + private final IVoiceInteractionSessionListener mVoiceInteractionSessionListener = + new IVoiceInteractionSessionListener.Stub() { + @Override + public void onVoiceSessionShown() { + // Do nothing + } + + @Override + public void onVoiceSessionHidden() { + // Do nothing + } + + @Override + public void onVoiceSessionWindowVisibilityChanged(boolean visible) { + mContext.getMainExecutor().execute(() -> + OverviewProxyService.this.onVoiceSessionWindowVisibilityChanged(visible)); + } + + @Override + public void onSetUiHints(Bundle hints) { + // Do nothing + } + }; + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @Inject public OverviewProxyService(Context context, CommandQueue commandQueue, @@ -569,6 +596,7 @@ public class OverviewProxyService extends CurrentUserTracker implements ScreenLifecycle screenLifecycle, UiEventLogger uiEventLogger, KeyguardUnlockAnimationController sysuiUnlockAnimationController, + AssistUtils assistUtils, DumpManager dumpManager) { super(broadcastDispatcher); mContext = context; @@ -640,6 +668,9 @@ public class OverviewProxyService extends CurrentUserTracker implements startConnectionToCurrentUser(); mStartingSurface = startingSurface; mSysuiUnlockAnimationController = sysuiUnlockAnimationController; + + // Listen for assistant changes + assistUtils.registerVoiceInteractionSessionListener(mVoiceInteractionSessionListener); } @Override @@ -648,6 +679,11 @@ public class OverviewProxyService extends CurrentUserTracker implements internalConnectToCurrentUser(); } + public void onVoiceSessionWindowVisibilityChanged(boolean visible) { + mSysUiState.setFlag(SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING, visible) + .commitUpdate(mContext.getDisplayId()); + } + public void notifyBackAction(boolean completed, int downX, int downY, boolean isButton, boolean gestureSwipeLeft) { try {