summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-03-24 07:05:30 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-03-24 07:05:30 +0000
commitdc711d9c592545c9f21d0f14ac8dd2679d1fe944 (patch)
treeac110844fef70665adf0e9844db8bdf6d4af2de9
parente0b1bfb87d020f5da3cd32a3473e13297fbbe11d (diff)
parent2f67cf7684a147b9d10bd7381cfb7a73ff8b4836 (diff)
Merge "Add NPE chceck in CameraTransitionCallback" into rvc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/ScreenDecorations.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 5f004a631e46..281b566b6ffb 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -33,6 +33,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.Dimension;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -122,7 +123,8 @@ public class ScreenDecorations extends SystemUI implements Tunable {
protected int mRoundedDefaultBottom;
@VisibleForTesting
protected View[] mOverlays;
- private DisplayCutoutView[] mCutoutViews = new DisplayCutoutView[BOUNDS_POSITION_LENGTH];
+ @Nullable
+ private DisplayCutoutView[] mCutoutViews;
private float mDensity;
private WindowManager mWindowManager;
private int mRotation;
@@ -135,18 +137,32 @@ public class ScreenDecorations extends SystemUI implements Tunable {
new CameraAvailabilityListener.CameraTransitionCallback() {
@Override
public void onApplyCameraProtection(@NonNull Path protectionPath, @NonNull Rect bounds) {
+ if (mCutoutViews == null) {
+ Log.w(TAG, "DisplayCutoutView do not initialized");
+ return;
+ }
// Show the extra protection around the front facing camera if necessary
for (DisplayCutoutView dcv : mCutoutViews) {
- dcv.setProtection(protectionPath, bounds);
- dcv.setShowProtection(true);
+ // Check Null since not all mCutoutViews[pos] be inflated at the meanwhile
+ if (dcv != null) {
+ dcv.setProtection(protectionPath, bounds);
+ dcv.setShowProtection(true);
+ }
}
}
@Override
public void onHideCameraProtection() {
+ if (mCutoutViews == null) {
+ Log.w(TAG, "DisplayCutoutView do not initialized");
+ return;
+ }
// Go back to the regular anti-aliasing
for (DisplayCutoutView dcv : mCutoutViews) {
- dcv.setShowProtection(false);
+ // Check Null since not all mCutoutViews[pos] be inflated at the meanwhile
+ if (dcv != null) {
+ dcv.setShowProtection(false);
+ }
}
}
};