summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bill Lin <lbill@google.com> 2020-03-24 01:16:34 +0800
committer Bill Lin <lbill@google.com> 2020-03-24 12:56:43 +0800
commit2f67cf7684a147b9d10bd7381cfb7a73ff8b4836 (patch)
tree3caec5b8ee0e195371036513d22f2ad7ffdbe24d
parent6c95b5053bc205d168ff7a4fbb353895434e6d68 (diff)
Add NPE chceck in CameraTransitionCallback
Initialized mCutoutView introduce performance regression in SystemUIBootTiming_StartServicescom Check Null in traverse mCutoutViews loop since not all mCutoutViews[pos] be inflated at the meanwhile Test: boottime_test Test: manual boot without crash Bug: 151986151 Change-Id: Iba8e07a1304f3e07c89de6d4e223b620bd88b7d3
-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);
+ }
}
}
};