Use a Region when calculating TouchableRegion for cutouts
HeadsUpManagerPhone handles adding extra touchable region for the
display cutout. When this changed to use Rects, the extra touch region
was applied to the entire phone width because Rect#union() will cause
the resulting Rect to grow in every dimension. The fix is to use a
Region instead so we can properly union only the space under the notch
Fixes: 135487528
Test: manual
Change-Id: I1d39785087cc3378fc42363df170b81b84420a8e
(cherry picked from commit e1822fd8d4)
This commit is contained in:
committed by
android-build-team Robot
parent
b9be1e51e2
commit
27a288e8b2
@@ -22,6 +22,7 @@ import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.util.Log;
|
||||
import android.util.Pools;
|
||||
import android.view.DisplayCutout;
|
||||
@@ -76,7 +77,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 Region mTouchableRegion = new Region();
|
||||
|
||||
private AnimationStateHandler mAnimationStateHandler;
|
||||
|
||||
@@ -299,10 +300,11 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
|
||||
info.touchableRegion.set(calculateTouchableRegion());
|
||||
}
|
||||
|
||||
public Rect calculateTouchableRegion() {
|
||||
public Region calculateTouchableRegion() {
|
||||
if (!hasPinnedHeadsUp()) {
|
||||
mTouchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight);
|
||||
updateRegionForNotch(mTouchableRegion);
|
||||
|
||||
} else {
|
||||
NotificationEntry topEntry = getTopEntry();
|
||||
if (topEntry.isChildInGroup()) {
|
||||
@@ -322,7 +324,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
|
||||
return mTouchableRegion;
|
||||
}
|
||||
|
||||
private void updateRegionForNotch(Rect region) {
|
||||
private void updateRegionForNotch(Region region) {
|
||||
DisplayCutout cutout = mStatusBarWindowView.getRootWindowInsets().getDisplayCutout();
|
||||
if (cutout == null) {
|
||||
return;
|
||||
@@ -390,6 +392,8 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
|
||||
super.dumpInternal(fd, pw, args);
|
||||
pw.print(" mBarState=");
|
||||
pw.println(mStatusBarState);
|
||||
pw.print(" mTouchableRegion=");
|
||||
pw.println(mTouchableRegion);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.os.PowerManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -620,9 +621,10 @@ public class NotificationPanelView extends PanelView implements
|
||||
|
||||
private Rect calculateGestureExclusionRect() {
|
||||
Rect exclusionRect = null;
|
||||
if (isFullyCollapsed()) {
|
||||
Region touchableRegion = mHeadsUpManager.calculateTouchableRegion();
|
||||
if (isFullyCollapsed() && touchableRegion != null) {
|
||||
// Note: The heads up manager also calculates the non-pinned touchable region
|
||||
exclusionRect = mHeadsUpManager.calculateTouchableRegion();
|
||||
exclusionRect = touchableRegion.getBounds();
|
||||
}
|
||||
return exclusionRect != null
|
||||
? exclusionRect
|
||||
|
||||
Reference in New Issue
Block a user