From 8b9d7baa418810047863133d336ab2f0479c1d30 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 15 Sep 2020 21:34:16 +0800 Subject: [PATCH] Remove unnecessary null checking on ViewRootImpl#mWindowAttribute From static analysis, as ViewRootImpl#mWindowAttribute is now a final object from CL[1] and the object is created when ViewRootImpl initialized so the object reference should not be changed, it won't be necessary to do the null check again for some code points. [1]: I0d749c1abb38520fe8fc477d22d6523f470e9abc Fix: 168335781 Fix: 168319140 Test: build and check launching app without any exception. Change-Id: I30e1efb8e52704fbd8c97dc375e7ac253c6a90a8 --- core/java/android/view/ViewRootImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index af839d4481f75..e6f89a761e6bc 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3092,8 +3092,7 @@ public final class ViewRootImpl implements ViewParent, if (changedVisibility || regainedFocus) { // Toasts are presented as notifications - don't present them as windows as well - boolean isToast = (mWindowAttributes == null) ? false - : (mWindowAttributes.type == TYPE_TOAST); + boolean isToast = mWindowAttributes.type == TYPE_TOAST; if (!isToast) { host.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } @@ -3258,8 +3257,7 @@ public final class ViewRootImpl implements ViewParent, if (mAttachInfo.mThreadedRenderer != null && mSurface.isValid()) { mFullRedrawNeeded = true; try { - final WindowManager.LayoutParams lp = mWindowAttributes; - final Rect surfaceInsets = lp != null ? lp.surfaceInsets : null; + final Rect surfaceInsets = mWindowAttributes.surfaceInsets; mAttachInfo.mThreadedRenderer.initializeIfNeeded( mWidth, mHeight, mAttachInfo, mSurface, surfaceInsets); } catch (OutOfResourcesException e) {