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
This commit is contained in:
Yohei Yukawa
2022-07-12 19:33:20 -07:00
parent 7e29c3b0d2
commit aff7c622da

View File

@@ -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);
}
mCurPerceptible = perceptible;
Binder.withCleanCallingIdentity(() ->
updateSystemUiLocked(mImeWindowVis, mBackDisposition));
}
}