Loading core/java/android/service/autofill/FillRequest.java +11 −2 Original line number Diff line number Diff line Loading @@ -71,12 +71,21 @@ public final class FillRequest implements Parcelable { */ public static final int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2; /** * Indicates the request came from a password field. * * (TODO: b/141703197) Temporary fix for augmented autofill showing passwords. * * @hide */ public static final @RequestFlags int FLAG_PASSWORD_INPUT_TYPE = 0x4; /** @hide */ public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST, FLAG_PASSWORD_INPUT_TYPE }) @Retention(RetentionPolicy.SOURCE) @interface RequestFlags{} Loading @@ -100,7 +109,7 @@ public final class FillRequest implements Parcelable { @Nullable Bundle clientState, @RequestFlags int flags) { mId = id; mFlags = Preconditions.checkFlagsArgument(flags, FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST); FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST | FLAG_PASSWORD_INPUT_TYPE); mContexts = Preconditions.checkCollectionElementsNotNull(contexts, "contexts"); mClientState = clientState; } Loading core/java/android/view/autofill/AutofillManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.view.autofill; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; import static android.view.autofill.Helper.sDebug; import static android.view.autofill.Helper.sVerbose; import static android.view.autofill.Helper.toList; Loading Loading @@ -60,6 +61,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeProvider; import android.view.accessibility.AccessibilityWindowInfo; import android.widget.TextView; import com.android.internal.annotations.GuardedBy; import com.android.internal.logging.MetricsLogger; Loading Loading @@ -966,6 +968,10 @@ public final class AutofillManager { if (!isClientDisablingEnterExitEvent()) { final AutofillValue value = view.getAutofillValue(); if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) { flags |= FLAG_PASSWORD_INPUT_TYPE; } if (!isActiveLocked()) { // Starts new session. startSessionLocked(id, null, value, flags); Loading Loading @@ -1130,6 +1136,10 @@ public final class AutofillManager { } else { // don't notify entered when Activity is already in background if (!isClientDisablingEnterExitEvent()) { if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) { flags |= FLAG_PASSWORD_INPUT_TYPE; } if (!isActiveLocked()) { // Starts new session. startSessionLocked(id, bounds, null, flags); Loading core/java/android/widget/TextView.java +10 −0 Original line number Diff line number Diff line Loading @@ -6582,6 +6582,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return mTransformation instanceof PasswordTransformationMethod; } /** * Returns true if the current inputType is any type of password. * * @hide */ public boolean isAnyPasswordInputType() { final int inputType = getInputType(); return isPasswordInputType(inputType) || isVisiblePasswordInputType(inputType); } static boolean isPasswordInputType(int inputType) { final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); Loading services/autofill/java/com/android/server/autofill/Session.java +20 −8 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.autofill; import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; import static android.view.autofill.AutofillManager.ACTION_START_SESSION; import static android.view.autofill.AutofillManager.ACTION_VALUE_CHANGED; Loading Loading @@ -581,7 +582,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState + ", flags=" + flags + ")"); } mForAugmentedAutofillOnly = true; triggerAugmentedAutofillLocked(); triggerAugmentedAutofillLocked(flags); return; } viewState.setState(newState); Loading Loading @@ -780,7 +781,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState id, mCompatMode); } // Although "standard" autofill is disabled, it might still trigger augmented autofill if (triggerAugmentedAutofillLocked() != null) { if (triggerAugmentedAutofillLocked(requestFlags) != null) { mForAugmentedAutofillOnly = true; if (sDebug) { Slog.d(TAG, "Service disabled autofill for " + mComponentName Loading Loading @@ -2424,7 +2425,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (sDebug) Slog.d(TAG, "updateLocked(" + id + "): augmented-autofillable"); // ...then trigger the augmented autofill UI triggerAugmentedAutofillLocked(); triggerAugmentedAutofillLocked(flags); return; } Loading Loading @@ -2688,8 +2689,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // The default autofill service cannot fullfill the request, let's check if the augmented // autofill service can. mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(); if (mAugmentedAutofillDestroyer == null) { mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(flags); if (mAugmentedAutofillDestroyer == null && ((flags & FLAG_PASSWORD_INPUT_TYPE) == 0)) { if (sVerbose) { Slog.v(TAG, "canceling session " + id + " when service returned null and it cannot " + "be augmented. AutofillableIds: " + autofillableIds); Loading @@ -2699,9 +2700,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState removeSelf(); } else { if (sVerbose) { if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { Slog.v(TAG, "keeping session " + id + " when service returned null and " + "augmented service is disabled for password fields. " + "AutofillableIds: " + autofillableIds); } else { Slog.v(TAG, "keeping session " + id + " when service returned null but " + "it can be augmented. AutofillableIds: " + autofillableIds); } } mAugmentedAutofillableIds = autofillableIds; try { mClient.setState(AutofillManager.SET_STATE_FLAG_FOR_AUTOFILL_ONLY); Loading @@ -2719,7 +2726,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO(b/123099468): might need to call it in other places, like when the service returns a // non-null response but without datasets (for example, just SaveInfo) @GuardedBy("mLock") private Runnable triggerAugmentedAutofillLocked() { private Runnable triggerAugmentedAutofillLocked(int flags) { // (TODO: b/141703197) Fix later by passing info to service. if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { return null; } // Check if Smart Suggestions is supported... final @SmartSuggestionMode int supportedModes = mService .getSupportedSmartSuggestionModesLocked(); Loading Loading
core/java/android/service/autofill/FillRequest.java +11 −2 Original line number Diff line number Diff line Loading @@ -71,12 +71,21 @@ public final class FillRequest implements Parcelable { */ public static final int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2; /** * Indicates the request came from a password field. * * (TODO: b/141703197) Temporary fix for augmented autofill showing passwords. * * @hide */ public static final @RequestFlags int FLAG_PASSWORD_INPUT_TYPE = 0x4; /** @hide */ public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST, FLAG_PASSWORD_INPUT_TYPE }) @Retention(RetentionPolicy.SOURCE) @interface RequestFlags{} Loading @@ -100,7 +109,7 @@ public final class FillRequest implements Parcelable { @Nullable Bundle clientState, @RequestFlags int flags) { mId = id; mFlags = Preconditions.checkFlagsArgument(flags, FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST); FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST | FLAG_PASSWORD_INPUT_TYPE); mContexts = Preconditions.checkCollectionElementsNotNull(contexts, "contexts"); mClientState = clientState; } Loading
core/java/android/view/autofill/AutofillManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.view.autofill; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; import static android.view.autofill.Helper.sDebug; import static android.view.autofill.Helper.sVerbose; import static android.view.autofill.Helper.toList; Loading Loading @@ -60,6 +61,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeProvider; import android.view.accessibility.AccessibilityWindowInfo; import android.widget.TextView; import com.android.internal.annotations.GuardedBy; import com.android.internal.logging.MetricsLogger; Loading Loading @@ -966,6 +968,10 @@ public final class AutofillManager { if (!isClientDisablingEnterExitEvent()) { final AutofillValue value = view.getAutofillValue(); if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) { flags |= FLAG_PASSWORD_INPUT_TYPE; } if (!isActiveLocked()) { // Starts new session. startSessionLocked(id, null, value, flags); Loading Loading @@ -1130,6 +1136,10 @@ public final class AutofillManager { } else { // don't notify entered when Activity is already in background if (!isClientDisablingEnterExitEvent()) { if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) { flags |= FLAG_PASSWORD_INPUT_TYPE; } if (!isActiveLocked()) { // Starts new session. startSessionLocked(id, bounds, null, flags); Loading
core/java/android/widget/TextView.java +10 −0 Original line number Diff line number Diff line Loading @@ -6582,6 +6582,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return mTransformation instanceof PasswordTransformationMethod; } /** * Returns true if the current inputType is any type of password. * * @hide */ public boolean isAnyPasswordInputType() { final int inputType = getInputType(); return isPasswordInputType(inputType) || isVisiblePasswordInputType(inputType); } static boolean isPasswordInputType(int inputType) { final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); Loading
services/autofill/java/com/android/server/autofill/Session.java +20 −8 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.autofill; import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; import static android.view.autofill.AutofillManager.ACTION_START_SESSION; import static android.view.autofill.AutofillManager.ACTION_VALUE_CHANGED; Loading Loading @@ -581,7 +582,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState + ", flags=" + flags + ")"); } mForAugmentedAutofillOnly = true; triggerAugmentedAutofillLocked(); triggerAugmentedAutofillLocked(flags); return; } viewState.setState(newState); Loading Loading @@ -780,7 +781,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState id, mCompatMode); } // Although "standard" autofill is disabled, it might still trigger augmented autofill if (triggerAugmentedAutofillLocked() != null) { if (triggerAugmentedAutofillLocked(requestFlags) != null) { mForAugmentedAutofillOnly = true; if (sDebug) { Slog.d(TAG, "Service disabled autofill for " + mComponentName Loading Loading @@ -2424,7 +2425,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (sDebug) Slog.d(TAG, "updateLocked(" + id + "): augmented-autofillable"); // ...then trigger the augmented autofill UI triggerAugmentedAutofillLocked(); triggerAugmentedAutofillLocked(flags); return; } Loading Loading @@ -2688,8 +2689,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // The default autofill service cannot fullfill the request, let's check if the augmented // autofill service can. mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(); if (mAugmentedAutofillDestroyer == null) { mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(flags); if (mAugmentedAutofillDestroyer == null && ((flags & FLAG_PASSWORD_INPUT_TYPE) == 0)) { if (sVerbose) { Slog.v(TAG, "canceling session " + id + " when service returned null and it cannot " + "be augmented. AutofillableIds: " + autofillableIds); Loading @@ -2699,9 +2700,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState removeSelf(); } else { if (sVerbose) { if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { Slog.v(TAG, "keeping session " + id + " when service returned null and " + "augmented service is disabled for password fields. " + "AutofillableIds: " + autofillableIds); } else { Slog.v(TAG, "keeping session " + id + " when service returned null but " + "it can be augmented. AutofillableIds: " + autofillableIds); } } mAugmentedAutofillableIds = autofillableIds; try { mClient.setState(AutofillManager.SET_STATE_FLAG_FOR_AUTOFILL_ONLY); Loading @@ -2719,7 +2726,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO(b/123099468): might need to call it in other places, like when the service returns a // non-null response but without datasets (for example, just SaveInfo) @GuardedBy("mLock") private Runnable triggerAugmentedAutofillLocked() { private Runnable triggerAugmentedAutofillLocked(int flags) { // (TODO: b/141703197) Fix later by passing info to service. if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { return null; } // Check if Smart Suggestions is supported... final @SmartSuggestionMode int supportedModes = mService .getSupportedSmartSuggestionModesLocked(); Loading