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

Commit 7841d02e authored by Felipe Leme's avatar Felipe Leme
Browse files

Use DeviceConfig to configure Augmented Autofill Modes.

Test: atest AugmentedLoginActivityTest
Bug: 121037717

Change-Id: I269946b3055bce82872976d88fa315c7d8c01b99
parent d5df08e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1813,7 +1813,6 @@ package android.provider {

  public static final class Settings.Global extends android.provider.Settings.NameValueTable {
    field public static final String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages";
    field public static final String AUTOFILL_SMART_SUGGESTION_EMULATION_FLAGS = "autofill_smart_suggestion_emulation_flags";
    field public static final String AUTOMATIC_POWER_SAVER_MODE = "automatic_power_saver_mode";
    field public static final String CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS = "captive_portal_fallback_probe_specs";
    field public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url";
@@ -2694,6 +2693,7 @@ package android.view.autofill {

  public final class AutofillManager {
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    field public static final String DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES = "smart_suggestion_supported_modes";
    field public static final int FLAG_SMART_SUGGESTION_SYSTEM = 1; // 0x1
    field public static final int MAX_TEMP_AUGMENTED_SERVICE_DURATION_MS = 120000; // 0x1d4c0
  }
+0 −11
Original line number Diff line number Diff line
@@ -13284,17 +13284,6 @@ public final class Settings {
         */
        public static final String AUTOFILL_MAX_VISIBLE_DATASETS = "autofill_max_visible_datasets";
        /**
         * Used to emulate Smart Suggestion for Augmented Autofill during development
         *
         * <p>Valid values: {@code 0x1} for IME and/or {@code 0x2} for popup window.
         *
         * @hide
         */
        @TestApi
        public static final String AUTOFILL_SMART_SUGGESTION_EMULATION_FLAGS =
                "autofill_smart_suggestion_emulation_flags";
        /**
         * Exemptions to the hidden API blacklist.
         *
+10 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.view.autofill;

import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.util.DebugUtils.flagsToString;
import static android.view.autofill.Helper.sDebug;
import static android.view.autofill.Helper.sVerbose;

@@ -353,6 +352,15 @@ public final class AutofillManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface SmartSuggestionMode {}

    /**
     * Used to emulate Smart Suggestion for Augmented Autofill during development
     *
     * @hide
     */
    @TestApi
    public static final String DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES =
            "smart_suggestion_supported_modes";

    /**
     * Makes an authentication id from a request id and a dataset id.
     *
@@ -2347,7 +2355,7 @@ public final class AutofillManager {

    /** @hide */
    public static String getSmartSuggestionModeToString(@SmartSuggestionMode int flags) {
        return flagsToString(AutofillManager.class, "FLAG_SMART_SUGGESTION_", flags);
        return (flags == FLAG_SMART_SUGGESTION_SYSTEM) ? "1-SYSTEM" : flags + "-UNSUPPORTED";
    }

    @GuardedBy("mLock")
+0 −1
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ public class SettingsBackupTest {
                    Settings.Global.AUTOFILL_LOGGING_LEVEL,
                    Settings.Global.AUTOFILL_MAX_PARTITIONS_SIZE,
                    Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS,
                    Settings.Global.AUTOFILL_SMART_SUGGESTION_EMULATION_FLAGS,
                    Settings.Global.AUTOMATIC_POWER_SAVER_MODE,
                    Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED,
                    Settings.Global.BATTERY_CHARGING_STATE_UPDATE_DELAY,
+24 −14
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.os.ResultReceiver;
import android.os.ShellCallback;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.service.autofill.FillEventHistory;
import android.service.autofill.UserData;
@@ -167,10 +168,14 @@ public final class AutofillManagerService
        mUi = new AutoFillUI(ActivityThread.currentActivityThread().getSystemUiContext());
        mAm = LocalServices.getService(ActivityManagerInternal.class);

        DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_AUTOFILL,
                ActivityThread.currentApplication().getMainExecutor(),
                (namespace, name, value) -> setSmartSuggestionModesFromDeviceConfig(value));

        setLogLevelFromSettings();
        setMaxPartitionsFromSettings();
        setMaxVisibleDatasetsFromSettings();
        setSmartSuggestionEmulationFromSettings();
        setSmartSuggestionModesFromDeviceConfig();

        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
@@ -197,9 +202,6 @@ public final class AutofillManagerService
        resolver.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS), false, observer,
                UserHandle.USER_ALL);
        resolver.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.AUTOFILL_SMART_SUGGESTION_EMULATION_FLAGS), false, observer,
                UserHandle.USER_ALL);
    }

    @Override // from AbstractMasterSystemService
@@ -214,9 +216,6 @@ public final class AutofillManagerService
            case Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS:
                setMaxVisibleDatasetsFromSettings();
                break;
            case Settings.Global.AUTOFILL_SMART_SUGGESTION_EMULATION_FLAGS:
                setSmartSuggestionEmulationFromSettings();
                break;
            default:
                Slog.w(TAG, "Unexpected property (" + property + "); updating cache instead");
                // fall through
@@ -457,14 +456,25 @@ public final class AutofillManagerService
        }
    }

    private void setSmartSuggestionEmulationFromSettings() {
        final int flags = Settings.Global.getInt(getContext().getContentResolver(),
                Settings.Global.AUTOFILL_SMART_SUGGESTION_EMULATION_FLAGS, 0);
        if (sDebug) {
            Slog.d(TAG, "setSmartSuggestionEmulationFromSettings(): "
                    + getSmartSuggestionModeToString(flags));
    private void setSmartSuggestionModesFromDeviceConfig() {
        final String value = DeviceConfig.getProperty(DeviceConfig.NAMESPACE_AUTOFILL,
                AutofillManager.DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES);
        setSmartSuggestionModesFromDeviceConfig(value);
    }

    private void setSmartSuggestionModesFromDeviceConfig(@Nullable String value) {
        if (sDebug) Slog.d(TAG, "setSmartSuggestionEmulationFromDeviceConfig(): value=" + value);
        final int flags;
        if (value == null) {
            flags = AutofillManager.FLAG_SMART_SUGGESTION_SYSTEM;
        } else {
            try {
                flags = Integer.parseInt(value);
            } catch (Exception e) {
                Slog.w(TAG, "setSmartSuggestionEmulationFromDeviceConfig(): NAN:" + value);
                return;
            }
        }
        synchronized (mLock) {
            mSupportedSmartSuggestionModes = flags;
        }