Fix NPE in notifyFocusChanged

Before the first focus change, mFocusedWindow is null.

Bug: 121122996
Test: manual - Switch between activities without exception log.
Change-Id: Id09ec08296daab5335a4c3167d61e5e21f148016
This commit is contained in:
Riddle Hsu
2019-01-14 21:30:07 +08:00
parent cf136dd1ff
commit 63e4053ffd

View File

@@ -1761,12 +1761,15 @@ public class InputManagerService extends IInputManager.Stub
// Native callback
private void notifyFocusChanged(IBinder oldToken, IBinder newToken) {
if (mFocusedWindow.asBinder() == newToken) {
Log.w(TAG, "notifyFocusChanged called with unchanged mFocusedWindow=" + mFocusedWindow);
return;
if (mFocusedWindow != null) {
if (mFocusedWindow.asBinder() == newToken) {
Slog.w(TAG, "notifyFocusChanged called with unchanged mFocusedWindow="
+ mFocusedWindow);
return;
}
setPointerCapture(false);
}
setPointerCapture(false);
mFocusedWindow = IWindow.Stub.asInterface(newToken);
}