Merge "Invalidate autofill session on IME disconnect" into tm-dev am: c17eae2651

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18646671

Change-Id: If35353300cc711e1441afe1d783c8cbd4057b5e7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-30 17:08:10 +00:00
committed by Automerger Merge Worker
2 changed files with 26 additions and 0 deletions

View File

@@ -247,6 +247,7 @@ final class InputMethodBindingController {
private final ServiceConnection mVisibleConnection = new ServiceConnection() { private final ServiceConnection mVisibleConnection = new ServiceConnection() {
@Override public void onBindingDied(ComponentName name) { @Override public void onBindingDied(ComponentName name) {
synchronized (ImfLock.class) { synchronized (ImfLock.class) {
mService.invalidateAutofillSessionLocked();
if (mVisibleBound) { if (mVisibleBound) {
unbindVisibleConnection(); unbindVisibleConnection();
} }
@@ -257,6 +258,9 @@ final class InputMethodBindingController {
} }
@Override public void onServiceDisconnected(ComponentName name) { @Override public void onServiceDisconnected(ComponentName name) {
synchronized (ImfLock.class) {
mService.invalidateAutofillSessionLocked();
}
} }
}; };

View File

@@ -313,6 +313,15 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@Nullable @Nullable
private CreateInlineSuggestionsRequest mPendingInlineSuggestionsRequest; 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 @UserIdInt
private int mLastSwitchUserId; private int mLastSwitchUserId;
@@ -2176,6 +2185,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback, InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback,
boolean touchExplorationEnabled) { boolean touchExplorationEnabled) {
clearPendingInlineSuggestionsRequestLocked(); clearPendingInlineSuggestionsRequestLocked();
mInlineSuggestionsRequestCallback = callback;
final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked()); final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
try { try {
if (userId == mSettings.getCurrentUserId() if (userId == mSettings.getCurrentUserId()
@@ -2797,6 +2807,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "Avoiding IME startup and unbinding current input method."); Slog.d(TAG, "Avoiding IME startup and unbinding current input method.");
} }
invalidateAutofillSessionLocked();
mBindingController.unbindCurrentMethod(); mBindingController.unbindCurrentMethod();
return InputBindResult.NO_EDITOR; return InputBindResult.NO_EDITOR;
} }
@@ -2834,6 +2845,17 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
return mBindingController.bindCurrentMethod(); return mBindingController.bindCurrentMethod();
} }
@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") @GuardedBy("ImfLock.class")
private boolean shouldPreventImeStartupLocked( private boolean shouldPreventImeStartupLocked(
@NonNull String selectedMethodId, @NonNull String selectedMethodId,