diff options
author | Jeff Brown <jeffbrown@google.com> | 2015-04-02 23:12:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-02 23:12:51 +0000 |
commit | fd93eaf278ad2f58bb23d3141da1342f872c473c (patch) | |
tree | 2cd505c33e9b54d78c4cf62a927ca8b0e157809e /packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | |
parent | 9764b40898f9fe9b942110f90c13133903c6e468 (diff) | |
parent | 503cffc18121cdbb7d969b3a4de3168f13c75459 (diff) | |
download | frameworks_base-fd93eaf278ad2f58bb23d3141da1342f872c473c.zip frameworks_base-fd93eaf278ad2f58bb23d3141da1342f872c473c.tar.gz frameworks_base-fd93eaf278ad2f58bb23d3141da1342f872c473c.tar.bz2 |
Merge "Clarify settings update code."
Diffstat (limited to 'packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 8328d11..126b4aa 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -1859,40 +1859,43 @@ public class SettingsProvider extends ContentProvider { return getSettingsLocked(SETTINGS_TYPE_SYSTEM, userId); } + /** + * You must perform all necessary mutations to bring the settings + * for this user from the old to the new version. When you add a new + * upgrade step you *must* update SETTINGS_VERSION. + * + * This is an example of moving a setting from secure to global. + * + * // v119: Example settings changes. + * if (currentVersion == 118) { + * if (userId == UserHandle.USER_OWNER) { + * // Remove from the secure settings. + * SettingsState secureSettings = getSecureSettingsLocked(userId); + * String name = "example_setting_to_move"; + * String value = secureSettings.getSetting(name); + * secureSettings.deleteSetting(name); + * + * // Add to the global settings. + * SettingsState globalSettings = getGlobalSettingsLocked(); + * globalSettings.insertSetting(name, value, SettingsState.SYSTEM_PACKAGE_NAME); + * } + * + * // Update the current version. + * currentVersion = 119; + * } + */ private int onUpgradeLocked(int userId, int oldVersion, int newVersion) { if (DEBUG) { Slog.w(LOG_TAG, "Upgrading settings for user: " + userId + " from version: " + oldVersion + " to version: " + newVersion); } - // You must perform all necessary mutations to bring the settings - // for this user from the old to the new version. When you add a new - // upgrade step you *must* update SETTINGS_VERSION. - - /** - * This is an example of moving a setting from secure to global. - * - * int currentVersion = oldVersion; - * if (currentVersion == 118) { - * // Remove from the secure settings. - * SettingsState secureSettings = getSecureSettingsLocked(userId); - * String name = "example_setting_to_move"; - * String value = secureSettings.getSetting(name); - * secureSettings.deleteSetting(name); - * - * // Add to the global settings. - * SettingsState globalSettings = getGlobalSettingsLocked(); - * globalSettings.insertSetting(name, value, SettingsState.SYSTEM_PACKAGE_NAME); - * - * // Update the current version. - * currentVersion = 119; - * } - * - * // Return the current version. - * return currentVersion; - */ - - return SettingsState.VERSION_UNDEFINED; + int currentVersion = oldVersion; + + // vXXX: Add new settings above this point. + + // Return the current version. + return currentVersion; } } } |