OSDN Git Service

Fixed a bug where the system could crash when expanding
authorSelim Cinek <cinek@google.com>
Wed, 12 Oct 2016 18:34:52 +0000 (11:34 -0700)
committerSelim Cinek <cinek@google.com>
Wed, 12 Oct 2016 19:08:57 +0000 (12:08 -0700)
When expanding a notification it could disappear and the
system would crash.

Test: Manual, expand notification group and have it removed while
doing so.
Change-Id: I421ab0cf7a9292e6894529c80784ba0989071fb0
Fixes: 31941185

packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java

index bc89db2..f3e5c94 100644 (file)
@@ -1056,7 +1056,7 @@ public class NotificationStackScrollLayout extends ViewGroup
     @Override
     public int getMaxExpandHeight(ExpandableView view) {
         int maxContentHeight = view.getMaxContentHeight();
-        if (view.isSummaryWithChildren()) {
+        if (view.isSummaryWithChildren() && view.getParent() == this) {
             // Faking a measure with the group expanded to simulate how the group would look if
             // it was. Doing a calculation here would be highly non-trivial because of the
             // algorithm
@@ -1071,8 +1071,11 @@ public class NotificationStackScrollLayout extends ViewGroup
                     row.getStatusBarNotification());
             mGroupExpandedForMeasure = false;
             row.setForceUnlocked(false);
-            int height = mCurrentStackScrollState.getViewStateForView(view).height;
-            return Math.min(height, maxContentHeight);
+            StackViewState viewState = mCurrentStackScrollState.getViewStateForView(view);
+            if (viewState != null) {
+                // The view could have been removed
+                return Math.min(viewState.height, maxContentHeight);
+            }
         }
         return maxContentHeight;
     }