summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/inputmethod/InlineSuggestionsRequestCallback.java81
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java15
-rw-r--r--services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java68
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java8
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java4
5 files changed, 126 insertions, 50 deletions
diff --git a/core/java/com/android/internal/inputmethod/InlineSuggestionsRequestCallback.java b/core/java/com/android/internal/inputmethod/InlineSuggestionsRequestCallback.java
new file mode 100644
index 000000000000..92d453ba0e9f
--- /dev/null
+++ b/core/java/com/android/internal/inputmethod/InlineSuggestionsRequestCallback.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.inputmethod;
+
+import android.annotation.BinderThread;
+import android.view.autofill.AutofillId;
+import android.view.inputmethod.InlineSuggestionsRequest;
+
+/**
+ * An internal interface that mirrors {@link IInlineSuggestionsRequestCallback}.
+ *
+ * <p>This interface is used to forward incoming IPCs from
+ * {@link com.android.server.inputmethod.AutofillSuggestionsController} to
+ * {@link com.android.server.autofill.AutofillInlineSuggestionsRequestSession}.</p>
+ */
+public interface InlineSuggestionsRequestCallback {
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInlineSuggestionsUnsupported()}.
+ */
+ @BinderThread
+ void onInlineSuggestionsUnsupported();
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInlineSuggestionsRequest(
+ * InlineSuggestionsRequest, IInlineSuggestionsResponseCallback)}.
+ */
+ @BinderThread
+ void onInlineSuggestionsRequest(InlineSuggestionsRequest request,
+ IInlineSuggestionsResponseCallback callback);
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInputMethodStartInput(AutofillId)}.
+ */
+ @BinderThread
+ void onInputMethodStartInput(AutofillId imeFieldId);
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInputMethodShowInputRequested(boolean)}.
+ */
+ @BinderThread
+ void onInputMethodShowInputRequested(boolean requestResult);
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInputMethodStartInputView()}.
+ */
+ @BinderThread
+ void onInputMethodStartInputView();
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInputMethodFinishInputView()}.
+ */
+ @BinderThread
+ void onInputMethodFinishInputView();
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInputMethodFinishInput()}.
+ */
+ @BinderThread
+ void onInputMethodFinishInput();
+
+ /**
+ * Forwards {@link IInlineSuggestionsRequestCallback#onInlineSuggestionsSessionInvalidated()}.
+ */
+ @BinderThread
+ void onInlineSuggestionsSessionInvalidated();
+}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
index 468b9ab5710e..219b788448e8 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
@@ -36,6 +36,7 @@ import android.view.inputmethod.InlineSuggestionsResponse;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.IInlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.IInlineSuggestionsResponseCallback;
+import com.android.internal.inputmethod.InlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.InlineSuggestionsRequestInfo;
import com.android.server.autofill.ui.InlineFillUi;
import com.android.server.inputmethod.InputMethodManagerInternal;
@@ -376,8 +377,8 @@ final class AutofillInlineSuggestionsRequestSession {
/**
* Internal implementation of {@link IInlineSuggestionsRequestCallback}.
*/
- private static final class InlineSuggestionsRequestCallbackImpl extends
- IInlineSuggestionsRequestCallback.Stub {
+ private static final class InlineSuggestionsRequestCallbackImpl
+ implements InlineSuggestionsRequestCallback {
private final WeakReference<AutofillInlineSuggestionsRequestSession> mSession;
@@ -388,7 +389,7 @@ final class AutofillInlineSuggestionsRequestSession {
@BinderThread
@Override
- public void onInlineSuggestionsUnsupported() throws RemoteException {
+ public void onInlineSuggestionsUnsupported() {
if (sDebug) Slog.d(TAG, "onInlineSuggestionsUnsupported() called.");
final AutofillInlineSuggestionsRequestSession session = mSession.get();
if (session != null) {
@@ -412,7 +413,7 @@ final class AutofillInlineSuggestionsRequestSession {
}
@Override
- public void onInputMethodStartInput(AutofillId imeFieldId) throws RemoteException {
+ public void onInputMethodStartInput(AutofillId imeFieldId) {
if (sVerbose) Slog.v(TAG, "onInputMethodStartInput() received on " + imeFieldId);
final AutofillInlineSuggestionsRequestSession session = mSession.get();
if (session != null) {
@@ -423,7 +424,7 @@ final class AutofillInlineSuggestionsRequestSession {
}
@Override
- public void onInputMethodShowInputRequested(boolean requestResult) throws RemoteException {
+ public void onInputMethodShowInputRequested(boolean requestResult) {
if (sVerbose) {
Slog.v(TAG, "onInputMethodShowInputRequested() received: " + requestResult);
}
@@ -454,7 +455,7 @@ final class AutofillInlineSuggestionsRequestSession {
}
@Override
- public void onInputMethodFinishInput() throws RemoteException {
+ public void onInputMethodFinishInput() {
if (sVerbose) Slog.v(TAG, "onInputMethodFinishInput() received");
final AutofillInlineSuggestionsRequestSession session = mSession.get();
if (session != null) {
@@ -466,7 +467,7 @@ final class AutofillInlineSuggestionsRequestSession {
@BinderThread
@Override
- public void onInlineSuggestionsSessionInvalidated() throws RemoteException {
+ public void onInlineSuggestionsSessionInvalidated() {
if (sDebug) Slog.d(TAG, "onInlineSuggestionsSessionInvalidated() called.");
final AutofillInlineSuggestionsRequestSession session = mSession.get();
if (session != null) {
diff --git a/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java b/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java
index 00bc7517bebd..ad98b4a8db13 100644
--- a/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java
+++ b/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java
@@ -29,6 +29,7 @@ import android.view.inputmethod.InputMethodInfo;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.IInlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.IInlineSuggestionsResponseCallback;
+import com.android.internal.inputmethod.InlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.InlineSuggestionsRequestInfo;
/**
@@ -49,12 +50,12 @@ final class AutofillSuggestionsController {
private static final class CreateInlineSuggestionsRequest {
@NonNull final InlineSuggestionsRequestInfo mRequestInfo;
- @NonNull final IInlineSuggestionsRequestCallback mCallback;
+ @NonNull final InlineSuggestionsRequestCallback mCallback;
@NonNull final String mPackageName;
CreateInlineSuggestionsRequest(
@NonNull InlineSuggestionsRequestInfo requestInfo,
- @NonNull IInlineSuggestionsRequestCallback callback,
+ @NonNull InlineSuggestionsRequestCallback callback,
@NonNull String packageName) {
mRequestInfo = requestInfo;
mCallback = callback;
@@ -78,7 +79,7 @@ final class AutofillSuggestionsController {
*/
@GuardedBy("ImfLock.class")
@Nullable
- private IInlineSuggestionsRequestCallback mInlineSuggestionsRequestCallback;
+ private InlineSuggestionsRequestCallback mInlineSuggestionsRequestCallback;
AutofillSuggestionsController(@NonNull InputMethodManagerService service) {
mService = service;
@@ -97,33 +98,30 @@ final class AutofillSuggestionsController {
@GuardedBy("ImfLock.class")
void onCreateInlineSuggestionsRequest(@UserIdInt int userId,
- InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback,
+ InlineSuggestionsRequestInfo requestInfo, InlineSuggestionsRequestCallback callback,
boolean touchExplorationEnabled) {
clearPendingInlineSuggestionsRequest();
mInlineSuggestionsRequestCallback = callback;
final InputMethodInfo imi = mService.queryInputMethodForCurrentUserLocked(
mService.getSelectedMethodIdLocked());
- try {
- if (userId == mService.getCurrentImeUserIdLocked()
- && imi != null && isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
- mPendingInlineSuggestionsRequest = new CreateInlineSuggestionsRequest(
- requestInfo, callback, imi.getPackageName());
- if (mService.getCurMethodLocked() != null) {
- // In the normal case when the IME is connected, we can make the request here.
- performOnCreateInlineSuggestionsRequest();
- } else {
- // Otherwise, the next time the IME connection is established,
- // InputMethodBindingController.mMainConnection#onServiceConnected() will call
- // into #performOnCreateInlineSuggestionsRequestLocked() to make the request.
- if (DEBUG) {
- Slog.d(TAG, "IME not connected. Delaying inline suggestions request.");
- }
- }
+
+ if (userId == mService.getCurrentImeUserIdLocked()
+ && imi != null && isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
+ mPendingInlineSuggestionsRequest = new CreateInlineSuggestionsRequest(
+ requestInfo, callback, imi.getPackageName());
+ if (mService.getCurMethodLocked() != null) {
+ // In the normal case when the IME is connected, we can make the request here.
+ performOnCreateInlineSuggestionsRequest();
} else {
- callback.onInlineSuggestionsUnsupported();
+ // Otherwise, the next time the IME connection is established,
+ // InputMethodBindingController.mMainConnection#onServiceConnected() will call
+ // into #performOnCreateInlineSuggestionsRequestLocked() to make the request.
+ if (DEBUG) {
+ Slog.d(TAG, "IME not connected. Delaying inline suggestions request.");
+ }
}
- } catch (RemoteException e) {
- Slog.w(TAG, "RemoteException calling onCreateInlineSuggestionsRequest(): " + e);
+ } else {
+ callback.onInlineSuggestionsUnsupported();
}
}
@@ -166,11 +164,7 @@ final class AutofillSuggestionsController {
@GuardedBy("ImfLock.class")
void invalidateAutofillSession() {
if (mInlineSuggestionsRequestCallback != null) {
- try {
- mInlineSuggestionsRequestCallback.onInlineSuggestionsSessionInvalidated();
- } catch (RemoteException e) {
- Slog.e(TAG, "Cannot invalidate autofill session.", e);
- }
+ mInlineSuggestionsRequestCallback.onInlineSuggestionsSessionInvalidated();
}
}
@@ -180,13 +174,13 @@ final class AutofillSuggestionsController {
*/
private final class InlineSuggestionsRequestCallbackDecorator
extends IInlineSuggestionsRequestCallback.Stub {
- @NonNull private final IInlineSuggestionsRequestCallback mCallback;
+ @NonNull private final InlineSuggestionsRequestCallback mCallback;
@NonNull private final String mImePackageName;
private final int mImeDisplayId;
@NonNull private final IBinder mImeToken;
InlineSuggestionsRequestCallbackDecorator(
- @NonNull IInlineSuggestionsRequestCallback callback, @NonNull String imePackageName,
+ @NonNull InlineSuggestionsRequestCallback callback, @NonNull String imePackageName,
int displayId, @NonNull IBinder imeToken) {
mCallback = callback;
mImePackageName = imePackageName;
@@ -195,7 +189,7 @@ final class AutofillSuggestionsController {
}
@Override
- public void onInlineSuggestionsUnsupported() throws RemoteException {
+ public void onInlineSuggestionsUnsupported() {
mCallback.onInlineSuggestionsUnsupported();
}
@@ -220,32 +214,32 @@ final class AutofillSuggestionsController {
}
@Override
- public void onInputMethodStartInput(AutofillId imeFieldId) throws RemoteException {
+ public void onInputMethodStartInput(AutofillId imeFieldId) {
mCallback.onInputMethodStartInput(imeFieldId);
}
@Override
- public void onInputMethodShowInputRequested(boolean requestResult) throws RemoteException {
+ public void onInputMethodShowInputRequested(boolean requestResult) {
mCallback.onInputMethodShowInputRequested(requestResult);
}
@Override
- public void onInputMethodStartInputView() throws RemoteException {
+ public void onInputMethodStartInputView() {
mCallback.onInputMethodStartInputView();
}
@Override
- public void onInputMethodFinishInputView() throws RemoteException {
+ public void onInputMethodFinishInputView() {
mCallback.onInputMethodFinishInputView();
}
@Override
- public void onInputMethodFinishInput() throws RemoteException {
+ public void onInputMethodFinishInput() {
mCallback.onInputMethodFinishInput();
}
@Override
- public void onInlineSuggestionsSessionInvalidated() throws RemoteException {
+ public void onInlineSuggestionsSessionInvalidated() {
mCallback.onInlineSuggestionsSessionInvalidated();
}
}
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java
index e8543f225ef0..dace67f2c462 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java
@@ -25,7 +25,7 @@ import android.view.inputmethod.InlineSuggestionsRequest;
import android.view.inputmethod.InputMethodInfo;
import com.android.internal.inputmethod.IAccessibilityInputMethodSession;
-import com.android.internal.inputmethod.IInlineSuggestionsRequestCallback;
+import com.android.internal.inputmethod.InlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.InlineSuggestionsRequestInfo;
import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.server.LocalServices;
@@ -86,11 +86,11 @@ public abstract class InputMethodManagerInternal {
*
* @param userId the user ID to be queried
* @param requestInfo information needed to create an {@link InlineSuggestionsRequest}.
- * @param cb {@link IInlineSuggestionsRequestCallback} used to pass back the request
+ * @param cb {@link InlineSuggestionsRequestCallback} used to pass back the request
* object
*/
public abstract void onCreateInlineSuggestionsRequest(@UserIdInt int userId,
- InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb);
+ InlineSuggestionsRequestInfo requestInfo, InlineSuggestionsRequestCallback cb);
/**
* Force switch to the enabled input method by {@code imeId} for current user. If the input
@@ -263,7 +263,7 @@ public abstract class InputMethodManagerInternal {
@Override
public void onCreateInlineSuggestionsRequest(@UserIdInt int userId,
InlineSuggestionsRequestInfo requestInfo,
- IInlineSuggestionsRequestCallback cb) {
+ InlineSuggestionsRequestCallback cb) {
}
@Override
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 98f0102dc750..954f9bcd9c43 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -147,7 +147,6 @@ import com.android.internal.inputmethod.IAccessibilityInputMethodSession;
import com.android.internal.inputmethod.IBooleanListener;
import com.android.internal.inputmethod.IConnectionlessHandwritingCallback;
import com.android.internal.inputmethod.IImeTracker;
-import com.android.internal.inputmethod.IInlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.IInputContentUriToken;
import com.android.internal.inputmethod.IInputMethod;
import com.android.internal.inputmethod.IInputMethodClient;
@@ -157,6 +156,7 @@ import com.android.internal.inputmethod.IInputMethodSessionCallback;
import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection;
import com.android.internal.inputmethod.IRemoteInputConnection;
import com.android.internal.inputmethod.ImeTracing;
+import com.android.internal.inputmethod.InlineSuggestionsRequestCallback;
import com.android.internal.inputmethod.InlineSuggestionsRequestInfo;
import com.android.internal.inputmethod.InputBindResult;
import com.android.internal.inputmethod.InputMethodDebug;
@@ -5486,7 +5486,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
@Override
public void onCreateInlineSuggestionsRequest(@UserIdInt int userId,
- InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb) {
+ InlineSuggestionsRequestInfo requestInfo, InlineSuggestionsRequestCallback cb) {
// Get the device global touch exploration state before lock to avoid deadlock.
final boolean touchExplorationEnabled = AccessibilityManagerInternal.get()
.isTouchExplorationEnabled(userId);