Exclude the status bar and HUN from gestures

Bug: 133264268
Test: Ensure that HUNs and collapsed status bar prevents back
Change-Id: I5d326be8525ab959180c815f48c1275255a5a785
This commit is contained in:
Winson Chung
2019-05-28 15:04:08 -07:00
parent 8a09c7c0ae
commit 9cd2115a8e
2 changed files with 34 additions and 7 deletions

View File

@@ -22,8 +22,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region.Op;
import android.util.Log;
import android.util.Pools;
import android.view.DisplayCutout;
@@ -78,6 +76,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
private int[] mTmpTwoArray = new int[2];
private boolean mHeadsUpGoingAway;
private int mStatusBarState;
private Rect mTouchableRegion = new Rect();
private AnimationStateHandler mAnimationStateHandler;
@@ -297,10 +296,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
@Nullable
public void updateTouchableRegion(ViewTreeObserver.InternalInsetsInfo info) {
info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
info.touchableRegion.set(calculateTouchableRegion());
}
public Rect calculateTouchableRegion() {
if (!hasPinnedHeadsUp()) {
info.touchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight);
updateRegionForNotch(info.touchableRegion);
mTouchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight);
updateRegionForNotch(mTouchableRegion);
} else {
NotificationEntry topEntry = getTopEntry();
if (topEntry.isChildInGroup()) {
@@ -315,11 +317,12 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
int minX = mTmpTwoArray[0];
int maxX = mTmpTwoArray[0] + topRow.getWidth();
int height = topRow.getIntrinsicHeight();
info.touchableRegion.set(minX, 0, maxX, mHeadsUpInset + height);
mTouchableRegion.set(minX, 0, maxX, mHeadsUpInset + height);
}
return mTouchableRegion;
}
private void updateRegionForNotch(Region region) {
private void updateRegionForNotch(Rect region) {
DisplayCutout cutout = mStatusBarWindowView.getRootWindowInsets().getDisplayCutout();
if (cutout == null) {
return;
@@ -330,7 +333,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
Rect bounds = new Rect();
ScreenDecorations.DisplayCutoutView.boundsFromDirection(cutout, Gravity.TOP, bounds);
bounds.offset(0, mDisplayCutoutTouchableRegionSize);
region.op(bounds, Op.UNION);
region.union(bounds);
}
@Override

View File

@@ -100,6 +100,7 @@ import com.android.systemui.util.InjectionInflationController;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
@@ -141,6 +142,7 @@ public class NotificationPanelView extends PanelView implements
private static final String COUNTER_PANEL_OPEN_PEEK = "panel_open_peek";
private static final Rect mDummyDirtyRect = new Rect(0, 0, 1, 1);
private static final Rect mEmptyRect = new Rect();
private static final AnimationProperties CLOCK_ANIMATION_PROPERTIES = new AnimationProperties()
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
@@ -596,6 +598,25 @@ public class NotificationPanelView extends PanelView implements
mQs.setHeightOverride(mQs.getDesiredHeight());
}
updateMaxHeadsUpTranslation();
updateGestureExclusionRect();
}
private void updateGestureExclusionRect() {
Rect exclusionRect = calculateGestureExclusionRect();
setSystemGestureExclusionRects(exclusionRect.isEmpty()
? Collections.EMPTY_LIST
: Collections.singletonList(exclusionRect));
}
private Rect calculateGestureExclusionRect() {
Rect exclusionRect = null;
if (isFullyCollapsed()) {
// Note: The heads up manager also calculates the non-pinned touchable region
exclusionRect = mHeadsUpManager.calculateTouchableRegion();
}
return exclusionRect != null
? exclusionRect
: mEmptyRect;
}
private void setIsFullWidth(boolean isFullWidth) {
@@ -1798,6 +1819,7 @@ public class NotificationPanelView extends PanelView implements
updateHeader();
updateNotificationTranslucency();
updatePanelExpanded();
updateGestureExclusionRect();
if (DEBUG) {
invalidate();
}
@@ -2568,6 +2590,7 @@ public class NotificationPanelView extends PanelView implements
mNotificationStackScroller.runAfterAnimationFinished(
mHeadsUpExistenceChangedRunnable);
}
updateGestureExclusionRect();
}
public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
@@ -2992,6 +3015,7 @@ public class NotificationPanelView extends PanelView implements
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
super.dump(fd, pw, args);
pw.println(" gestureExclusionRect: " + calculateGestureExclusionRect());
if (mKeyguardStatusBar != null) {
mKeyguardStatusBar.dump(fd, pw, args);
}