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

Commit e257fbd9 authored by Haoran Zhang's avatar Haoran Zhang
Browse files

Force hiding fill UI when it's destroyed.

The bug describes a scenaior where drop down UI is not removed even when
tapping on other fields. Forcing hiding dropdown UI fix this issue. For
reason why it would fix it needs more understanding.

Test: atest CtsAutoFillServiceTestCases
Bug: b/290917485

Change-Id: Id4940093aad5dcb290a494245052ba2ce9321aec
parent 338ade29
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -4213,6 +4213,14 @@ public final class AutofillManager {
            }
        }

        @Override
        public void requestHideFillUiWhenDestroyed(int sessionId, AutofillId id) {
            final AutofillManager afm = mAfm.get();
            if (afm != null) {
                afm.post(() -> afm.requestHideFillUi(id, true));
            }
        }

        @Override
        public void notifyNoFillUi(int sessionId, AutofillId id, int sessionFinishedState) {
            final AutofillManager afm = mAfm.get();
+5 −0
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ oneway interface IAutoFillManagerClient {
     */
    void requestHideFillUi(int sessionId, in AutofillId id);

    /**
     * Requests hiding the fill UI when it's destroyed
     */
    void requestHideFillUiWhenDestroyed(int sessionId, in AutofillId id);

    /**
     * Notifies no fill UI will be shown, and also mark the state as finished if necessary (if
     * sessionFinishedState != 0).
+15 −0
Original line number Diff line number Diff line
@@ -2401,6 +2401,21 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }
    }

    @Override
    public void requestHideFillUiWhenDestroyed(AutofillId id) {
        synchronized (mLock) {
            // NOTE: We allow this call in a destroyed state as the UI is
            // asked to go away after we get destroyed, so let it do that.
            try {
                mClient.requestHideFillUiWhenDestroyed(this.id, id);
            } catch (RemoteException e) {
                Slog.e(TAG, "Error requesting to hide fill UI", e);
            }

            mInlineSessionController.hideInlineSuggestionsUiLocked(id);
        }
    }

    // AutoFillUiCallback
    @Override
    public void cancelSession() {
+8 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ public final class AutoFillUI {
        void requestShowFillUi(AutofillId id, int width, int height,
                IAutofillWindowPresenter presenter);
        void requestHideFillUi(AutofillId id);
        void requestHideFillUiWhenDestroyed(AutofillId id);
        void startIntentSenderAndFinishSession(IntentSender intentSender);
        void startIntentSender(IntentSender intentSender, Intent intent);
        void dispatchUnhandledKey(AutofillId id, KeyEvent keyEvent);
@@ -288,6 +289,13 @@ public final class AutoFillUI {
                    }
                }

                @Override
                public void requestHideFillUiWhenDestroyed() {
                    if (mCallback != null) {
                        mCallback.requestHideFillUiWhenDestroyed(focusedId);
                    }
                }

                @Override
                public void startIntentSender(IntentSender intentSender) {
                    if (mCallback != null) {
+2 −1
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ final class FillUi {
        void requestShowFillUi(int width, int height,
                IAutofillWindowPresenter windowPresenter);
        void requestHideFillUi();
        void requestHideFillUiWhenDestroyed();
        void startIntentSender(IntentSender intentSender);
        void dispatchUnhandledKey(KeyEvent keyEvent);
        void cancelSession();
@@ -482,7 +483,7 @@ final class FillUi {
        }
        mCallback.onDestroy();
        if (notifyClient) {
            mCallback.requestHideFillUi();
            mCallback.requestHideFillUiWhenDestroyed();
        }
        mDestroyed = true;
    }