OSDN Git Service

Ensure the cutout is not null before trying to use it.
authorJoshua Tsuji <tsuji@google.com>
Fri, 25 Jan 2019 16:37:49 +0000 (11:37 -0500)
committerJoshua Tsuji <tsuji@google.com>
Fri, 25 Jan 2019 20:52:05 +0000 (15:52 -0500)
Test: manual
Change-Id: I59cf13aed53a5d8a61e5dc65500764ecdddc9c39

packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java

index 5fdf76f..b584f67 100644 (file)
@@ -33,6 +33,7 @@ import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewTreeObserver;
+import android.view.WindowInsets;
 import android.view.WindowManager;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
@@ -590,9 +591,12 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
 
     private int getStatusBarHeight() {
         if (getRootWindowInsets() != null) {
+            WindowInsets insets = getRootWindowInsets();
             return Math.max(
-                    getRootWindowInsets().getSystemWindowInsetTop(),
-                    getRootWindowInsets().getDisplayCutout().getSafeInsetTop());
+                    insets.getSystemWindowInsetTop(),
+                    insets.getDisplayCutout() != null
+                            ? insets.getDisplayCutout().getSafeInsetTop()
+                            : 0);
         }
 
         return 0;
index f3ca938..4f870f6 100644 (file)
@@ -98,7 +98,9 @@ public class ExpandedAnimationController
         if (insets != null) {
             return mBubblePaddingPx + Math.max(
                     insets.getSystemWindowInsetTop(),
-                    insets.getDisplayCutout().getSafeInsetTop());
+                    insets.getDisplayCutout() != null
+                            ? insets.getDisplayCutout().getSafeInsetTop()
+                            : 0);
         }
 
         return mBubblePaddingPx;
index a113a63..0f51376 100644 (file)
@@ -211,7 +211,9 @@ public class StackAnimationController extends
                             - mBubblePadding
                             + Math.max(
                             insets.getSystemWindowInsetLeft(),
-                            insets.getDisplayCutout().getSafeInsetLeft());
+                            insets.getDisplayCutout() != null
+                                    ? insets.getDisplayCutout().getSafeInsetLeft()
+                                    : 0);
             mAllowableStackPositionRegion.right =
                     mLayout.getWidth()
                             - mIndividualBubbleSize
@@ -219,20 +221,26 @@ public class StackAnimationController extends
                             - mBubblePadding
                             - Math.max(
                             insets.getSystemWindowInsetRight(),
-                            insets.getDisplayCutout().getSafeInsetRight());
+                            insets.getDisplayCutout() != null
+                                ? insets.getDisplayCutout().getSafeInsetRight()
+                                : 0);
 
             mAllowableStackPositionRegion.top =
                     mBubblePadding
                             + Math.max(
                             insets.getSystemWindowInsetTop(),
-                            insets.getDisplayCutout().getSafeInsetTop());
+                            insets.getDisplayCutout() != null
+                                ? insets.getDisplayCutout().getSafeInsetTop()
+                                : 0);
             mAllowableStackPositionRegion.bottom =
                     mLayout.getHeight()
                             - mIndividualBubbleSize
                             - mBubblePadding
                             - Math.max(
                             insets.getSystemWindowInsetBottom(),
-                            insets.getDisplayCutout().getSafeInsetBottom());
+                            insets.getDisplayCutout() != null
+                                    ? insets.getDisplayCutout().getSafeInsetBottom()
+                                    : 0);
         }
 
         return mAllowableStackPositionRegion;