Migrate the NETWORK_SCORER_APP to NETWORK_RECOMMENDATIONS_ENABLED.
If NETWORK_SCORER_APP has a non-null value then enabled NETWORK_RECOMMENDATIONS_ENABLED. Test: runtest --path frameworks/base/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsProviderTest.java BUG: 32913919 Change-Id: Ibea34f0a17539e9c583898dc336f807f92b33c54
This commit is contained in:
@@ -57,6 +57,7 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.UserManagerInternal;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
@@ -2175,7 +2176,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 135;
|
||||
private static final int SETTINGS_VERSION = 136;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -2553,6 +2554,30 @@ public class SettingsProvider extends ContentProvider {
|
||||
currentVersion = 135;
|
||||
}
|
||||
|
||||
if (currentVersion == 135) {
|
||||
// Version 135: Migrating the NETWORK_SCORER_APP setting to the
|
||||
// NETWORK_RECOMMENDATIONS_ENABLED setting.
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
final SettingsState globalSettings = getGlobalSettingsLocked();
|
||||
Setting currentSetting = globalSettings.getSettingLocked(
|
||||
Global.NETWORK_SCORER_APP);
|
||||
if (!currentSetting.isNull()) {
|
||||
// A scorer was set so enable recommendations.
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.NETWORK_RECOMMENDATIONS_ENABLED,
|
||||
"1",
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
|
||||
// and clear the scorer setting since it's no longer needed.
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.NETWORK_SCORER_APP,
|
||||
null,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
}
|
||||
currentVersion = 136;
|
||||
}
|
||||
|
||||
if (currentVersion != newVersion) {
|
||||
Slog.wtf("SettingsProvider", "warning: upgrading settings database to version "
|
||||
+ newVersion + " left it at "
|
||||
|
||||
Reference in New Issue
Block a user