Modify MSIME sample to use setActive()

MSIME sample can now set connection active/inactive.

Bug: 128751901
Test: Manually verified using steps in bug.
Change-Id: I77bf8c844838f32888004611975cfa316255961b
This commit is contained in:
Tarandeep Singh
2019-04-11 15:57:42 -07:00
parent 1c57b7b861
commit 0994cdf0dc
2 changed files with 9 additions and 1 deletions

View File

@@ -152,8 +152,11 @@ final class ClientCallbackImpl implements MultiClientInputMethodServiceDelegate.
mDelegate.reportImeWindowTarget( mDelegate.reportImeWindowTarget(
mClientId, targetWindowHandle, window.getWindow().getAttributes().token); mClientId, targetWindowHandle, window.getWindow().getAttributes().token);
} }
if (inputConnection == null || editorInfo == null) { if (inputConnection == null || editorInfo == null) {
// deactivate previous client.
if (MultiClientInputMethod.sLastClientId != mClientId) {
mDelegate.setActive(MultiClientInputMethod.sLastClientId, false /* active */);
}
// Dummy InputConnection case. // Dummy InputConnection case.
if (window.getClientId() == mClientId) { if (window.getClientId() == mClientId) {
// Special hack for temporary focus changes (e.g. notification shade). // Special hack for temporary focus changes (e.g. notification shade).
@@ -163,6 +166,9 @@ final class ClientCallbackImpl implements MultiClientInputMethodServiceDelegate.
window.onDummyStartInput(mClientId, targetWindowHandle); window.onDummyStartInput(mClientId, targetWindowHandle);
} }
} else { } else {
if (MultiClientInputMethod.sLastClientId != mClientId) {
mDelegate.setActive(mClientId, true /* active */);
}
window.onStartInput(mClientId, targetWindowHandle, inputConnection); window.onStartInput(mClientId, targetWindowHandle, inputConnection);
} }
@@ -184,6 +190,7 @@ final class ClientCallbackImpl implements MultiClientInputMethodServiceDelegate.
window.hide(); window.hide();
break; break;
} }
MultiClientInputMethod.sLastClientId = mClientId;
} }
@Override @Override

View File

@@ -28,6 +28,7 @@ import android.util.Log;
public final class MultiClientInputMethod extends Service { public final class MultiClientInputMethod extends Service {
private static final String TAG = "MultiClientInputMethod"; private static final String TAG = "MultiClientInputMethod";
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
static int sLastClientId = MultiClientInputMethodServiceDelegate.INVALID_CLIENT_ID;
SoftInputWindowManager mSoftInputWindowManager; SoftInputWindowManager mSoftInputWindowManager;
MultiClientInputMethodServiceDelegate mDelegate; MultiClientInputMethodServiceDelegate mDelegate;