From 87610b4e1dca201936d09a4481d9d648c538f26b Mon Sep 17 00:00:00 2001 From: Matt Casey Date: Wed, 24 Apr 2019 14:31:45 -0400 Subject: [PATCH] Make StatusBarWindowController aware of assist session in progress. Separate "assist is rendering something" from "assist session is in progress". If an assist session is in progress, the status bar should be focusable and back gestures should cause the session to be canceled. This also intercepts touches outside of the status bar when a session is in progress, but those touches will cancel (separate CL), so this shouldn't be a problem. Bug: 123413054 Test: Ensure in-progress assist sesion is canceled on back, ensure back is not affected outside of a session. Change-Id: Ife24b58a7851c5865ff75e66e00e32ae3293a0e8 --- .../systemui/statusbar/phone/StatusBar.java | 5 +++++ .../phone/StatusBarWindowController.java | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 7c271cef6abb3..2babfe3ca544b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -3294,6 +3294,11 @@ public class StatusBar extends SystemUI implements DemoMode, } return true; } + if (mStatusBarWindowController.hasAssistActiveSession()) { + // Back pressed during an assist session, cancel it. + mAssistManager.hideAssist(); + return true; + } if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { if (mNotificationPanel.canPanelBeCollapsed()) { animateCollapsePanels(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java index 984ab0563fea5..2969cf35377ca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java @@ -208,7 +208,8 @@ public class StatusBarWindowController implements Callback, Dumpable, Configurat || state.bubbleExpanded) { mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) { + } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable + || state.assistActiveSession) { mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mLpChanged.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } else { @@ -501,9 +502,13 @@ public class StatusBarWindowController implements Callback, Dumpable, Configurat /** * Sets whether assist UI is showing on the screen. + * + * @param assistShowing whether any assist UI is being shown. + * @param activeSession whether AssistManager has an active assist session in progress. */ - public void setAssistShowing(boolean assistShowing) { + public void setAssistState(boolean assistShowing, boolean activeSession) { mCurrentState.assistShowing = assistShowing; + mCurrentState.assistActiveSession = activeSession; apply(mCurrentState); } @@ -514,6 +519,13 @@ public class StatusBarWindowController implements Callback, Dumpable, Configurat return mCurrentState.assistShowing; } + /** + * The AssistManager is handling an active assist session. + */ + public boolean hasAssistActiveSession() { + return mCurrentState.assistActiveSession; + } + /** * Sets if there is a bubble being expanded on the screen. */ @@ -590,7 +602,10 @@ public class StatusBarWindowController implements Callback, Dumpable, Configurat boolean notTouchable; boolean bubblesShowing; boolean bubbleExpanded; + // Assist manager is rendering any UI. boolean assistShowing; + // Assist manager is handling an active assist session. + boolean assistActiveSession; /** * The {@link StatusBar} state from the status bar.