Merge "[DO NOT MERGE] Suppress fill and save dialog for activities that have credman field." into udc-dev
This commit is contained in:
@@ -121,6 +121,12 @@ public final class FillRequest implements Parcelable {
|
||||
*/
|
||||
public static final @RequestFlags int FLAG_PCC_DETECTION = 0x200;
|
||||
|
||||
/**
|
||||
* Indicate whether the screen has credman field
|
||||
* @hide
|
||||
*/
|
||||
public static final @RequestFlags int FLAG_SCREEN_HAS_CREDMAN_FIELD = 0x400;
|
||||
|
||||
/** @hide */
|
||||
public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;
|
||||
|
||||
@@ -234,7 +240,8 @@ public final class FillRequest implements Parcelable {
|
||||
FLAG_SUPPORTS_FILL_DIALOG,
|
||||
FLAG_IME_SHOWING,
|
||||
FLAG_RESET_FILL_DIALOG_STATE,
|
||||
FLAG_PCC_DETECTION
|
||||
FLAG_PCC_DETECTION,
|
||||
FLAG_SCREEN_HAS_CREDMAN_FIELD
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@DataClass.Generated.Member
|
||||
@@ -266,6 +273,8 @@ public final class FillRequest implements Parcelable {
|
||||
return "FLAG_RESET_FILL_DIALOG_STATE";
|
||||
case FLAG_PCC_DETECTION:
|
||||
return "FLAG_PCC_DETECTION";
|
||||
case FLAG_SCREEN_HAS_CREDMAN_FIELD:
|
||||
return "FLAG_SCREEN_HAS_CREDMAN_FIELD";
|
||||
default: return Integer.toHexString(value);
|
||||
}
|
||||
}
|
||||
@@ -282,10 +291,15 @@ public final class FillRequest implements Parcelable {
|
||||
* include contexts from requests whose {@link SaveInfo} had the
|
||||
* {@link SaveInfo#FLAG_DELAY_SAVE} flag.
|
||||
* @param hints
|
||||
* Autofill Provider should return data for the autofill hints requested here,
|
||||
* Sends a list of datatypes for the Autofill Provider.
|
||||
*
|
||||
* If this is populated, Autofill Provider should return data
|
||||
* for the autofill hints requested here,
|
||||
* even though the Autofill Provider may not have detected these types.
|
||||
* The hints would be part of HintConstants:
|
||||
* https://developer.android.com/reference/androidx/autofill/HintConstants
|
||||
*
|
||||
* This is populated if the platform's field detection is enabled.
|
||||
* @param clientState
|
||||
* Gets the latest client state bundle set by the service in a
|
||||
* {@link FillResponse.Builder#setClientState(Bundle) fill response}.
|
||||
@@ -353,7 +367,8 @@ public final class FillRequest implements Parcelable {
|
||||
| FLAG_SUPPORTS_FILL_DIALOG
|
||||
| FLAG_IME_SHOWING
|
||||
| FLAG_RESET_FILL_DIALOG_STATE
|
||||
| FLAG_PCC_DETECTION);
|
||||
| FLAG_PCC_DETECTION
|
||||
| FLAG_SCREEN_HAS_CREDMAN_FIELD);
|
||||
this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
|
||||
this.mDelayedFillIntentSender = delayedFillIntentSender;
|
||||
|
||||
@@ -381,10 +396,15 @@ public final class FillRequest implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Autofill Provider should return data for the autofill hints requested here,
|
||||
* Sends a list of datatypes for the Autofill Provider.
|
||||
*
|
||||
* If this is populated, Autofill Provider should return data
|
||||
* for the autofill hints requested here,
|
||||
* even though the Autofill Provider may not have detected these types.
|
||||
* The hints would be part of HintConstants:
|
||||
* https://developer.android.com/reference/androidx/autofill/HintConstants
|
||||
*
|
||||
* This is populated if the platform's field detection is enabled.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull List<String> getHints() {
|
||||
@@ -534,7 +554,8 @@ public final class FillRequest implements Parcelable {
|
||||
| FLAG_SUPPORTS_FILL_DIALOG
|
||||
| FLAG_IME_SHOWING
|
||||
| FLAG_RESET_FILL_DIALOG_STATE
|
||||
| FLAG_PCC_DETECTION);
|
||||
| FLAG_PCC_DETECTION
|
||||
| FLAG_SCREEN_HAS_CREDMAN_FIELD);
|
||||
this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
|
||||
this.mDelayedFillIntentSender = delayedFillIntentSender;
|
||||
|
||||
@@ -556,10 +577,10 @@ public final class FillRequest implements Parcelable {
|
||||
};
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1675711417112L,
|
||||
time = 1682097266850L,
|
||||
codegenVersion = "1.0.23",
|
||||
sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
|
||||
inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SUPPORTS_FILL_DIALOG\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_IME_SHOWING\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_RESET_FILL_DIALOG_STATE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PCC_DETECTION\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.NonNull java.util.List<java.lang.String> mHints\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate final @android.annotation.Nullable android.content.IntentSender mDelayedFillIntentSender\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
|
||||
inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SUPPORTS_FILL_DIALOG\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_IME_SHOWING\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_RESET_FILL_DIALOG_STATE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PCC_DETECTION\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SCREEN_HAS_CREDMAN_FIELD\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.NonNull java.util.List<java.lang.String> mHints\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate final @android.annotation.Nullable android.content.IntentSender mDelayedFillIntentSender\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
@@ -10380,11 +10380,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disable triggering autofill if the view is integrated with CredentialManager.
|
||||
if (afm.shouldIgnoreCredentialViews() && isCredential()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check whether view is not part of an activity. If it's not, return false.
|
||||
if (getAutofillViewId() <= LAST_APP_AUTOFILL_ID) {
|
||||
return false;
|
||||
|
||||
@@ -99,39 +99,34 @@ public class AutofillFeatureFlags {
|
||||
"autofill_dialog_hints";
|
||||
|
||||
// START CREDENTIAL MANAGER FLAGS //
|
||||
|
||||
/**
|
||||
* Indicates whether credential manager tagged views should be ignored from autofill structures.
|
||||
* This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
|
||||
* (deprecated) Indicates whether credential manager tagged views should be ignored from
|
||||
* autofill structures.This flag is further gated by
|
||||
* {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
|
||||
*
|
||||
* TODO(b/280661772): Remove this flag once API change is allowed
|
||||
*/
|
||||
public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS =
|
||||
"autofill_credential_manager_ignore_views";
|
||||
|
||||
/**
|
||||
* Indicates CredentialManager feature enabled or not.
|
||||
* (deprecated) Indicates CredentialManager feature enabled or not.
|
||||
* This is the overall feature flag. Individual behavior of credential manager may be controlled
|
||||
* via a different flag, but gated by this flag.
|
||||
*
|
||||
* TODO(b/280661772): Remove this flag once API change is allowed
|
||||
*/
|
||||
public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED =
|
||||
"autofill_credential_manager_enabled";
|
||||
|
||||
/**
|
||||
* Indicates whether credential manager tagged views should suppress fill dialog.
|
||||
* Indicates whether credential manager tagged views should suppress fill and save dialog.
|
||||
* This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG =
|
||||
"autofill_credential_manager_suppress_fill_dialog";
|
||||
|
||||
/**
|
||||
* Indicates whether credential manager tagged views should suppress save dialog.
|
||||
* This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_SAVE_DIALOG =
|
||||
"autofill_credential_manager_suppress_save_dialog";
|
||||
public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG =
|
||||
"autofill_credential_manager_suppress_fill_and_save_dialog";
|
||||
// END CREDENTIAL MANAGER FLAGS //
|
||||
|
||||
// START AUTOFILL FOR ALL APPS FLAGS //
|
||||
@@ -270,11 +265,7 @@ public class AutofillFeatureFlags {
|
||||
|
||||
|
||||
// CREDENTIAL MANAGER DEFAULTS
|
||||
// Credential manager is enabled by default so as to allow testing by app developers
|
||||
private static final boolean DEFAULT_CREDENTIAL_MANAGER_ENABLED = true;
|
||||
private static final boolean DEFAULT_CREDENTIAL_MANAGER_IGNORE_VIEWS = true;
|
||||
private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG = false;
|
||||
private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_SAVE_DIALOG = false;
|
||||
private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG = true;
|
||||
// END CREDENTIAL MANAGER DEFAULTS
|
||||
|
||||
|
||||
@@ -317,43 +308,19 @@ public class AutofillFeatureFlags {
|
||||
(str) -> !TextUtils.isEmpty(str));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the Credential Manager feature is enabled or not
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isCredentialManagerEnabled() {
|
||||
return DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_AUTOFILL,
|
||||
DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED,
|
||||
DEFAULT_CREDENTIAL_MANAGER_ENABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether credential manager tagged views should be ignored for autofill structure.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean shouldIgnoreCredentialViews() {
|
||||
return isCredentialManagerEnabled()
|
||||
&& DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_AUTOFILL,
|
||||
DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS,
|
||||
DEFAULT_CREDENTIAL_MANAGER_IGNORE_VIEWS);
|
||||
}
|
||||
|
||||
/* starts credman flag getter function */
|
||||
/**
|
||||
* Whether credential manager tagged views should not trigger fill dialog requests.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isFillDialogDisabledForCredentialManager() {
|
||||
return isCredentialManagerEnabled()
|
||||
&& DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_AUTOFILL,
|
||||
DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG,
|
||||
DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG);
|
||||
public static boolean isFillAndSaveDialogDisabledForCredentialManager() {
|
||||
return DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_AUTOFILL,
|
||||
DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG,
|
||||
DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG);
|
||||
}
|
||||
/* ends credman flag getter function */
|
||||
|
||||
/**
|
||||
* Whether triggering fill request on unimportant view is enabled.
|
||||
|
||||
@@ -21,6 +21,7 @@ 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.FLAG_PCC_DETECTION;
|
||||
import static android.service.autofill.FillRequest.FLAG_RESET_FILL_DIALOG_STATE;
|
||||
import static android.service.autofill.FillRequest.FLAG_SCREEN_HAS_CREDMAN_FIELD;
|
||||
import static android.service.autofill.FillRequest.FLAG_SUPPORTS_FILL_DIALOG;
|
||||
import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED;
|
||||
import static android.view.ContentInfo.SOURCE_AUTOFILL;
|
||||
@@ -33,7 +34,6 @@ import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresFeature;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.annotation.TestApi;
|
||||
@@ -109,7 +109,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import sun.misc.Cleaner;
|
||||
@@ -638,6 +637,8 @@ public final class AutofillManager {
|
||||
@GuardedBy("mLock")
|
||||
private boolean mEnabledForAugmentedAutofillOnly;
|
||||
|
||||
private boolean mHasCredentialField;
|
||||
|
||||
/**
|
||||
* Indicates whether there is already a field to do a fill request after
|
||||
* the activity started.
|
||||
@@ -653,6 +654,8 @@ public final class AutofillManager {
|
||||
|
||||
private final boolean mIsFillDialogEnabled;
|
||||
|
||||
private final boolean mIsFillAndSaveDialogDisabledForCredentialManager;
|
||||
|
||||
// Indicate whether trigger fill request on unimportant views is enabled
|
||||
private boolean mIsTriggerFillRequestOnUnimportantViewEnabled = false;
|
||||
|
||||
@@ -699,9 +702,6 @@ public final class AutofillManager {
|
||||
// Indicates whether called the showAutofillDialog() method.
|
||||
private boolean mShowAutofillDialogCalled = false;
|
||||
|
||||
// Cached autofill feature flag
|
||||
private boolean mShouldIgnoreCredentialViews = false;
|
||||
|
||||
private final String[] mFillDialogEnabledHints;
|
||||
|
||||
// Tracked all views that have appeared, including views that there are no
|
||||
@@ -849,7 +849,10 @@ public final class AutofillManager {
|
||||
|
||||
mIsFillDialogEnabled = AutofillFeatureFlags.isFillDialogEnabled();
|
||||
mFillDialogEnabledHints = AutofillFeatureFlags.getFillDialogEnabledHints();
|
||||
mShouldIgnoreCredentialViews = AutofillFeatureFlags.shouldIgnoreCredentialViews();
|
||||
|
||||
mIsFillAndSaveDialogDisabledForCredentialManager =
|
||||
AutofillFeatureFlags.isFillAndSaveDialogDisabledForCredentialManager();
|
||||
|
||||
if (sDebug) {
|
||||
Log.d(TAG, "Fill dialog is enabled:" + mIsFillDialogEnabled
|
||||
+ ", hints=" + Arrays.toString(mFillDialogEnabledHints));
|
||||
@@ -1415,12 +1418,12 @@ public final class AutofillManager {
|
||||
if (infos.size() == 0) {
|
||||
throw new IllegalArgumentException("No VirtualViewInfo found");
|
||||
}
|
||||
if (AutofillFeatureFlags.isFillDialogDisabledForCredentialManager()
|
||||
&& view.isCredential()) {
|
||||
if (view.isCredential() && mIsFillAndSaveDialogDisabledForCredentialManager) {
|
||||
if (sDebug) {
|
||||
Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
|
||||
+ view.getAutofillId().toString());
|
||||
}
|
||||
mHasCredentialField = true;
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < infos.size(); i++) {
|
||||
@@ -1442,12 +1445,13 @@ public final class AutofillManager {
|
||||
if (sDebug) {
|
||||
Log.d(TAG, "notifyViewEnteredForFillDialog:" + v.getAutofillId());
|
||||
}
|
||||
if (AutofillFeatureFlags.isFillDialogDisabledForCredentialManager()
|
||||
&& v.isCredential()) {
|
||||
if (v.isCredential()
|
||||
&& mIsFillAndSaveDialogDisabledForCredentialManager) {
|
||||
if (sDebug) {
|
||||
Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
|
||||
+ v.getAutofillId().toString());
|
||||
+ v.getAutofillId());
|
||||
}
|
||||
mHasCredentialField = true;
|
||||
return;
|
||||
}
|
||||
notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints());
|
||||
@@ -1500,7 +1504,7 @@ public final class AutofillManager {
|
||||
if (mIsFillDialogEnabled
|
||||
|| ArrayUtils.containsAny(autofillHints, mFillDialogEnabledHints)) {
|
||||
if (sDebug) {
|
||||
Log.d(TAG, "Trigger fill request when the view is ready.");
|
||||
Log.d(TAG, "Triggering pre-emptive request for fill dialog.");
|
||||
}
|
||||
|
||||
int flags = FLAG_SUPPORTS_FILL_DIALOG;
|
||||
@@ -1737,6 +1741,15 @@ public final class AutofillManager {
|
||||
flags |= FLAG_PASSWORD_INPUT_TYPE;
|
||||
}
|
||||
|
||||
// Update session when screen has credman field
|
||||
if (AutofillFeatureFlags.isFillAndSaveDialogDisabledForCredentialManager()
|
||||
&& mHasCredentialField) {
|
||||
flags |= FLAG_SCREEN_HAS_CREDMAN_FIELD;
|
||||
if (sVerbose) {
|
||||
Log.v(TAG, "updating session with flag screen has credman view");
|
||||
}
|
||||
}
|
||||
|
||||
flags |= getImeStateFlag(view);
|
||||
|
||||
if (!isActiveLocked()) {
|
||||
@@ -2239,11 +2252,6 @@ public final class AutofillManager {
|
||||
return client != null && client.autofillClientIsFillUiShowing();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean shouldIgnoreCredentialViews() {
|
||||
return mShouldIgnoreCredentialViews;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void onAuthenticationResult(int authenticationId, Intent data, View focusView) {
|
||||
if (!hasAutofillFeature()) {
|
||||
@@ -2449,6 +2457,7 @@ public final class AutofillManager {
|
||||
mIsFillRequested.set(false);
|
||||
mShowAutofillDialogCalled = false;
|
||||
mFillDialogTriggerIds = null;
|
||||
mHasCredentialField = false;
|
||||
mAllTrackedViews.clear();
|
||||
if (resetEnteredIds) {
|
||||
mEnteredIds = null;
|
||||
@@ -3540,7 +3549,8 @@ public final class AutofillManager {
|
||||
private boolean shouldShowAutofillDialog(View view, AutofillId id) {
|
||||
if (!hasFillDialogUiFeature()
|
||||
|| mShowAutofillDialogCalled
|
||||
|| mFillDialogTriggerIds == null) {
|
||||
|| mFillDialogTriggerIds == null
|
||||
|| mHasCredentialField) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,42 +51,12 @@ public class AutofillFeatureFlagsTest {
|
||||
assertThat(fillDialogHints[1]).isEqualTo("creditCardNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsCredentialManagerEnabled() {
|
||||
setCredentialManagerEnabled(false);
|
||||
assertThat(AutofillFeatureFlags.isCredentialManagerEnabled()).isFalse();
|
||||
setCredentialManagerEnabled(true);
|
||||
assertThat(AutofillFeatureFlags.isCredentialManagerEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldIgnoreCredentialManagerViews() {
|
||||
setCredentialManagerEnabled(false);
|
||||
setIgnoreCredentialManagerViews(true);
|
||||
// Overall feature is disabled, so we shouldn't ignore views.
|
||||
assertThat(AutofillFeatureFlags.shouldIgnoreCredentialViews()).isFalse();
|
||||
setCredentialManagerEnabled(true);
|
||||
assertThat(AutofillFeatureFlags.shouldIgnoreCredentialViews()).isTrue();
|
||||
}
|
||||
|
||||
private static void setFillDialogHints(String value) {
|
||||
setDeviceConfig(
|
||||
AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_DIALOG_HINTS,
|
||||
value);
|
||||
}
|
||||
|
||||
private static void setCredentialManagerEnabled(boolean value) {
|
||||
setDeviceConfig(
|
||||
AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED,
|
||||
String.valueOf(value));
|
||||
}
|
||||
|
||||
private static void setIgnoreCredentialManagerViews(boolean value) {
|
||||
setDeviceConfig(
|
||||
AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS,
|
||||
String.valueOf(value));
|
||||
}
|
||||
|
||||
private static void setDeviceConfig(String key, String value) {
|
||||
DeviceConfig.setProperty(
|
||||
DeviceConfig.NAMESPACE_AUTOFILL, key, value, /* makeDefault */ false);
|
||||
|
||||
@@ -27,6 +27,7 @@ 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.FLAG_PCC_DETECTION;
|
||||
import static android.service.autofill.FillRequest.FLAG_RESET_FILL_DIALOG_STATE;
|
||||
import static android.service.autofill.FillRequest.FLAG_SCREEN_HAS_CREDMAN_FIELD;
|
||||
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.INVALID_REQUEST_ID;
|
||||
@@ -592,6 +593,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
|
||||
/** Whether the fill dialog UI is disabled. */
|
||||
private boolean mFillDialogDisabled;
|
||||
|
||||
/** Whether current screen has credman field. */
|
||||
private boolean mScreenHasCredmanField;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3087,6 +3091,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
final FillResponse response = getLastResponseLocked("showSaveLocked(%s)");
|
||||
final SaveInfo saveInfo = response == null ? null : response.getSaveInfo();
|
||||
|
||||
/*
|
||||
* Don't show save if the session has credman field
|
||||
*
|
||||
* TODO: add a new enum NO_SAVE_UI_CREDMAN
|
||||
*/
|
||||
if (mSessionFlags.mScreenHasCredmanField) {
|
||||
if (sVerbose) {
|
||||
Slog.v(TAG, "Call to Session#showSaveLocked() rejected - "
|
||||
+ "there is credman field in screen");
|
||||
}
|
||||
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
|
||||
Event.NO_SAVE_UI_REASON_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
* The Save dialog is only shown if all conditions below are met:
|
||||
*
|
||||
@@ -3817,6 +3835,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
return;
|
||||
}
|
||||
|
||||
if ((flags & FLAG_SCREEN_HAS_CREDMAN_FIELD) != 0) {
|
||||
mSessionFlags.mScreenHasCredmanField = true;
|
||||
}
|
||||
|
||||
switch(action) {
|
||||
case ACTION_START_SESSION:
|
||||
// View is triggering autofill.
|
||||
@@ -4293,7 +4315,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
|
||||
private boolean isFillDialogUiEnabled() {
|
||||
synchronized (mLock) {
|
||||
return !mSessionFlags.mFillDialogDisabled;
|
||||
return !mSessionFlags.mFillDialogDisabled && !mSessionFlags.mScreenHasCredmanField;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user