Make fill dialog feature controlled by device config

Use device config to control whether autofill dialog feature is enabled.
To support this, the autofill namespace of DeviceConfig needs to be exposed
for AutofillManager to read in the app thread.
There are augmented_autofill_mode, smart_suggestion_supported_modes and
compat_mode_allowed_packages existed in autofill space. These can be made
app readable.

Bug: 210926084
Test: atest android.autofillservice.cts.dialog.LoginActivityTest
Change-Id: Idfb846656a0c26eba1db4f8ef6ec427ae4ca666d
This commit is contained in:
TYM Tsai
2022-02-18 18:12:56 +08:00
parent 038fd80ce8
commit 261ac24929
3 changed files with 25 additions and 3 deletions

View File

@@ -2960,6 +2960,7 @@ package android.view.autofill {
public final class AutofillManager {
field public static final String DEVICE_CONFIG_AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "compat_mode_allowed_packages";
field public static final String DEVICE_CONFIG_AUTOFILL_DIALOG_ENABLED = "autofill_dialog_enabled";
field public static final String DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES = "smart_suggestion_supported_modes";
field public static final int FLAG_SMART_SUGGESTION_OFF = 0; // 0x0
field public static final int FLAG_SMART_SUGGESTION_SYSTEM = 1; // 0x1

View File

@@ -586,7 +586,7 @@ public final class DeviceConfig {
@NonNull
private static final List<String> PUBLIC_NAMESPACES =
Arrays.asList(NAMESPACE_TEXTCLASSIFIER, NAMESPACE_RUNTIME, NAMESPACE_STATSD_JAVA,
NAMESPACE_STATSD_JAVA_BOOT, NAMESPACE_SELECTION_TOOLBAR);
NAMESPACE_STATSD_JAVA_BOOT, NAMESPACE_SELECTION_TOOLBAR, NAMESPACE_AUTOFILL);
/**
* Privacy related properties definitions.
*

View File

@@ -58,6 +58,7 @@ import android.os.Looper;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import android.provider.DeviceConfig;
import android.service.autofill.AutofillService;
import android.service.autofill.FillCallback;
import android.service.autofill.FillEventHistory;
@@ -491,6 +492,15 @@ public final class AutofillManager {
public static final String DEVICE_CONFIG_AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES =
"compat_mode_allowed_packages";
/**
* Sets the fill dialog feature enabled or not.
*
* @hide
*/
@TestApi
public static final String DEVICE_CONFIG_AUTOFILL_DIALOG_ENABLED =
"autofill_dialog_enabled";
/** @hide */
public static final int RESULT_OK = 0;
/** @hide */
@@ -539,7 +549,7 @@ public final class AutofillManager {
*/
public static final int NO_SESSION = Integer.MAX_VALUE;
private static final boolean HAS_FILL_DIALOG_UI_FEATURE = false;
private static final boolean HAS_FILL_DIALOG_UI_FEATURE_DEFAULT = false;
private final IAutoFillManager mService;
@@ -655,6 +665,8 @@ public final class AutofillManager {
@Nullable private List<AutofillId> mFillDialogTriggerIds;
private final boolean mIsFillDialogEnabled;
/** @hide */
public interface AutofillClient {
/**
@@ -795,6 +807,14 @@ public final class AutofillManager {
mIsFillRequested = false;
mRequireAutofill = false;
mIsFillDialogEnabled = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_AUTOFILL,
DEVICE_CONFIG_AUTOFILL_DIALOG_ENABLED,
HAS_FILL_DIALOG_UI_FEATURE_DEFAULT);
if (sDebug) {
Log.d(TAG, "Fill dialog is enabled:" + mIsFillDialogEnabled);
}
if (mOptions != null) {
sDebug = (mOptions.loggingLevel & FLAG_ADD_CLIENT_DEBUG) != 0;
sVerbose = (mOptions.loggingLevel & FLAG_ADD_CLIENT_VERBOSE) != 0;
@@ -1081,7 +1101,7 @@ public final class AutofillManager {
}
private boolean hasFillDialogUiFeature() {
return HAS_FILL_DIALOG_UI_FEATURE;
return mIsFillDialogEnabled;
}
/**
@@ -3012,6 +3032,7 @@ public final class AutofillManager {
}
pw.print(pfx); pw.print("compat mode enabled: ");
synchronized (mLock) {
pw.print(pfx); pw.print("fill dialog enabled: "); pw.println(mIsFillDialogEnabled);
if (mCompatibilityBridge != null) {
final String pfx2 = pfx + " ";
pw.println("true");