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

Commit 26fba80f authored by Daniel Kim's avatar Daniel Kim Committed by Android (Google) Code Review
Browse files

Merge "Disregard isCredential for routing to proxy service" into main

parents 9139fe4e 68d247ac
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -1469,7 +1469,8 @@ public final class AutofillManager {
        if (infos.size() == 0) {
            throw new IllegalArgumentException("No VirtualViewInfo found");
        }
        if (isCredmanRequested(view) && mIsFillAndSaveDialogDisabledForCredentialManager) {
        if (shouldSuppressDialogsForCredman(view)
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            if (sDebug) {
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                        + view.getAutofillId().toString());
@@ -1493,7 +1494,7 @@ public final class AutofillManager {
     * @hide
     */
    public void notifyViewEnteredForFillDialog(View v) {
        if (isCredmanRequested(v)
        if (shouldSuppressDialogsForCredman(v)
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            if (sDebug) {
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
@@ -3390,19 +3391,39 @@ public final class AutofillManager {
        }
    }

    private boolean isCredmanRequested(View view) {
    private boolean shouldSuppressDialogsForCredman(View view) {
        if (view == null) {
            return false;
        }
        // isCredential field indicates that the developer might be calling Credman, and we should
        // suppress autofill dialogs. But it is not a good enough indicator that there is a valid
        // credman option.
        if (view.isCredential()) {
            return true;
        }
        return containsAutofillHintPrefix(view, View.AUTOFILL_HINT_CREDENTIAL_MANAGER);
    }

    private boolean isCredmanRequested(View view) {
        if (view == null) {
            return false;
        }
        String[] hints = view.getAutofillHints();
        if (hints == null) {
            return false;
        }
        // if hint starts with 'credential=', then we assume that there is a valid
        // credential option set by the client.
        return containsAutofillHintPrefix(view, View.AUTOFILL_HINT_CREDENTIAL_MANAGER + "=");
    }

    private boolean containsAutofillHintPrefix(View view, String prefix) {
        String[] hints = view.getAutofillHints();
        if (hints == null) {
            return false;
        }
        for (String hint : hints) {
            if (hint != null && hint.startsWith(View.AUTOFILL_HINT_CREDENTIAL_MANAGER)) {
            if (hint != null && hint.startsWith(prefix)) {
                return true;
            }
        }