Fixed a bug where systemUI would crash when swiping notifications
Bug: 26159274
Change-Id: Ie8f9e65909fbe6e3d6436e9e4aab9e29779bfd10
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 51602e7..59cbd40 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar;
import android.content.Context;
+import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -44,6 +45,7 @@
private static Rect mClipRect = new Rect();
private boolean mWillBeGone;
private int mMinClipTopAmount = 0;
+ private boolean mMeasuredTooHigh;
public ExpandableView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -54,12 +56,13 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
boolean limitViewHeight = shouldLimitViewHeight();
+ final int givenSize = MeasureSpec.getSize(heightMeasureSpec);
int ownMaxHeight = limitViewHeight ? mMaxViewHeight : Integer.MAX_VALUE;
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
boolean hasFixedHeight = heightMode == MeasureSpec.EXACTLY;
if (hasFixedHeight) {
// We have a height set in our layout, so we want to be at most as big as given
- ownMaxHeight = Math.min(MeasureSpec.getSize(heightMeasureSpec), ownMaxHeight);
+ ownMaxHeight = Math.min(givenSize, ownMaxHeight);
}
int newHeightSpec = MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.AT_MOST);
int maxChildHeight = 0;
@@ -97,6 +100,7 @@
mMatchParentViews.clear();
int width = MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(width, ownHeight);
+ mMeasuredTooHigh = heightMode != MeasureSpec.UNSPECIFIED && ownHeight > givenSize;
}
protected boolean shouldLimitViewHeight() {
@@ -384,6 +388,18 @@
mMinClipTopAmount = minClipTopAmount;
}
+ @Override
+ public void setLayerType(int layerType, Paint paint) {
+ if (hasOverlappingRendering()) {
+ super.setLayerType(layerType, paint);
+ }
+ }
+
+ @Override
+ public boolean hasOverlappingRendering() {
+ return super.hasOverlappingRendering() && !mMeasuredTooHigh;
+ }
+
/**
* A listener notifying when {@link #getActualHeight} changes.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index 2b71ce9..beaa3ad 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -90,7 +90,7 @@
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
- int childCount = mChildren.size();
+ int childCount = Math.min(mChildren.size(), NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
for (int i = 0; i < childCount; i++) {
View child = mChildren.get(i);
if (child.getVisibility() == View.GONE) {
@@ -118,7 +118,7 @@
int newHeightSpec = MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.AT_MOST);
int dividerHeightSpec = MeasureSpec.makeMeasureSpec(mDividerHeight, MeasureSpec.EXACTLY);
int height = mNotificationHeaderHeight + mNotificatonTopPadding;
- int childCount = mChildren.size();
+ int childCount = Math.min(mChildren.size(), NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
for (int i = 0; i < childCount; i++) {
View child = mChildren.get(i);
child.measure(widthMeasureSpec, newHeightSpec);