Check that sysui states before allowing back gesture
- Ensure not in immersive mode, and also that the notification panel is
not expanded
Bug: 130340004
Bug: 130417141
Test: Manual, ensure back doesn't work when notification panel is down or
app is in immersive mode
Change-Id: I29f5cd80cc89b28802ca8b2c9e2956ae5b3b1151
This commit is contained in:
@@ -51,6 +51,7 @@ public class QuickStepContract {
|
||||
public static final int SYSUI_STATE_SCREEN_PINNING = 1 << 0;
|
||||
public static final int SYSUI_STATE_NAV_BAR_HIDDEN = 1 << 1;
|
||||
public static final int SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED = 1 << 2;
|
||||
public static final int SYSUI_STATE_BOUNCER_SHOWING = 1 << 3;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({SYSUI_STATE_SCREEN_PINNING,
|
||||
|
||||
@@ -28,6 +28,7 @@ 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 static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
|
||||
@@ -489,12 +490,17 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
|
||||
}
|
||||
}
|
||||
|
||||
public int getSystemUiStateFlags() {
|
||||
return mSysUiStateFlags;
|
||||
}
|
||||
|
||||
private void updateSystemUiStateFlags() {
|
||||
final NavigationBarController navBar = Dependency.get(NavigationBarController.class);
|
||||
final NavigationBarFragment navBarFragment = navBar.getDefaultNavigationBarFragment();
|
||||
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 |= ActivityManagerWrapper.getInstance().isScreenPinningActive()
|
||||
? SYSUI_STATE_SCREEN_PINNING : 0;
|
||||
@@ -502,6 +508,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
|
||||
? SYSUI_STATE_NAV_BAR_HIDDEN : 0;
|
||||
mSysUiStateFlags |= panelExpanded
|
||||
? SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED : 0;
|
||||
mSysUiStateFlags |= bouncerShowing
|
||||
? SYSUI_STATE_BOUNCER_SHOWING : 0;
|
||||
notifySystemUiStateFlags(mSysUiStateFlags);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ 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;
|
||||
@@ -127,7 +131,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
|
||||
|
||||
private final PointF mDownPoint = new PointF();
|
||||
private boolean mThresholdCrossed = false;
|
||||
private boolean mIgnoreThisGesture = false;
|
||||
private boolean mAllowGesture = false;
|
||||
private boolean mIsOnLeftEdge;
|
||||
|
||||
private int mImeHeight = 0;
|
||||
@@ -285,9 +289,14 @@ public class EdgeBackGestureHandler implements DisplayListener {
|
||||
|
||||
private void onMotionEvent(MotionEvent ev) {
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
// Verify if this is in within the touch region
|
||||
mIgnoreThisGesture = !isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
|
||||
if (!mIgnoreThisGesture) {
|
||||
// Verify if this is in within the touch region and we aren't in immersive mode, and
|
||||
// either the bouncer is showing or the notification panel is hidden
|
||||
int stateFlags = mOverviewProxyService.getSystemUiStateFlags();
|
||||
mAllowGesture = (stateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
|
||||
&& ((stateFlags & SYSUI_STATE_BOUNCER_SHOWING) == SYSUI_STATE_BOUNCER_SHOWING
|
||||
|| (stateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) == 0)
|
||||
&& isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
|
||||
if (mAllowGesture) {
|
||||
mIsOnLeftEdge = ev.getX() < mEdgeWidth;
|
||||
mEdgePanelLp.gravity = mIsOnLeftEdge
|
||||
? (Gravity.LEFT | Gravity.TOP)
|
||||
@@ -302,13 +311,13 @@ public class EdgeBackGestureHandler implements DisplayListener {
|
||||
mThresholdCrossed = false;
|
||||
mEdgePanel.handleTouch(ev);
|
||||
}
|
||||
} else if (!mIgnoreThisGesture) {
|
||||
} else if (mAllowGesture) {
|
||||
if (!mThresholdCrossed && ev.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
float dx = Math.abs(ev.getX() - mDownPoint.x);
|
||||
float dy = Math.abs(ev.getY() - mDownPoint.y);
|
||||
if (dy > dx && dy > mTouchSlop) {
|
||||
// Send action cancel to reset all the touch events
|
||||
mIgnoreThisGesture = true;
|
||||
mAllowGesture = false;
|
||||
MotionEvent cancelEv = MotionEvent.obtain(ev);
|
||||
cancelEv.setAction(MotionEvent.ACTION_CANCEL);
|
||||
mEdgePanel.handleTouch(cancelEv);
|
||||
|
||||
@@ -30,6 +30,7 @@ import static com.android.systemui.Dependency.MAIN_HANDLER;
|
||||
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;
|
||||
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.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;
|
||||
@@ -166,6 +167,7 @@ import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.Snoo
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.qs.QSFragment;
|
||||
import com.android.systemui.qs.QSPanel;
|
||||
import com.android.systemui.recents.OverviewProxyService;
|
||||
import com.android.systemui.recents.Recents;
|
||||
import com.android.systemui.recents.ScreenPinningRequest;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
@@ -3582,6 +3584,10 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
if (!mBouncerShowing) {
|
||||
updatePanelExpansionForKeyguard();
|
||||
}
|
||||
|
||||
// Notify overview proxy service of the new states
|
||||
Dependency.get(OverviewProxyService.class).setSystemUiStateFlag(SYSUI_STATE_BOUNCER_SHOWING,
|
||||
isBouncerShowing());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user