From 120ae3dbedcafff31f9a3470fb1cc211b1d3ea84 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Fri, 16 Jul 2021 21:42:46 +0800 Subject: [PATCH] Fix NPE when calling PasswordViewEntry.getWindowInsetsController().hide() As PasswordViewEntry didn't always attached to KeyguardPasswordView, check if the view is attached in case NPE happen when getting null WindowInsetsController Fix: 192644416 Test: manual test as issue steps Test: 1) make a security lock 2) unlocked to go to launcher 3) turn off screen 4) check the log and make sure no crash log. Change-Id: I13897f05576150b2f5e867c43d20efb02e681cef --- .../android/keyguard/KeyguardPasswordViewController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordViewController.java index d3171013ae0c9..92f8454fc93eb 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordViewController.java @@ -228,12 +228,16 @@ public class KeyguardPasswordViewController super.onPause(); }); } - mPasswordEntry.getWindowInsetsController().hide(WindowInsets.Type.ime()); + if (mPasswordEntry.isAttachedToWindow()) { + mPasswordEntry.getWindowInsetsController().hide(WindowInsets.Type.ime()); + } } @Override public void onStartingToHide() { - mPasswordEntry.getWindowInsetsController().hide(WindowInsets.Type.ime()); + if (mPasswordEntry.isAttachedToWindow()) { + mPasswordEntry.getWindowInsetsController().hide(WindowInsets.Type.ime()); + } } private void updateSwitchImeButton() {