summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodServiceInternal.java
diff options
context:
space:
mode:
authoryingleiw <yingleiw@google.com>2021-12-13 14:00:06 -0800
committeryingleiw <yingleiw@google.com>2022-02-08 22:14:19 -0800
commitfb17e5ae7a9e1a095d114d8dde76f14578b6c233 (patch)
treeb401b0dd16ffa1b60c507544e3d5a7293c3693f8 /core/java/android/inputmethodservice/InputMethodServiceInternal.java
parent370b27ad3b62d673a454697c0e49eda6225dd365 (diff)
Allow a11y services to enter text via the path IMEs use
InputMethodService is the primary and a11y is the secondary. InputMethodService is not affected by a11y status. When the session from input method is established, app can start input (pass input context to input method). When an a11y session comes back, it will be passed to the app. When InputMethodManagerService binds to/start input with InputMethodService, it does the same to a11y services which requested IME functionalities. It is possible that input method can edit text before ally sessios are established. So the EditorInfo passed to a11y could be stale. So when an a11y session is passed to client, client will send a notification (input method doesn't have this extra notification) for the current selection. I think since the time for a11y session establish shouldn't be long, and we get the current state later, it should be fine for a11y services. When input method is disconnected from app (client) (even for input method switching), we cleared a11y and sessions too. When input method request sessions, we must rerequest sessions for a11y. This is mainly because when we unbindCurrentClientLocked(SWITCH_IME), we set active to false for the current client. Suppose we don't want to change the current structure of input method, an inactive client probably should clear accessibility sessions too. When we switch to a client which already has a session with input method, there might be some a11y sessions with this client, and some a11y services might be disabled or enabled while the client was switched out. We pass unchanged a11y sessions to client, and request sessions for newly enabled a11y services. When an a11y service is disabled, it removes its session from all clients in InputMethodManagerService. Test: type word through modified "switchToInputMethod". Tested session notification through logs. Tested client switching, input method switching, a11y service enabled/disable, multiple a11y services, a11y service enabled before device reboot. Also tested work profile. Bug: 187453053 Change-Id: Ia651a811093a939d00c081be1961e24ed3ad0356
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodServiceInternal.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodServiceInternal.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodServiceInternal.java b/core/java/android/inputmethodservice/InputMethodServiceInternal.java
index 7cd4ff61b2c8..09dbb27359b0 100644
--- a/core/java/android/inputmethodservice/InputMethodServiceInternal.java
+++ b/core/java/android/inputmethodservice/InputMethodServiceInternal.java
@@ -18,6 +18,7 @@ package android.inputmethodservice;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.inputmethod.InputConnection;
@@ -31,8 +32,11 @@ import java.io.PrintWriter;
* framework classes for internal use.
*
* <p>CAVEATS: {@link AbstractInputMethodService} does not support all the methods here.</p>
+ *
+ * @hide
*/
-interface InputMethodServiceInternal {
+// TODO(b/215636776): move InputMethodServiceInternal to proper package
+public interface InputMethodServiceInternal {
/**
* @return {@link Context} associated with the service.
*/
@@ -70,7 +74,8 @@ interface InputMethodServiceInternal {
* closed for you after you return.
* @param args additional arguments to the dump request.
*/
- default void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
+ default void dump(@SuppressLint("UseParcelFileDescriptor") @NonNull FileDescriptor fd,
+ @NonNull PrintWriter fout, @NonNull String[] args) {
}
/**
@@ -81,6 +86,6 @@ interface InputMethodServiceInternal {
* @param where {@code where} parameter to be passed.
* @param icProto {@code icProto} parameter to be passed.
*/
- default void triggerServiceDump(String where, @Nullable byte[] icProto) {
+ default void triggerServiceDump(@NonNull String where, @Nullable byte[] icProto) {
}
}