summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-05-22 01:25:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-05-22 01:25:25 +0000
commit4bbcccdeb93913c0429c75c832630ffc571ad5b4 (patch)
tree8545ba40e5f50d33e6de95bf23f226887fb22857
parent1795bab8749900a5acb621fd1e699b786824b647 (diff)
parent12fc7e3806f1010de5decb8287ab2830a511628a (diff)
Merge "Make AutofillSuggestionsController per-user" into main
-rw-r--r--services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java33
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodBindingController.java29
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java25
3 files changed, 44 insertions, 43 deletions
diff --git a/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java b/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java
index a3b1a2df9577..0749edce97a1 100644
--- a/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java
+++ b/services/core/java/com/android/server/inputmethod/AutofillSuggestionsController.java
@@ -18,7 +18,6 @@ package com.android.server.inputmethod;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.UserIdInt;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Slog;
@@ -39,7 +38,7 @@ final class AutofillSuggestionsController {
private static final boolean DEBUG = false;
private static final String TAG = AutofillSuggestionsController.class.getSimpleName();
- @NonNull private final InputMethodManagerService mService;
+ @NonNull private final InputMethodBindingController mBindingController;
/**
* The host input token of the input method that is currently associated with this controller.
@@ -81,8 +80,8 @@ final class AutofillSuggestionsController {
@Nullable
private InlineSuggestionsRequestCallback mInlineSuggestionsRequestCallback;
- AutofillSuggestionsController(@NonNull InputMethodManagerService service) {
- mService = service;
+ AutofillSuggestionsController(@NonNull InputMethodBindingController bindingController) {
+ mBindingController = bindingController;
}
@GuardedBy("ImfLock.class")
@@ -97,21 +96,15 @@ final class AutofillSuggestionsController {
}
@GuardedBy("ImfLock.class")
- void onCreateInlineSuggestionsRequest(@UserIdInt int userId,
- InlineSuggestionsRequestInfo requestInfo, InlineSuggestionsRequestCallback callback,
- boolean touchExplorationEnabled) {
+ void onCreateInlineSuggestionsRequest(InlineSuggestionsRequestInfo requestInfo,
+ InlineSuggestionsRequestCallback callback, boolean touchExplorationEnabled) {
clearPendingInlineSuggestionsRequest();
mInlineSuggestionsRequestCallback = callback;
- if (userId != mService.getCurrentImeUserIdLocked()) {
- callback.onInlineSuggestionsUnsupported();
- return;
- }
-
// Note that current user ID is guaranteed to be userId.
- final var imeId = mService.getSelectedMethodIdLocked();
- final InputMethodInfo imi = InputMethodSettingsRepository.get(userId).getMethodMap()
- .get(imeId);
+ final var imeId = mBindingController.getSelectedMethodId();
+ final InputMethodInfo imi = InputMethodSettingsRepository.get(mBindingController.mUserId)
+ .getMethodMap().get(imeId);
if (imi == null || !isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
callback.onInlineSuggestionsUnsupported();
return;
@@ -119,7 +112,7 @@ final class AutofillSuggestionsController {
mPendingInlineSuggestionsRequest = new CreateInlineSuggestionsRequest(
requestInfo, callback, imi.getPackageName());
- if (mService.getCurMethodLocked() != null) {
+ if (mBindingController.getCurMethod() != null) {
// In the normal case when the IME is connected, we can make the request here.
performOnCreateInlineSuggestionsRequest();
} else {
@@ -137,7 +130,7 @@ final class AutofillSuggestionsController {
if (mPendingInlineSuggestionsRequest == null) {
return;
}
- IInputMethodInvoker curMethod = mService.getCurMethodLocked();
+ IInputMethodInvoker curMethod = mBindingController.getCurMethod();
if (DEBUG) {
Slog.d(TAG, "Performing onCreateInlineSuggestionsRequest. mCurMethod = " + curMethod);
}
@@ -146,8 +139,8 @@ final class AutofillSuggestionsController {
new InlineSuggestionsRequestCallbackDecorator(
mPendingInlineSuggestionsRequest.mCallback,
mPendingInlineSuggestionsRequest.mPackageName,
- mService.getCurTokenDisplayIdLocked(),
- mService.getCurTokenLocked());
+ mBindingController.getCurTokenDisplayId(),
+ mBindingController.getCurToken());
curMethod.onCreateInlineSuggestionsRequest(
mPendingInlineSuggestionsRequest.mRequestInfo, callback);
} else {
@@ -212,7 +205,7 @@ final class AutofillSuggestionsController {
}
request.setHostDisplayId(mImeDisplayId);
synchronized (ImfLock.class) {
- final IBinder curImeToken = mService.getCurTokenLocked();
+ final IBinder curImeToken = mBindingController.getCurToken();
if (mImeToken == curImeToken) {
mCurHostInputToken = request.getHostInputToken();
}
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
index ad9995097639..8191ee14adff 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
@@ -48,6 +48,8 @@ import android.view.inputmethod.InputMethodManager;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.inputmethod.IInputMethod;
+import com.android.internal.inputmethod.InlineSuggestionsRequestCallback;
+import com.android.internal.inputmethod.InlineSuggestionsRequestInfo;
import com.android.internal.inputmethod.InputBindResult;
import com.android.internal.inputmethod.UnbindReason;
import com.android.server.EventLogTags;
@@ -68,6 +70,7 @@ final class InputMethodBindingController {
@UserIdInt final int mUserId;
@NonNull private final InputMethodManagerService mService;
@NonNull private final Context mContext;
+ @NonNull private final AutofillSuggestionsController mAutofillController;
@NonNull private final PackageManagerInternal mPackageManagerInternal;
@NonNull private final WindowManagerInternal mWindowManagerInternal;
@@ -122,6 +125,7 @@ final class InputMethodBindingController {
mUserId = userId;
mService = service;
mContext = mService.mContext;
+ mAutofillController = new AutofillSuggestionsController(this);
mPackageManagerInternal = mService.mPackageManagerInternal;
mWindowManagerInternal = mService.mWindowManagerInternal;
mImeConnectionBindFlags = imeConnectionBindFlags;
@@ -282,7 +286,7 @@ final class InputMethodBindingController {
private final ServiceConnection mVisibleConnection = new ServiceConnection() {
@Override public void onBindingDied(ComponentName name) {
synchronized (ImfLock.class) {
- mService.invalidateAutofillSessionLocked();
+ mAutofillController.invalidateAutofillSession();
if (isVisibleBound()) {
unbindVisibleConnection();
}
@@ -294,7 +298,7 @@ final class InputMethodBindingController {
@Override public void onServiceDisconnected(ComponentName name) {
synchronized (ImfLock.class) {
- mService.invalidateAutofillSessionLocked();
+ mAutofillController.invalidateAutofillSession();
}
}
};
@@ -339,7 +343,7 @@ final class InputMethodBindingController {
mService.initializeImeLocked(mCurMethod, mCurToken);
mService.scheduleNotifyImeUidToAudioService(mCurMethodUid);
mService.reRequestCurrentClientSessionLocked();
- mService.performOnCreateInlineSuggestionsRequestLocked();
+ mAutofillController.performOnCreateInlineSuggestionsRequest();
}
// reset Handwriting event receiver.
@@ -398,6 +402,24 @@ final class InputMethodBindingController {
};
@GuardedBy("ImfLock.class")
+ void invalidateAutofillSession() {
+ mAutofillController.invalidateAutofillSession();
+ }
+
+ @GuardedBy("ImfLock.class")
+ void onCreateInlineSuggestionsRequest(InlineSuggestionsRequestInfo requestInfo,
+ InlineSuggestionsRequestCallback callback, boolean touchExplorationEnabled) {
+ mAutofillController.onCreateInlineSuggestionsRequest(requestInfo, callback,
+ touchExplorationEnabled);
+ }
+
+ @GuardedBy("ImfLock.class")
+ @Nullable
+ IBinder getCurHostInputToken() {
+ return mAutofillController.getCurHostInputToken();
+ }
+
+ @GuardedBy("ImfLock.class")
void unbindCurrentMethod() {
if (isVisibleBound()) {
unbindVisibleConnection();
@@ -410,6 +432,7 @@ final class InputMethodBindingController {
if (getCurToken() != null) {
removeCurrentToken();
mService.resetSystemUiLocked();
+ mAutofillController.onResetSystemUi();
}
mCurId = null;
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 594d1127ac0e..9824a13b1e53 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -332,9 +332,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
private final UserManagerInternal mUserManagerInternal;
@MultiUserUnawareField
private final InputMethodMenuController mMenuController;
- @MultiUserUnawareField
- @NonNull
- private final AutofillSuggestionsController mAutofillController;
@GuardedBy("ImfLock.class")
@MultiUserUnawareField
@@ -1304,7 +1301,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
new HardwareKeyboardShortcutController(settings.getMethodMap(),
settings.getUserId());
mMenuController = new InputMethodMenuController(this);
- mAutofillController = new AutofillSuggestionsController(this);
mVisibilityStateComputer = new ImeVisibilityStateComputer(this);
mVisibilityApplier = new DefaultImeVisibilityApplier(this);
@@ -1713,11 +1709,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
return methodList;
}
- @GuardedBy("ImfLock.class")
- void performOnCreateInlineSuggestionsRequestLocked() {
- mAutofillController.performOnCreateInlineSuggestionsRequest();
- }
-
/**
* Gets enabled subtypes of the specified {@link InputMethodInfo}.
*
@@ -2115,7 +2106,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
if (DEBUG) {
Slog.d(TAG, "Avoiding IME startup and unbinding current input method.");
}
- invalidateAutofillSessionLocked();
+ bindingController.invalidateAutofillSession();
bindingController.unbindCurrentMethod();
return InputBindResult.NO_EDITOR;
}
@@ -2216,11 +2207,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
}
@GuardedBy("ImfLock.class")
- void invalidateAutofillSessionLocked() {
- mAutofillController.invalidateAutofillSession();
- }
-
- @GuardedBy("ImfLock.class")
private boolean shouldPreventImeStartupLocked(
@NonNull String selectedMethodId,
@StartInputFlags int startInputFlags,
@@ -2408,7 +2394,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
mImeWindowVis = 0;
mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT;
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
- mAutofillController.onResetSystemUi();
}
@GuardedBy("ImfLock.class")
@@ -5470,8 +5455,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
.isTouchExplorationEnabled(userId);
synchronized (ImfLock.class) {
- mAutofillController.onCreateInlineSuggestionsRequest(userId, requestInfo, cb,
- touchExplorationEnabled);
+ getInputMethodBindingController(userId).onCreateInlineSuggestionsRequest(
+ requestInfo, cb, touchExplorationEnabled);
}
}
@@ -5539,7 +5524,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
if (displayId != getCurTokenDisplayIdLocked()) {
return false;
}
- curHostInputToken = mAutofillController.getCurHostInputToken();
+ curHostInputToken = getInputMethodBindingController(userId).getCurHostInputToken();
if (curHostInputToken == null) {
return false;
}
@@ -5881,7 +5866,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
p.println(" mCurToken=" + getCurTokenLocked());
p.println(" mCurTokenDisplayId=" + getCurTokenDisplayIdLocked());
- p.println(" mCurHostInputToken=" + mAutofillController.getCurHostInputToken());
+ p.println(" mCurHostInputToken=" + bindingController.getCurHostInputToken());
p.println(" mCurIntent=" + bindingController.getCurIntent());
method = getCurMethodLocked();
p.println(" mCurMethod=" + getCurMethodLocked());