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

Commit aff7c622 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Simplify IMMS#reportPerceptibleAsync()

IMMS#mCurFocusedWindow is guaranteed to be associated with the current
IME client process.  As long as the calling process has the same
window token, checking calledFromValidUserLocked() is just redundant
and could even make it a bit unclear about what security model we are
enforcing there.

Bug: 34886274
Test: presubmit
Change-Id: Iafb2b6d82fcccb4a33eceebff3d08b96fde8dc03
parent 7e29c3b0
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -3430,19 +3430,12 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
    public void reportPerceptibleAsync(IBinder windowToken, boolean perceptible) {
        Objects.requireNonNull(windowToken, "windowToken must not be null");
        synchronized (ImfLock.class) {
            if (!calledFromValidUserLocked()) {
            if (mCurFocusedWindow != windowToken || mCurPerceptible == perceptible) {
                return;
            }
            final long ident = Binder.clearCallingIdentity();
            try {
                if (mCurFocusedWindow == windowToken
                        && mCurPerceptible != perceptible) {
            mCurPerceptible = perceptible;
                    updateSystemUiLocked(mImeWindowVis, mBackDisposition);
                }
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
            Binder.withCleanCallingIdentity(() ->
                    updateSystemUiLocked(mImeWindowVis, mBackDisposition));
        }
    }