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

Commit 03415d12 authored by Simranjit Kohli's avatar Simranjit Kohli
Browse files

[Fill Dialog Improvements] Implement Fill Dialog improvements

Implement Fill Dialog improvements.
This change achieves a multitude of changes.
1. Disable pre-trigger flow
2. Show fill dialog if applicable
3. Reset fill dialog state so that fill dialog can be retriggered
   on another fill request in the same session. This part isn't
   tested yet, and would be done later.

Bug: 377868687
Flag: android.service.autofill.improve_fill_dialog_aconfig
Test: atest CtsAutoFillServiceTestCases
      atest android.autofillservice.cts.dialog.LoginActivityTest

Change-Id: I959ecc4e98d26f059a6a354f6c83d653555e89c3
parent 7efd5ae7
Loading
Loading
Loading
Loading
+59 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.service.autofill.FillRequest.FLAG_SUPPORTS_FILL_DIALOG;
import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED;
import static android.service.autofill.FillRequest.FLAG_VIEW_REQUESTS_CREDMAN_SERVICE;
import static android.service.autofill.Flags.FLAG_FILL_DIALOG_IMPROVEMENTS;
import static android.service.autofill.Flags.improveFillDialogAconfig;
import static android.service.autofill.Flags.relayoutFix;
import static android.view.ContentInfo.SOURCE_AUTOFILL;
import static android.view.autofill.Helper.sDebug;
@@ -787,6 +788,11 @@ public final class AutofillManager {

    private AutofillStateFingerprint mAutofillStateFingerprint;

    /**
     * Whether improveFillDialog feature is enabled or not.
     */
    private boolean mImproveFillDialogEnabled;

    /** @hide */
    public interface AutofillClient {
        /**
@@ -1017,6 +1023,17 @@ public final class AutofillManager {
        mRelayoutFix = relayoutFix() && AutofillFeatureFlags.enableRelayoutFixes();
        mRelativePositionForRelayout = AutofillFeatureFlags.enableRelativeLocationForRelayout();
        mIsCredmanIntegrationEnabled = Flags.autofillCredmanIntegration();
        mImproveFillDialogEnabled =
                improveFillDialogAconfig() && AutofillFeatureFlags.isImproveFillDialogEnabled();
    }

    /**
     * Whether improvement to fill dialog is enabled.
     *
     * @hide
     */
    public boolean isImproveFillDialogEnabled() {
        return mImproveFillDialogEnabled;
    }

    /**
@@ -1679,6 +1696,11 @@ public final class AutofillManager {

    private void notifyViewReadyInner(AutofillId id, @Nullable String[] autofillHints,
            boolean isCredmanRequested) {
        if (isImproveFillDialogEnabled() && !isCredmanRequested) {
            // We do not want to send pre-trigger request.
            // TODO(b/377868687): verify if we can remove the flow for isCredmanRequested too.
            return;
        }
        if (sDebug) {
            Log.d(TAG, "notifyViewReadyInner:" + id);
        }
@@ -2045,6 +2067,34 @@ public final class AutofillManager {
        mEnteredIds.add(id);
    }

    /**
     * Notify autofill system that IME animation has started
     * @param startTimeMs start time as measured by SystemClock.elapsedRealtime()
     */
    void notifyImeAnimationStart(long startTimeMs) {
        try {
            mService.notifyImeAnimationStart(mSessionId, startTimeMs, mContext.getUserId());
        } catch (RemoteException e) {
            // The failure could be a consequence of something going wrong on the
            // server side. Just log the exception and move-on.
            Log.w(TAG, "notifyImeAnimationStart(): RemoteException caught but ignored " + e);
        }
    }

    /**
     * Notify autofill system that IME animation has ended
     * @param endTimeMs end time as measured by SystemClock.elapsedRealtime()
     */
    void notifyImeAnimationEnd(long endTimeMs) {
        try {
            mService.notifyImeAnimationEnd(mSessionId, endTimeMs, mContext.getUserId());
        } catch (RemoteException e) {
            // The failure could be a consequence of something going wrong on the
            // server side. Just log the exception and move-on.
            Log.w(TAG, "notifyImeAnimationStart(): RemoteException caught but ignored " + e);
        }
    }

    /**
     * Called when a virtual view that supports autofill is exited.
     *
@@ -4050,6 +4100,10 @@ public final class AutofillManager {
    @FlaggedApi(FLAG_FILL_DIALOG_IMPROVEMENTS)
    @Deprecated
    public boolean showAutofillDialog(@NonNull View view) {
        if (isImproveFillDialogEnabled()) {
            Log.i(TAG, "showAutofillDialog() return false due to improve fill dialog");
            return false;
        }
        Objects.requireNonNull(view);
        if (shouldShowAutofillDialog(view, view.getAutofillId())) {
            mShowAutofillDialogCalled = true;
@@ -4093,6 +4147,10 @@ public final class AutofillManager {
    @FlaggedApi(FLAG_FILL_DIALOG_IMPROVEMENTS)
    @Deprecated
    public boolean showAutofillDialog(@NonNull View view, int virtualId) {
        if (isImproveFillDialogEnabled()) {
            Log.i(TAG, "showAutofillDialog() return false due to improve fill dialog");
            return false;
        }
        Objects.requireNonNull(view);
        if (shouldShowAutofillDialog(view, getAutofillId(view, virtualId))) {
            mShowAutofillDialogCalled = true;
@@ -4117,7 +4175,7 @@ public final class AutofillManager {
            return false;
        }

        if (getImeStateFlag(view) == FLAG_IME_SHOWING) {
        if (getImeStateFlag(view) == FLAG_IME_SHOWING && !isImproveFillDialogEnabled()) {
            // IME is showing
            return false;
        }
+2 −0
Original line number Diff line number Diff line
@@ -70,4 +70,6 @@ oneway interface IAutoFillManager {
    void notifyNotExpiringResponseDuringAuth(int sessionId, int userId);
    void notifyViewEnteredIgnoredDuringAuthCount(int sessionId, int userId);
    void setAutofillIdsAttemptedForRefill(int sessionId, in List<AutofillId> ids, int userId);
    void notifyImeAnimationStart(int sessionId, long startTimeMs, int userId);
    void notifyImeAnimationEnd(int sessionId, long endTimeMs, int userId);
}
+10 −0
Original line number Diff line number Diff line
@@ -8,6 +8,16 @@ flag {
  bug: "297380045"
}

flag {
  name: "improve_fill_dialog_aconfig"
  namespace: "autofill"
  description: "Improvements for Fill Dialog. Guard DeviceConfig rollout "
  bug: "382493181"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "fill_fields_from_current_session_only"
  namespace: "autofill"
+9 −2
Original line number Diff line number Diff line
@@ -354,6 +354,13 @@ final class AutofillInlineSuggestionsRequestSession {
        }
    }

    private void handleOnInputMethodStartInputView() {
        synchronized (mLock) {
            mUiCallback.onInputMethodStartInputView();
            handleOnReceiveImeStatusUpdated(true, true);
        }
    }

    /**
     * Handles the IME session status received from the IME.
     *
@@ -437,8 +444,8 @@ final class AutofillInlineSuggestionsRequestSession {
            final AutofillInlineSuggestionsRequestSession session = mSession.get();
            if (session != null) {
                session.mHandler.sendMessage(obtainMessage(
                        AutofillInlineSuggestionsRequestSession::handleOnReceiveImeStatusUpdated,
                        session, true, true));
                        AutofillInlineSuggestionsRequestSession::handleOnInputMethodStartInputView,
                        session));
            }
        }

+26 −0
Original line number Diff line number Diff line
@@ -2138,6 +2138,32 @@ public final class AutofillManagerService
            }
        }

        @Override
        public void notifyImeAnimationStart(int sessionId, long startTimeMs, int userId) {
            synchronized (mLock) {
                final AutofillManagerServiceImpl service =
                        peekServiceForUserWithLocalBinderIdentityLocked(userId);
                if (service != null) {
                    service.notifyImeAnimationStart(sessionId, startTimeMs, getCallingUid());
                } else if (sVerbose) {
                    Slog.v(TAG, "notifyImeAnimationStart(): no service for " + userId);
                }
            }
        }

        @Override
        public void notifyImeAnimationEnd(int sessionId, long endTimeMs, int userId) {
            synchronized (mLock) {
                final AutofillManagerServiceImpl service =
                        peekServiceForUserWithLocalBinderIdentityLocked(userId);
                if (service != null) {
                    service.notifyImeAnimationEnd(sessionId, endTimeMs, getCallingUid());
                } else if (sVerbose) {
                    Slog.v(TAG, "notifyImeAnimationEnd(): no service for " + userId);
                }
            }
        }

        @Override
        public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) return;
Loading