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

Commit 234030a0 authored by Adam He's avatar Adam He
Browse files

Don't show fill ui if fillrequest times out.

Fixes: 127062800
Test: atest
android.autofillservice.cts.augmented.AugmentedLoginActivityTest

Change-Id: Iad067c79746a829334f64b2b340021876e341dd4
parent 52577fcc
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -202,10 +202,13 @@ public abstract class AugmentedAutofillService extends Service {
        if (mAutofillProxies == null) {
            mAutofillProxies = new SparseArray<>();
        }

        final ICancellationSignal transport = CancellationSignal.createTransport();
        final CancellationSignal cancellationSignal = CancellationSignal.fromTransport(transport);
        AutofillProxy proxy = mAutofillProxies.get(sessionId);
        if (proxy == null) {
            proxy = new AutofillProxy(sessionId, client, taskId, componentName, focusedId,
                    focusedValue, requestTime, callback);
                    focusedValue, requestTime, callback, cancellationSignal);
            mAutofillProxies.put(sessionId,  proxy);
        } else {
            // TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging
@@ -213,15 +216,14 @@ public abstract class AugmentedAutofillService extends Service {
            proxy.update(focusedId, focusedValue, callback);
        }

        final ICancellationSignal transport = CancellationSignal.createTransport();
        try {
            callback.onCancellable(transport);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }

        onFillRequest(new FillRequest(proxy), CancellationSignal.fromTransport(transport),
                new FillController(proxy), new FillCallback(proxy));
        onFillRequest(new FillRequest(proxy), cancellationSignal, new FillController(proxy),
                new FillCallback(proxy));
    }

    private void handleOnDestroyAllFillWindowsRequest() {
@@ -336,18 +338,21 @@ public abstract class AugmentedAutofillService extends Service {
        @GuardedBy("mLock")
        private FillWindow mFillWindow;

        private CancellationSignal mCancellationSignal;

        private AutofillProxy(int sessionId, @NonNull IBinder client, int taskId,
                @NonNull ComponentName componentName, @NonNull AutofillId focusedId,
                @Nullable AutofillValue focusedValue, long requestTime,
                @NonNull IFillCallback callback) {
                @NonNull IFillCallback callback, @NonNull CancellationSignal cancellationSignal) {
            mSessionId = sessionId;
            mClient = IAugmentedAutofillManagerClient.Stub.asInterface(client);
            mCallback = callback;
            this.taskId = taskId;
            this.componentName = componentName;
            this.mFocusedId = focusedId;
            this.mFocusedValue = focusedValue;
            this.mFirstRequestTime = requestTime;
            mFocusedId = focusedId;
            mFocusedValue = focusedValue;
            mFirstRequestTime = requestTime;
            mCancellationSignal = cancellationSignal;
            // TODO(b/123099468): linkToDeath
        }

@@ -401,6 +406,12 @@ public abstract class AugmentedAutofillService extends Service {

        public void requestShowFillUi(int width, int height, Rect anchorBounds,
                IAutofillWindowPresenter presenter) throws RemoteException {
            if (mCancellationSignal.isCanceled()) {
                if (VERBOSE) {
                    Log.v(TAG, "requestShowFillUi() not showing because request is cancelled");
                }
                return;
            }
            mClient.requestShowFillUi(mSessionId, mFocusedId, width, height, anchorBounds,
                    presenter);
        }
+4 −0
Original line number Diff line number Diff line
@@ -3146,6 +3146,10 @@ public final class AutofillManager {
            if (afm == null) return null;

            final View view = afm.getClient().autofillClientFindViewByAutofillIdTraversal(id);
            if (view == null) {
                Log.w(TAG, "getViewCoordinates(" + id + "): could not find view");
                return null;
            }
            final Rect windowVisibleDisplayFrame = new Rect();
            view.getWindowVisibleDisplayFrame(windowVisibleDisplayFrame);
            final int[] location = new int[2];