summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-05-30 17:32:33 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-05-30 17:32:33 +0000
commitc5ab6c9b1879933d44c19c3d243433ebc9691dfa (patch)
tree1f76328e2e7a738b7c0b61523d3fcf63688cf91b
parent843f8c3211a77dacda3653cee03e849d48bae33a (diff)
parent688c534d84eb1b3c80c5b5cdf4b4d78cb18e973a (diff)
Merge "Invalidate autofill session on IME disconnect" into tm-dev am: c17eae2651 am: 688c534d84
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18646671 Change-Id: I709057c4bc7fff1ac992f02eabbcbeae0ad14442 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodBindingController.java4
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java22
2 files changed, 26 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
index 9195b68e7a8f..86969ce1693c 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
@@ -247,6 +247,7 @@ final class InputMethodBindingController {
private final ServiceConnection mVisibleConnection = new ServiceConnection() {
@Override public void onBindingDied(ComponentName name) {
synchronized (ImfLock.class) {
+ mService.invalidateAutofillSessionLocked();
if (mVisibleBound) {
unbindVisibleConnection();
}
@@ -257,6 +258,9 @@ final class InputMethodBindingController {
}
@Override public void onServiceDisconnected(ComponentName name) {
+ synchronized (ImfLock.class) {
+ mService.invalidateAutofillSessionLocked();
+ }
}
};
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index ea2b1571c0ae..1a1c265f568d 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -313,6 +313,15 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@Nullable
private CreateInlineSuggestionsRequest mPendingInlineSuggestionsRequest;
+ /**
+ * A callback into the autofill service obtained from the latest call to
+ * {@link #onCreateInlineSuggestionsRequestLocked}, which can be used to invalidate an
+ * autofill session in case the IME process dies.
+ */
+ @GuardedBy("ImfLock.class")
+ @Nullable
+ private IInlineSuggestionsRequestCallback mInlineSuggestionsRequestCallback;
+
@UserIdInt
private int mLastSwitchUserId;
@@ -2176,6 +2185,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback,
boolean touchExplorationEnabled) {
clearPendingInlineSuggestionsRequestLocked();
+ mInlineSuggestionsRequestCallback = callback;
final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
try {
if (userId == mSettings.getCurrentUserId()
@@ -2797,6 +2807,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
if (DEBUG) {
Slog.d(TAG, "Avoiding IME startup and unbinding current input method.");
}
+ invalidateAutofillSessionLocked();
mBindingController.unbindCurrentMethod();
return InputBindResult.NO_EDITOR;
}
@@ -2835,6 +2846,17 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
@GuardedBy("ImfLock.class")
+ void invalidateAutofillSessionLocked() {
+ if (mInlineSuggestionsRequestCallback != null) {
+ try {
+ mInlineSuggestionsRequestCallback.onInlineSuggestionsSessionInvalidated();
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Cannot invalidate autofill session.", e);
+ }
+ }
+ }
+
+ @GuardedBy("ImfLock.class")
private boolean shouldPreventImeStartupLocked(
@NonNull String selectedMethodId,
@StartInputFlags int startInputFlags,