Merge "Lock down RemoteInputConnectionImpl#getInputConnection()"

This commit is contained in:
Yohei Yukawa
2021-08-05 14:41:07 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 4 deletions

View File

@@ -1381,8 +1381,7 @@ public final class InputMethodManager {
public boolean isAcceptingText() {
checkFocus();
synchronized (mH) {
return mServedInputConnection != null
&& mServedInputConnection.getInputConnection() != null;
return mServedInputConnection != null && !mServedInputConnection.isFinished();
}
}

View File

@@ -86,13 +86,17 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub {
* @return {@link InputConnection} to which incoming IPCs will be dispatched.
*/
@Nullable
public InputConnection getInputConnection() {
private InputConnection getInputConnection() {
synchronized (mLock) {
return mInputConnection;
}
}
private boolean isFinished() {
/**
* @return {@code true} until the target {@link InputConnection} receives
* {@link InputConnection#closeConnection()} as a result of {@link #deactivate()}.
*/
public boolean isFinished() {
synchronized (mLock) {
return mFinished;
}