From 32a1305cbd62222e13df51b1b4aa5ea488c65ffb Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Tue, 23 Mar 2021 23:35:41 +0000 Subject: [PATCH] onDrawScrollIndicators returns early if the view isn't attached Test: Install a test app that can reproduce the null pointer exception. Flash and install a build with this CL. Null pointer exception can no longer be observed. Bug: 183386115 Change-Id: Iab155dfca20e0119cc401d111ace23e416e93b93 --- core/java/android/view/View.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 1e2b2aedfc084..dd5c954045101 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -19782,6 +19782,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return; } + if (mAttachInfo == null) { + // View is not attached. + return; + } + final int h = dr.getIntrinsicHeight(); final int w = dr.getIntrinsicWidth(); final Rect rect = mAttachInfo.mTmpInvalRect;