Adds a config for default autofill service.
Change-Id: I4d2d8637617439c5df3f62426e9bc45a78edc2e3
Fixes: 35708268
Bug: 36790693
Test: manual verification
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 0d0ddf2..1f559e4 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -2798,7 +2798,7 @@
}
private final class UpgradeController {
- private static final int SETTINGS_VERSION = 143;
+ private static final int SETTINGS_VERSION = 144;
private final int mUserId;
@@ -3324,7 +3324,7 @@
}
if (currentVersion == 141) {
- // Version 141: We added the notion of a default and whether the system set
+ // Version 142: We added the notion of a default and whether the system set
// the setting. This is used for resetting the internal state and we need
// to make sure this value is updated for the existing settings, otherwise
// we would delete system set settings while they should stay unmodified.
@@ -3344,7 +3344,7 @@
}
if (currentVersion == 142) {
- // Version 142: Set a default value for Wi-Fi wakeup feature.
+ // Version 143: Set a default value for Wi-Fi wakeup feature.
if (userId == UserHandle.USER_SYSTEM) {
final SettingsState globalSettings = getGlobalSettingsLocked();
Setting currentSetting = globalSettings.getSettingLocked(
@@ -3361,6 +3361,27 @@
currentVersion = 143;
}
+ if (currentVersion == 143) {
+ // Version 144: Set a default value for Autofill service.
+ final SettingsState secureSettings = getSecureSettingsLocked(userId);
+ final Setting currentSetting = secureSettings
+ .getSettingLocked(Settings.Secure.AUTOFILL_SERVICE);
+ if (currentSetting.isNull()) {
+ final String defaultValue = getContext().getResources().getString(
+ com.android.internal.R.string.config_defaultAutofillService);
+ if (defaultValue != null) {
+ Slog.d(LOG_TAG, "Setting [" + defaultValue + "] as Autofill Service "
+ + "for user " + userId);
+ secureSettings.insertSettingLocked(Settings.Secure.AUTOFILL_SERVICE,
+ defaultValue, null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+ }
+
+ currentVersion = 144;
+ }
+
+ // vXXX: Add new settings above this point.
+
if (currentVersion != newVersion) {
Slog.wtf("SettingsProvider", "warning: upgrading settings database to version "
+ newVersion + " left it at "
@@ -3372,8 +3393,6 @@
}
}
- // vXXX: Add new settings above this point.
-
// Return the current version.
return currentVersion;
}