From bdaa14bf18bd86e99649dc5a5f6a57f26e793e55 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Wed, 2 Sep 2020 01:32:35 +0800 Subject: [PATCH] Add Null check for mView.findFocus() in ViewRootImpl Some apps like Netflix crashed while handleWindowFocusChanged but mView somehow has became null. It's fair to check null for mView.findFocus() since other places in ViewRootImpl that calling this method also add null check. Fix: 153862451 Test: atest CtsInputMethodTestCases Change-Id: I86bd5f3193deabe28bb425a8564017f7b32b90f3 --- core/java/android/view/ViewRootImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 6e17ac9960a88..e50f342bcf96e 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3234,8 +3234,8 @@ public final class ViewRootImpl implements ViewParent, // Note: must be done after the focus change callbacks, // so all of the view state is set up correctly. - mImeFocusController.onPostWindowFocus(mView.findFocus(), hasWindowFocus, - mWindowAttributes); + mImeFocusController.onPostWindowFocus(mView != null ? mView.findFocus() : null, + hasWindowFocus, mWindowAttributes); if (hasWindowFocus) { // Clear the forward bit. We can just do this directly, since