Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63e4053f authored by Riddle Hsu's avatar Riddle Hsu
Browse files

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
parent cf136dd1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -1761,12 +1761,15 @@ public class InputManagerService extends IInputManager.Stub

    // Native callback
    private void notifyFocusChanged(IBinder oldToken, IBinder newToken) {
        if (mFocusedWindow != null) {
            if (mFocusedWindow.asBinder() == newToken) {
            Log.w(TAG, "notifyFocusChanged called with unchanged mFocusedWindow=" + mFocusedWindow);
                Slog.w(TAG, "notifyFocusChanged called with unchanged mFocusedWindow="
                        + mFocusedWindow);
                return;
            }

            setPointerCapture(false);
        }

        mFocusedWindow = IWindow.Stub.asInterface(newToken);
    }