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

Commit 58dfa96a authored by Daniel's avatar Daniel
Browse files

Reroute to Credman based on autofill hint

Currently, Autofill Manager looks at the view's isCredential attribute
to suppress fill dialog. Add a new autofill hint that Autofill Manager will look at to regard in the
same manner as the isCredential attribute. This hint will be set by the
Credential Manager's support library.

The autofill hint has been available for older Android versions while
isCredential is only available for U+. In the future, if AwG can support
rerouting to CredentialManager based on the autofill hint, we could
enable Credman support in Autofill for U-.

Bug: 299319802
Test: atest CtsAutoFillServiceTestCases
Change-Id: I157735334c4141a78f5743282dd09c32e3200e6a
parent dd593baa
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1327,6 +1327,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    // TODO(229765029): unhide this for UI toolkit
    public static final String AUTOFILL_HINT_PASSWORD_AUTO = "passwordAuto";
    /**
     * Hint indicating that the developer intends to fill this view with output from
     * CredentialManager.
     *
     * @hide
     */
    public static final String AUTOFILL_HINT_CREDENTIAL_MANAGER = "credential";
    /**
     * Hints for the autofill services that describes the content of the view.
     */
+18 −2
Original line number Diff line number Diff line
@@ -1464,7 +1464,7 @@ public final class AutofillManager {
        if (infos.size() == 0) {
            throw new IllegalArgumentException("No VirtualViewInfo found");
        }
        if (view.isCredential() && mIsFillAndSaveDialogDisabledForCredentialManager) {
        if (isCredmanRequested(view) && mIsFillAndSaveDialogDisabledForCredentialManager) {
            if (sDebug) {
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                        + view.getAutofillId().toString());
@@ -1488,7 +1488,7 @@ public final class AutofillManager {
     * @hide
     */
    public void notifyViewEnteredForFillDialog(View v) {
        if (v.isCredential()
        if (isCredmanRequested(v)
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            if (sDebug) {
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
@@ -3434,6 +3434,22 @@ public final class AutofillManager {
        }
    }

    private boolean isCredmanRequested(View view) {
        if (view.isCredential()) {
            return true;
        }
        String[] hints = view.getAutofillHints();
        if (hints == null) {
            return false;
        }
        for (String hint : hints) {
            if (hint.equals(View.AUTOFILL_HINT_CREDENTIAL_MANAGER)) {
                return true;
            }
        }
        return false;
    }

    /**
     * Find a single view by its id.
     *