Merge "Clean up system ui state flags" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-22 00:54:53 +00:00
committed by Android (Google) Code Review
6 changed files with 147 additions and 39 deletions

View File

@@ -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
*/

View File

@@ -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<OverviewProxyLis
}
if (mSysUiStateFlags != newState) {
mSysUiStateFlags = newState;
notifySystemUiStateChanged(mSysUiStateFlags);
notifySystemUiStateFlags(mSysUiStateFlags);
}
}
@@ -516,18 +515,19 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
private void updateSystemUiStateFlags() {
final NavigationBarController navBar = Dependency.get(NavigationBarController.class);
final NavigationBarFragment navBarFragment = navBar.getDefaultNavigationBarFragment();
final NavigationBarView navBarView = navBar.getNavigationBarView(mContext.getDisplayId());
final StatusBar statusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
final boolean panelExpanded = statusBar != null && statusBar.getPanel() != null
&& statusBar.getPanel().isFullyExpanded();
final boolean bouncerShowing = statusBar != null && statusBar.isBouncerShowing();
mSysUiStateFlags = 0;
mSysUiStateFlags |= (navBarFragment != null && !navBarFragment.isNavBarWindowVisible())
? SYSUI_STATE_NAV_BAR_HIDDEN : 0;
mSysUiStateFlags |= panelExpanded
? SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED : 0;
mSysUiStateFlags |= bouncerShowing
? SYSUI_STATE_BOUNCER_SHOWING : 0;
mSysUiStateFlags |= navBarFragment != null ? navBarFragment.getA11yButtonState(null) : 0;
if (navBarFragment != null) {
navBarFragment.updateSystemUiStateFlags(-1);
}
if (navBarView != null) {
navBarView.updateSystemUiStateFlags();
}
if (statusBar != null) {
statusBar.updateSystemUiStateFlags();
}
notifySystemUiStateFlags(mSysUiStateFlags);
}
@@ -633,6 +633,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
mConnectionCallbacks.add(listener);
listener.onConnectionChanged(mOverviewProxy != null);
listener.onBackButtonAlphaChanged(mBackButtonAlpha, false);
listener.onSystemUiStateChanged(mSysUiStateFlags);
}
@Override
@@ -703,6 +704,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
private void notifySystemUiStateChanged(int sysuiStateFlags) {
for (int i = mConnectionCallbacks.size() - 1; i >= 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<OverviewProxyLis
pw.print(" quickStepIntent="); pw.println(mQuickStepIntent);
pw.print(" quickStepIntentResolved="); pw.println(isEnabled());
pw.print(" mSysUiStateFlags="); pw.println(mSysUiStateFlags);
pw.println(" " + QuickStepContract.getSystemUiStateString(mSysUiStateFlags));
pw.print(" backGestureDisabled=");
pw.println(QuickStepContract.isBackGestureDisabled(mSysUiStateFlags));
pw.print(" assistantGestureDisabled=");
pw.println(QuickStepContract.isAssistantGestureDisabled(mSysUiStateFlags));
}
public interface OverviewProxyListener {
@@ -750,6 +762,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
default void onOverviewShown(boolean fromHome) {}
default void onQuickScrubStarted() {}
default void onBackButtonAlphaChanged(float alpha, boolean animate) {}
default void onSystemUiStateChanged(int sysuiStateFlags) {}
default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
default void onAssistantGestureCompletion(float velocity) {}
default void startAssistant(Bundle bundle) {}

View File

@@ -17,10 +17,6 @@ package com.android.systemui.statusbar.phone;
import static android.view.Display.INVALID_DISPLAY;
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.content.Context;
import android.content.pm.ParceledListSlice;
import android.content.res.Resources;
@@ -318,9 +314,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
// either the bouncer is showing or the notification panel is hidden
int stateFlags = mOverviewProxyService.getSystemUiStateFlags();
mIsOnLeftEdge = ev.getX() <= mEdgeWidth;
mAllowGesture = (stateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
&& ((stateFlags & SYSUI_STATE_BOUNCER_SHOWING) == SYSUI_STATE_BOUNCER_SHOWING
|| (stateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) == 0)
mAllowGesture = !QuickStepContract.isBackGestureDisabled(stateFlags)
&& isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
if (mAllowGesture) {
mEdgePanelLp.gravity = mIsOnLeftEdge

View File

@@ -329,8 +329,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
notifyNavigationBarScreenOn();
mOverviewProxyService.addCallback(mOverviewProxyListener);
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_NAV_BAR_HIDDEN,
!isNavBarWindowVisible(), mDisplayId);
updateSystemUiStateFlags(-1);
// Currently there is no accelerometer sensor on non-default display.
if (mIsOnDefaultDisplay) {
@@ -458,8 +457,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
mNavigationBarWindowState = state;
if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state));
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_NAV_BAR_HIDDEN,
!isNavBarWindowVisible(), mDisplayId);
updateSystemUiStateFlags(-1);
mNavigationBarView.getRotateSuggestionButton()
.onNavigationBarWindowVisibilityChange(isNavBarWindowVisible());
}
@@ -576,7 +574,9 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
| StatusBarManager.DISABLE_SEARCH);
if (masked != mDisabledFlags1) {
mDisabledFlags1 = masked;
if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state1);
if (mNavigationBarView != null) {
mNavigationBarView.setDisabledFlags(state1);
}
updateScreenPinningGestures();
}
@@ -860,18 +860,30 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
private void updateAccessibilityServicesState(AccessibilityManager accessibilityManager) {
boolean[] feedbackEnabled = new boolean[1];
int flags = getA11yButtonState(feedbackEnabled);
int a11yFlags = getA11yButtonState(feedbackEnabled);
mNavigationBarView.getRotateSuggestionButton()
.setAccessibilityFeedbackEnabled(feedbackEnabled[0]);
boolean clickable = (flags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0;
boolean longClickable = (flags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
boolean clickable = (a11yFlags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0;
boolean longClickable = (a11yFlags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
mNavigationBarView.setAccessibilityButtonState(clickable, longClickable);
mOverviewProxyService.setSystemUiStateFlag(
SYSUI_STATE_A11Y_BUTTON_CLICKABLE, clickable, mDisplayId);
mOverviewProxyService.setSystemUiStateFlag(
SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, longClickable, mDisplayId);
updateSystemUiStateFlags(a11yFlags);
}
public void updateSystemUiStateFlags(int a11yFlags) {
if (a11yFlags < 0) {
a11yFlags = getA11yButtonState(null);
}
boolean clickable = (a11yFlags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0;
boolean longClickable = (a11yFlags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_A11Y_BUTTON_CLICKABLE,
clickable, mDisplayId);
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE,
longClickable, mDisplayId);
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_NAV_BAR_HIDDEN,
!isNavBarWindowVisible(), mDisplayId);
}
/**

View File

@@ -18,7 +18,10 @@ package com.android.systemui.statusbar.phone;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
import android.animation.LayoutTransition;
@@ -319,6 +322,7 @@ public class NavigationBarView extends FrameLayout implements
public void setComponents(NotificationPanelView panel, AssistManager assistManager) {
mPanelView = panel;
updateSystemUiStateFlags();
}
@Override
@@ -573,6 +577,7 @@ public class NavigationBarView extends FrameLayout implements
updateNavButtonIcons();
updateSlippery();
setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
updateSystemUiStateFlags();
}
public void updateNavButtonIcons() {
@@ -700,8 +705,21 @@ public class NavigationBarView extends FrameLayout implements
public void onPanelExpandedChange() {
updateSlippery();
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED,
mPanelView.isFullyExpanded(), getContext().getDisplayId());
updateSystemUiStateFlags();
}
public void updateSystemUiStateFlags() {
int displayId = mContext.getDisplayId();
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_SCREEN_PINNING,
ActivityManagerWrapper.getInstance().isScreenPinningActive(), displayId);
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_OVERVIEW_DISABLED,
(mDisabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0, displayId);
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_HOME_DISABLED,
(mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0, displayId);
if (mPanelView != null) {
mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED,
mPanelView.isFullyExpanded() && !mPanelView.isInSettings(), displayId);
}
}
public void updateStates() {

View File

@@ -31,6 +31,7 @@ import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASL
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
import static com.android.systemui.shared.system.WindowManagerWrapper.NAV_BAR_POS_INVALID;
import static com.android.systemui.shared.system.WindowManagerWrapper.NAV_BAR_POS_LEFT;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF;
@@ -785,6 +786,7 @@ public class StatusBar extends SystemUI implements DemoMode,
Dependency.get(InitController.class).addPostInitTask(
() -> 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);
}
/**