Extract adding new window token in own method

Bug: 205676419
Test: make
Change-Id: I90374ed05682057bd56ec44c78be4b56bb10b625
This commit is contained in:
Nikolas Havrikov
2021-11-08 15:48:50 +01:00
parent 430e1722e3
commit 8bdeee1ad4

View File

@@ -2513,20 +2513,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
setCurIntent(intent);
if (bindCurrentInputMethodServiceLocked(intent, this, mImeConnectionBindFlags)) {
setLastBindTime(SystemClock.uptimeMillis());
setHasConnection(true);
setCurId(info.getId());
setCurToken(new Binder());
mCurTokenDisplayId = displayIdToShowIme;
try {
if (DEBUG) {
Slog.v(TAG, "Adding window token: " + getCurToken() + " for display: "
+ mCurTokenDisplayId);
}
mIWindowManager.addWindowToken(getCurToken(), LayoutParams.TYPE_INPUT_METHOD,
mCurTokenDisplayId, null /* options */);
} catch (RemoteException e) {
}
addFreshWindowTokenLocked(displayIdToShowIme, info.getId());
return new InputBindResult(
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
null, null, getCurId(), getSequenceNumber(), false);
@@ -2548,6 +2535,27 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return intent;
}
@GuardedBy("mMethodMap")
private void addFreshWindowTokenLocked(int displayIdToShowIme, String methodId) {
Binder token = new Binder();
setCurToken(token);
setLastBindTime(SystemClock.uptimeMillis());
setHasConnection(true);
setCurId(methodId);
mCurTokenDisplayId = displayIdToShowIme;
try {
if (DEBUG) {
Slog.v(TAG, "Adding window token: " + token + " for display: "
+ displayIdToShowIme);
}
mIWindowManager.addWindowToken(token, LayoutParams.TYPE_INPUT_METHOD,
displayIdToShowIme, null /* options */);
} catch (RemoteException e) {
Slog.e(TAG, "Could not add window token " + token + " for display "
+ displayIdToShowIme, e);
}
}
@FunctionalInterface
interface ImeDisplayValidator {
@DisplayImePolicy int getDisplayImePolicy(int displayId);