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

Commit 4110ab51 authored by Simranjit Kohli's avatar Simranjit Kohli Committed by Android (Google) Code Review
Browse files

Merge "[Fill Dialog Improvements] Implement Fill Dialog improvements" into main

parents 96d9fdc4 03415d12
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