Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d320ec6 authored by Adam He's avatar Adam He
Browse files

Fixed Cancellation for PendingAutofillRequest.

1. mCallback.cancel() now correctly cancels the pending request.
2. AutofillProxy.update() now updates the CancellationSignal.

Fixes: 132459064
Test: atest android.autofillservice.cts.augmented
Change-Id: If8b2ab5c0fd8db4cfad440bf47031f6d85c28ae5
(cherry picked from commit 33bbf2aa2f1e5dabce5bd94e9b1c950cdcda1448)
parent ec5ded11
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public abstract class AugmentedAutofillService extends Service {
        } else {
            // TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging
            if (sDebug) Log.d(TAG, "Reusing proxy for session " + sessionId);
            proxy.update(focusedId, focusedValue, callback);
            proxy.update(focusedId, focusedValue, callback, cancellationSignal);
        }

        try {
@@ -252,6 +252,15 @@ public abstract class AugmentedAutofillService extends Service {
                    Log.w(TAG, "No proxy for session " + sessionId);
                    return;
                }
                if (proxy.mCallback != null) {
                    try {
                        if (!proxy.mCallback.isCompleted()) {
                            proxy.mCallback.cancel();
                        }
                    } catch (Exception e) {
                        Log.e(TAG, "failed to check current pending request status", e);
                    }
                }
                proxy.destroy();
            }
            mAutofillProxies.clear();
@@ -442,7 +451,7 @@ public abstract class AugmentedAutofillService extends Service {
        }

        private void update(@NonNull AutofillId focusedId, @NonNull AutofillValue focusedValue,
                @NonNull IFillCallback callback) {
                @NonNull IFillCallback callback, @NonNull CancellationSignal cancellationSignal) {
            synchronized (mLock) {
                mFocusedId = focusedId;
                mFocusedValue = focusedValue;
@@ -457,6 +466,7 @@ public abstract class AugmentedAutofillService extends Service {
                    Log.d(TAG, "mCallback is updated.");
                }
                mCallback = callback;
                mCancellationSignal = cancellationSignal;
            }
        }