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

Commit 82c700f5 authored by tiger_huang's avatar tiger_huang
Browse files

Make accessing mInputMethodTarget thread-safe

Use the lock to prevent other threads clearing mInputMethodTarget
while we are accessing members of mInputMethodTarget, or it will
cause system server crash due to unexpected NullPointerException.

Change-Id: Iec3bed916a019827364ddaf63a89270a4c407a47
parent 899110f3
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -6185,10 +6185,13 @@ public class WindowManagerService extends IWindowManager.Stub
        int retryCount = 0;
        WindowState appWin = null;

        final boolean appIsImTarget = mInputMethodTarget != null
        boolean appIsImTarget;
        synchronized(mWindowMap) {
            appIsImTarget = mInputMethodTarget != null
                    && mInputMethodTarget.mAppToken != null
                    && mInputMethodTarget.mAppToken.appToken != null
                    && mInputMethodTarget.mAppToken.appToken.asBinder() == appToken;
        }

        final int aboveAppLayer = (mPolicy.windowTypeToLayerLw(TYPE_APPLICATION) + 1)
                * TYPE_LAYER_MULTIPLIER + TYPE_LAYER_OFFSET;