in com/android/providers/settings/DatabaseHelper.java [245:1882]
public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
Log.w(TAG, "Upgrading settings database from version " + oldVersion + " to "
+ currentVersion);
int upgradeVersion = oldVersion;
// Pattern for upgrade blocks:
//
// if (upgradeVersion == [the DATABASE_VERSION you set] - 1) {
// .. your upgrade logic..
// upgradeVersion = [the DATABASE_VERSION you set]
// }
if (upgradeVersion == 20) {
/*
* Version 21 is part of the volume control refresh. There is no
* longer a UI-visible for setting notification vibrate on/off (in
* our design), but the functionality still exists. Force the
* notification vibrate to on.
*/
loadVibrateSetting(db, true);
upgradeVersion = 21;
}
if (upgradeVersion < 22) {
upgradeVersion = 22;
// Upgrade the lock gesture storage location and format
upgradeLockPatternLocation(db);
}
if (upgradeVersion < 23) {
db.execSQL("UPDATE favorites SET iconResource=0 WHERE iconType=0");
upgradeVersion = 23;
}
if (upgradeVersion == 23) {
db.beginTransaction();
try {
db.execSQL("ALTER TABLE favorites ADD spanX INTEGER");
db.execSQL("ALTER TABLE favorites ADD spanY INTEGER");
// Shortcuts, applications, folders
db.execSQL("UPDATE favorites SET spanX=1, spanY=1 WHERE itemType<=0");
// Photo frames, clocks
db.execSQL(
"UPDATE favorites SET spanX=2, spanY=2 WHERE itemType=1000 or itemType=1002");
// Search boxes
db.execSQL("UPDATE favorites SET spanX=4, spanY=1 WHERE itemType=1001");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 24;
}
if (upgradeVersion == 24) {
db.beginTransaction();
try {
// The value of the constants for preferring wifi or preferring mobile have been
// swapped, so reload the default.
db.execSQL("DELETE FROM system WHERE name='network_preference'");
db.execSQL("INSERT INTO system ('name', 'value') values ('network_preference', '" +
ConnectivityManager.DEFAULT_NETWORK_PREFERENCE + "')");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 25;
}
if (upgradeVersion == 25) {
db.beginTransaction();
try {
db.execSQL("ALTER TABLE favorites ADD uri TEXT");
db.execSQL("ALTER TABLE favorites ADD displayMode INTEGER");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 26;
}
if (upgradeVersion == 26) {
// This introduces the new secure settings table.
db.beginTransaction();
try {
createSecureTable(db);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 27;
}
if (upgradeVersion == 27) {
String[] settingsToMove = {
Settings.Secure.ADB_ENABLED,
Settings.Secure.ANDROID_ID,
Settings.Secure.BLUETOOTH_ON,
Settings.Secure.DATA_ROAMING,
Settings.Secure.DEVICE_PROVISIONED,
Settings.Secure.HTTP_PROXY,
Settings.Secure.INSTALL_NON_MARKET_APPS,
Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
Settings.Secure.LOGGING_ID,
Settings.Secure.NETWORK_PREFERENCE,
Settings.Secure.PARENTAL_CONTROL_ENABLED,
Settings.Secure.PARENTAL_CONTROL_LAST_UPDATE,
Settings.Secure.PARENTAL_CONTROL_REDIRECT_URL,
Settings.Secure.SETTINGS_CLASSNAME,
Settings.Secure.USB_MASS_STORAGE_ENABLED,
Settings.Secure.USE_GOOGLE_MAIL,
Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT,
Settings.Secure.WIFI_ON,
Settings.Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE,
Settings.Secure.WIFI_WATCHDOG_AP_COUNT,
Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS,
Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED,
Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS,
Settings.Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT,
Settings.Secure.WIFI_WATCHDOG_MAX_AP_CHECKS,
Settings.Secure.WIFI_WATCHDOG_ON,
Settings.Secure.WIFI_WATCHDOG_PING_COUNT,
Settings.Secure.WIFI_WATCHDOG_PING_DELAY_MS,
Settings.Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS,
};
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, settingsToMove, false);
upgradeVersion = 28;
}
if (upgradeVersion == 28 || upgradeVersion == 29) {
// Note: The upgrade to 28 was flawed since it didn't delete the old
// setting first before inserting. Combining 28 and 29 with the
// fixed version.
// This upgrade adds the STREAM_NOTIFICATION type to the list of
// types affected by ringer modes (silent, vibrate, etc.)
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'");
int newValue = (1 << AudioManager.STREAM_RING)
| (1 << AudioManager.STREAM_NOTIFICATION)
| (1 << AudioManager.STREAM_SYSTEM);
db.execSQL("INSERT INTO system ('name', 'value') values ('"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '"
+ String.valueOf(newValue) + "')");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 30;
}
if (upgradeVersion == 30) {
/*
* Upgrade 31 clears the title for all quick launch shortcuts so the
* activities' titles will be resolved at display time. Also, the
* folder is changed to '@quicklaunch'.
*/
db.beginTransaction();
try {
db.execSQL("UPDATE bookmarks SET folder = '@quicklaunch'");
db.execSQL("UPDATE bookmarks SET title = ''");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 31;
}
if (upgradeVersion == 31) {
/*
* Animations are now managed in preferences, and may be
* enabled or disabled based on product resources.
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.WINDOW_ANIMATION_SCALE + "'");
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.TRANSITION_ANIMATION_SCALE + "'");
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadDefaultAnimationSettings(stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 32;
}
if (upgradeVersion == 32) {
upgradeVersion = 33;
}
if (upgradeVersion == 33) {
// Set the default zoom controls to: tap-twice to bring up +/-
db.beginTransaction();
try {
db.execSQL("INSERT INTO system(name,value) values('zoom','2');");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 34;
}
if (upgradeVersion == 34) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
loadSecure35Settings(stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 35;
}
// due to a botched merge from donut to eclair, the initialization of ASSISTED_GPS_ENABLED
// was accidentally done out of order here.
// to fix this, ASSISTED_GPS_ENABLED is now initialized while upgrading from 38 to 39,
// and we intentionally do nothing from 35 to 36 now.
if (upgradeVersion == 35) {
upgradeVersion = 36;
}
if (upgradeVersion == 36) {
// This upgrade adds the STREAM_SYSTEM_ENFORCED type to the list of
// types affected by ringer modes (silent, vibrate, etc.)
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'");
int newValue = (1 << AudioManager.STREAM_RING)
| (1 << AudioManager.STREAM_NOTIFICATION)
| (1 << AudioManager.STREAM_SYSTEM)
| (1 << AudioManager.STREAM_SYSTEM_ENFORCED);
db.execSQL("INSERT INTO system ('name', 'value') values ('"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '"
+ String.valueOf(newValue) + "')");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 37;
}
if (upgradeVersion == 37) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
R.string.airplane_mode_toggleable_radios);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 38;
}
if (upgradeVersion == 38) {
db.beginTransaction();
try {
String value =
mContext.getResources().getBoolean(R.bool.assisted_gps_enabled) ? "1" : "0";
db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" +
Settings.Global.ASSISTED_GPS_ENABLED + "','" + value + "');");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 39;
}
if (upgradeVersion == 39) {
upgradeAutoBrightness(db);
upgradeVersion = 40;
}
if (upgradeVersion == 40) {
/*
* All animations are now turned on by default!
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.WINDOW_ANIMATION_SCALE + "'");
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.TRANSITION_ANIMATION_SCALE + "'");
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadDefaultAnimationSettings(stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 41;
}
if (upgradeVersion == 41) {
/*
* Initialize newly public haptic feedback setting
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.HAPTIC_FEEDBACK_ENABLED + "'");
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadDefaultHapticSettings(stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 42;
}
if (upgradeVersion == 42) {
/*
* Initialize new notification pulse setting
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
R.bool.def_notification_pulse);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 43;
}
if (upgradeVersion == 43) {
/*
* This upgrade stores bluetooth volume separately from voice volume
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt, Settings.System.VOLUME_BLUETOOTH_SCO,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO));
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 44;
}
if (upgradeVersion == 44) {
/*
* Gservices was moved into vendor/google.
*/
db.execSQL("DROP TABLE IF EXISTS gservices");
db.execSQL("DROP INDEX IF EXISTS gservicesIndex1");
upgradeVersion = 45;
}
if (upgradeVersion == 45) {
/*
* New settings for StorageManagerService
*/
db.beginTransaction();
try {
db.execSQL("INSERT INTO secure(name,value) values('" +
Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND + "','1');");
db.execSQL("INSERT INTO secure(name,value) values('" +
Settings.Secure.MOUNT_UMS_AUTOSTART + "','0');");
db.execSQL("INSERT INTO secure(name,value) values('" +
Settings.Secure.MOUNT_UMS_PROMPT + "','1');");
db.execSQL("INSERT INTO secure(name,value) values('" +
Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED + "','1');");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 46;
}
if (upgradeVersion == 46) {
/*
* The password mode constants have changed; reset back to no
* password.
*/
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='lockscreen.password_type';");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 47;
}
if (upgradeVersion == 47) {
/*
* The password mode constants have changed again; reset back to no
* password.
*/
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='lockscreen.password_type';");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 48;
}
if (upgradeVersion == 48) {
/*
* Default recognition service no longer initialized here,
* moved to RecognitionManagerService.
*/
upgradeVersion = 49;
}
if (upgradeVersion == 49) {
/*
* New settings for new user interface noises.
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadUISoundEffectsSettings(stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 50;
}
if (upgradeVersion == 50) {
/*
* Install location no longer initiated here.
*/
upgradeVersion = 51;
}
if (upgradeVersion == 51) {
/* Move the lockscreen related settings to Secure, including some private ones. */
String[] settingsToMove = {
Secure.LOCK_PATTERN_ENABLED,
Secure.LOCK_PATTERN_VISIBLE,
Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
"lockscreen.password_type",
"lockscreen.lockoutattemptdeadline",
"lockscreen.patterneverchosen",
"lock_pattern_autolock",
"lockscreen.lockedoutpermanently",
"lockscreen.password_salt"
};
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, settingsToMove, false);
upgradeVersion = 52;
}
if (upgradeVersion == 52) {
// new vibration/silent mode settings
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT,
R.bool.def_vibrate_in_silent);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 53;
}
if (upgradeVersion == 53) {
/*
* New settings for set install location UI no longer initiated here.
*/
upgradeVersion = 54;
}
if (upgradeVersion == 54) {
/*
* Update the screen timeout value if set to never
*/
db.beginTransaction();
try {
upgradeScreenTimeoutFromNever(db);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 55;
}
if (upgradeVersion == 55) {
/* Move the install location settings. */
String[] settingsToMove = {
Global.SET_INSTALL_LOCATION,
Global.DEFAULT_INSTALL_LOCATION
};
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, settingsToMove, false);
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt, Global.SET_INSTALL_LOCATION, 0);
loadSetting(stmt, Global.DEFAULT_INSTALL_LOCATION,
PackageHelper.APP_INSTALL_AUTO);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 56;
}
if (upgradeVersion == 56) {
/*
* Add Bluetooth to list of toggleable radios in airplane mode
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'");
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
R.string.airplane_mode_toggleable_radios);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 57;
}
/************* The following are Honeycomb changes ************/
if (upgradeVersion == 57) {
/*
* No longer initializing deleted setting ACCESSIBILITY_SCRIPT_INJECTION.
*/
upgradeVersion = 58;
}
if (upgradeVersion == 58) {
/* Add default for new Auto Time Zone */
int autoTimeValue = getIntValueFromSystem(db, Settings.System.AUTO_TIME, 0);
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO system(name,value)" + " VALUES(?,?);");
loadSetting(stmt, Settings.System.AUTO_TIME_ZONE,
autoTimeValue); // Sync timezone to NITZ if auto_time was enabled
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 59;
}
if (upgradeVersion == 59) {
// Persistence for the rotation lock feature.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.USER_ROTATION,
R.integer.def_user_rotation); // should be zero degrees
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 60;
}
if (upgradeVersion == 60) {
// Don't do this for upgrades from Gingerbread
// Were only required for intra-Honeycomb upgrades for testing
// upgradeScreenTimeout(db);
upgradeVersion = 61;
}
if (upgradeVersion == 61) {
// Don't do this for upgrades from Gingerbread
// Were only required for intra-Honeycomb upgrades for testing
// upgradeScreenTimeout(db);
upgradeVersion = 62;
}
// Change the default for screen auto-brightness mode
if (upgradeVersion == 62) {
// Don't do this for upgrades from Gingerbread
// Were only required for intra-Honeycomb upgrades for testing
// upgradeAutoBrightness(db);
upgradeVersion = 63;
}
if (upgradeVersion == 63) {
// This upgrade adds the STREAM_MUSIC type to the list of
// types affected by ringer modes (silent, vibrate, etc.)
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'");
int newValue = (1 << AudioManager.STREAM_RING)
| (1 << AudioManager.STREAM_NOTIFICATION)
| (1 << AudioManager.STREAM_SYSTEM)
| (1 << AudioManager.STREAM_SYSTEM_ENFORCED)
| (1 << AudioManager.STREAM_MUSIC);
db.execSQL("INSERT INTO system ('name', 'value') values ('"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '"
+ String.valueOf(newValue) + "')");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 64;
}
if (upgradeVersion == 64) {
// New setting to configure the long press timeout.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO secure(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, Settings.Secure.LONG_PRESS_TIMEOUT,
R.integer.def_long_press_timeout_millis);
stmt.close();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 65;
}
/************* The following are Ice Cream Sandwich changes ************/
if (upgradeVersion == 65) {
/*
* Animations are removed from Settings. Turned on by default
*/
db.beginTransaction();
SQLiteStatement stmt = null;
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.WINDOW_ANIMATION_SCALE + "'");
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.TRANSITION_ANIMATION_SCALE + "'");
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadDefaultAnimationSettings(stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 66;
}
if (upgradeVersion == 66) {
// This upgrade makes sure that MODE_RINGER_STREAMS_AFFECTED is set
// according to device voice capability
db.beginTransaction();
try {
int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) |
(1 << AudioManager.STREAM_NOTIFICATION) |
(1 << AudioManager.STREAM_SYSTEM) |
(1 << AudioManager.STREAM_SYSTEM_ENFORCED);
if (!mContext.getResources().getBoolean(
com.android.internal.R.bool.config_voice_capable)) {
ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
}
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'");
db.execSQL("INSERT INTO system ('name', 'value') values ('"
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '"
+ String.valueOf(ringerModeAffectedStreams) + "')");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 67;
}
if (upgradeVersion == 67) {
// New setting to enable touch exploration.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED,
R.bool.def_touch_exploration_enabled);
stmt.close();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 68;
}
if (upgradeVersion == 68) {
// Enable all system sounds by default
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "'");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 69;
}
if (upgradeVersion == 69) {
// Add RADIO_NFC to AIRPLANE_MODE_RADIO and AIRPLANE_MODE_TOGGLEABLE_RADIOS
String airplaneRadios = mContext.getResources().getString(
R.string.def_airplane_mode_radios);
String toggleableRadios = mContext.getResources().getString(
R.string.airplane_mode_toggleable_radios);
db.beginTransaction();
try {
db.execSQL("UPDATE system SET value='" + airplaneRadios + "' " +
"WHERE name='" + Settings.System.AIRPLANE_MODE_RADIOS + "'");
db.execSQL("UPDATE system SET value='" + toggleableRadios + "' " +
"WHERE name='" + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 70;
}
if (upgradeVersion == 70) {
// Update all built-in bookmarks. Some of the package names have changed.
loadBookmarks(db);
upgradeVersion = 71;
}
if (upgradeVersion == 71) {
// New setting to specify whether to speak passwords in accessibility mode.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD,
R.bool.def_accessibility_speak_password);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 72;
}
if (upgradeVersion == 72) {
// update vibration settings
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT,
R.bool.def_vibrate_in_silent);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 73;
}
if (upgradeVersion == 73) {
upgradeVibrateSettingFromNone(db);
upgradeVersion = 74;
}
if (upgradeVersion == 74) {
// No longer using URL from which WebView loads a JavaScript based screen-reader.
upgradeVersion = 75;
}
if (upgradeVersion == 75) {
db.beginTransaction();
SQLiteStatement stmt = null;
Cursor c = null;
try {
c = db.query(TABLE_SECURE, new String[] {"_id", "value"},
"name='lockscreen.disabled'",
null, null, null, null);
// only set default if it has not yet been set
if (c == null || c.getCount() == 0) {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.LOCKSCREEN_DISABLED,
R.bool.def_lockscreen_disabled);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (c != null) c.close();
if (stmt != null) stmt.close();
}
upgradeVersion = 76;
}
/************* The following are Jelly Bean changes ************/
if (upgradeVersion == 76) {
// Removed VIBRATE_IN_SILENT setting
db.beginTransaction();
try {
db.execSQL("DELETE FROM system WHERE name='"
+ Settings.System.VIBRATE_IN_SILENT + "'");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 77;
}
if (upgradeVersion == 77) {
// Introduce "vibrate when ringing" setting
loadVibrateWhenRingingSetting(db);
upgradeVersion = 78;
}
if (upgradeVersion == 78) {
// ACCESSIBILITY_SCREEN_READER_URL has been removed
upgradeVersion = 79;
}
if (upgradeVersion == 79) {
// Before touch exploration was a global setting controlled by the user
// via the UI. However, if the enabled accessibility services do not
// handle touch exploration mode, enabling it makes no sense. Therefore,
// now the services request touch exploration mode and the user is
// presented with a dialog to allow that and if she does we store that
// in the database. As a result of this change a user that has enabled
// accessibility, touch exploration, and some accessibility services
// may lose touch exploration state, thus rendering the device useless
// unless sighted help is provided, since the enabled service(s) are
// not in the list of services to which the user granted a permission
// to put the device in touch explore mode. Here we are allowing all
// enabled accessibility services to toggle touch exploration provided
// accessibility and touch exploration are enabled and no services can
// toggle touch exploration. Note that the user has already manually
// enabled the services and touch exploration which means the she has
// given consent to have these services work in touch exploration mode.
final boolean accessibilityEnabled = getIntValueFromTable(db, TABLE_SECURE,
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
final boolean touchExplorationEnabled = getIntValueFromTable(db, TABLE_SECURE,
Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1;
if (accessibilityEnabled && touchExplorationEnabled) {
String enabledServices = getStringValueFromTable(db, TABLE_SECURE,
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "");
String touchExplorationGrantedServices = getStringValueFromTable(db, TABLE_SECURE,
Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, "");
if (TextUtils.isEmpty(touchExplorationGrantedServices)
&& !TextUtils.isEmpty(enabledServices)) {
SQLiteStatement stmt = null;
try {
db.beginTransaction();
stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt,
Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
enabledServices);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
}
upgradeVersion = 80;
}
// vvv Jelly Bean MR1 changes begin here vvv
if (upgradeVersion == 80) {
// update screensaver settings
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ENABLED,
com.android.internal.R.bool.config_dreamsEnabledByDefault);
loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK,
com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault);
loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP,
com.android.internal.R.bool.config_dreamsActivatedOnSleepByDefault);
loadStringSetting(stmt, Settings.Secure.SCREENSAVER_COMPONENTS,
com.android.internal.R.string.config_dreamsDefaultComponent);
loadStringSetting(stmt, Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT,
com.android.internal.R.string.config_dreamsDefaultComponent);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 81;
}
if (upgradeVersion == 81) {
// Add package verification setting
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE,
R.bool.def_package_verifier_enable);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 82;
}
if (upgradeVersion == 82) {
// Move to per-user settings dbs
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
// Migrate now-global settings. Note that this happens before
// new users can be created.
createGlobalTable(db);
String[] settingsToMove = setToStringArray(
SettingsProvider.sSystemMovedToGlobalSettings);
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, false);
settingsToMove = setToStringArray(
SettingsProvider.sSecureMovedToGlobalSettings);
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, false);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 83;
}
if (upgradeVersion == 83) {
// 1. Setting whether screen magnification is enabled.
// 2. Setting for screen magnification scale.
// 3. Setting for screen magnification auto update.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO secure(name,value) VALUES(?,?);");
loadBooleanSetting(stmt,
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
R.bool.def_accessibility_display_magnification_enabled);
stmt.close();
stmt = db.compileStatement("INSERT INTO secure(name,value) VALUES(?,?);");
loadFractionSetting(stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
R.fraction.def_accessibility_display_magnification_scale, 1);
stmt.close();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 84;
}
if (upgradeVersion == 84) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
// Patch up the slightly-wrong key migration from 82 -> 83 for those
// devices that missed it, ignoring if the move is redundant
String[] settingsToMove = {
Settings.Secure.ADB_ENABLED,
Settings.Secure.BLUETOOTH_ON,
Settings.Secure.DATA_ROAMING,
Settings.Secure.DEVICE_PROVISIONED,
Settings.Secure.INSTALL_NON_MARKET_APPS,
Settings.Secure.USB_MASS_STORAGE_ENABLED
};
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 85;
}
if (upgradeVersion == 85) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
// Fix up the migration, ignoring already-migrated elements, to snap up to
// date with new changes to the set of global versus system/secure settings
String[] settingsToMove = { Settings.System.STAY_ON_WHILE_PLUGGED_IN };
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 86;
}
if (upgradeVersion == 86) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
String[] settingsToMove = {
Settings.Global.PACKAGE_VERIFIER_ENABLE,
Settings.Global.PACKAGE_VERIFIER_TIMEOUT,
Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE
};
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 87;
}
if (upgradeVersion == 87) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
String[] settingsToMove = {
Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS,
Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS,
Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS
};
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 88;
}
if (upgradeVersion == 88) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
String[] settingsToMove = {
Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD,
Settings.Global.BATTERY_DISCHARGE_THRESHOLD,
Settings.Global.SEND_ACTION_APP_ERROR,
Settings.Global.DROPBOX_AGE_SECONDS,
Settings.Global.DROPBOX_MAX_FILES,
Settings.Global.DROPBOX_QUOTA_KB,
Settings.Global.DROPBOX_QUOTA_PERCENT,
Settings.Global.DROPBOX_RESERVE_PERCENT,
Settings.Global.DROPBOX_TAG_PREFIX,
Settings.Global.ERROR_LOGCAT_PREFIX,
Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL,
Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD,
Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE,
Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES,
Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES,
Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS,
Settings.Global.CONNECTIVITY_CHANGE_DELAY,
Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED,
Settings.Global.CAPTIVE_PORTAL_SERVER,
Settings.Global.NSD_ON,
Settings.Global.SET_INSTALL_LOCATION,
Settings.Global.DEFAULT_INSTALL_LOCATION,
Settings.Global.INET_CONDITION_DEBOUNCE_UP_DELAY,
Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY,
Settings.Global.READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT,
Settings.Global.HTTP_PROXY,
Settings.Global.GLOBAL_HTTP_PROXY_HOST,
Settings.Global.GLOBAL_HTTP_PROXY_PORT,
Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST,
Settings.Global.SET_GLOBAL_HTTP_PROXY,
Settings.Global.DEFAULT_DNS_SERVER,
};
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 89;
}
if (upgradeVersion == 89) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
String[] prefixesToMove = {
Settings.Global.BLUETOOTH_HEADSET_PRIORITY_PREFIX,
Settings.Global.BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX,
Settings.Global.BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX,
};
movePrefixedSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, prefixesToMove);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 90;
}
if (upgradeVersion == 90) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
String[] systemToGlobal = {
Settings.Global.WINDOW_ANIMATION_SCALE,
Settings.Global.TRANSITION_ANIMATION_SCALE,
Settings.Global.ANIMATOR_DURATION_SCALE,
Settings.Global.FANCY_IME_ANIMATIONS,
Settings.Global.COMPATIBILITY_MODE,
Settings.Global.EMERGENCY_TONE,
Settings.Global.CALL_AUTO_RETRY,
Settings.Global.DEBUG_APP,
Settings.Global.WAIT_FOR_DEBUGGER,
Settings.Global.ALWAYS_FINISH_ACTIVITIES,
};
String[] secureToGlobal = {
Settings.Global.PREFERRED_NETWORK_MODE,
Settings.Global.CDMA_SUBSCRIPTION_MODE,
};
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, systemToGlobal, true);
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, secureToGlobal, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 91;
}
if (upgradeVersion == 91) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
// Move ringer mode from system to global settings
String[] settingsToMove = { Settings.Global.MODE_RINGER };
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 92;
}
if (upgradeVersion == 92) {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
if (mUserHandle == UserHandle.USER_SYSTEM) {
// consider existing primary users to have made it through user setup
// if the globally-scoped device-provisioned bit is set
// (indicating they already made it through setup as primary)
int deviceProvisioned = getIntValueFromTable(db, TABLE_GLOBAL,
Settings.Global.DEVICE_PROVISIONED, 0);
loadSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
deviceProvisioned);
} else {
// otherwise use the default
loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
R.bool.def_user_setup_complete);
}
} finally {
if (stmt != null) stmt.close();
}
upgradeVersion = 93;
}
if (upgradeVersion == 93) {
// Redo this step, since somehow it didn't work the first time for some users
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
// Migrate now-global settings
String[] settingsToMove = setToStringArray(
SettingsProvider.sSystemMovedToGlobalSettings);
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, true);
settingsToMove = setToStringArray(
SettingsProvider.sSecureMovedToGlobalSettings);
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 94;
}
if (upgradeVersion == 94) {
// Add wireless charging started sound setting
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
+ " VALUES(?,?);");
loadStringSetting(stmt, Settings.Global.CHARGING_STARTED_SOUND,
R.string.def_wireless_charging_started_sound);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 95;
}
if (upgradeVersion == 95) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
try {
String[] settingsToMove = { Settings.Global.BUGREPORT_IN_POWER_MENU };
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
upgradeVersion = 96;
}
if (upgradeVersion == 96) {
// NOP bump due to a reverted change that some people got on upgrade.
upgradeVersion = 97;
}
if (upgradeVersion == 97) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, Settings.Global.LOW_BATTERY_SOUND_TIMEOUT,
R.integer.def_low_battery_sound_timeout);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 98;
}
if (upgradeVersion == 98) {
// no-op; LOCK_SCREEN_SHOW_NOTIFICATIONS now handled in version 106
upgradeVersion = 99;
}
if (upgradeVersion == 99) {
// no-op; HEADS_UP_NOTIFICATIONS_ENABLED now handled in version 100
upgradeVersion = 100;
}
if (upgradeVersion == 100) {
// note: LOCK_SCREEN_SHOW_NOTIFICATIONS now handled in version 106
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED,
R.integer.def_heads_up_enabled);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 101;
}
if (upgradeVersion == 101) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName());
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 102;
}
if (upgradeVersion == 102) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
// The INSTALL_NON_MARKET_APPS setting is becoming per-user rather
// than device-global.
if (mUserHandle == UserHandle.USER_SYSTEM) {
// In the owner user, the global table exists so we can migrate the
// entry from there to the secure table, preserving its value.
String[] globalToSecure = {
Settings.Secure.INSTALL_NON_MARKET_APPS
};
moveSettingsToNewTable(db, TABLE_GLOBAL, TABLE_SECURE, globalToSecure, true);
} else {
// Secondary users' dbs don't have the global table, so institute the
// default.
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
R.bool.def_install_non_market_apps);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 103;
}
if (upgradeVersion == 103) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.Secure.WAKE_GESTURE_ENABLED,
R.bool.def_wake_gesture_enabled);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 104;
}
if (upgradeVersion < 105) {
// No-op: GUEST_USER_ENABLED setting was removed
upgradeVersion = 105;
}
if (upgradeVersion < 106) {
// LOCK_SCREEN_SHOW_NOTIFICATIONS is now per-user.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
R.integer.def_lock_screen_show_notifications);
if (mUserHandle == UserHandle.USER_SYSTEM) {
final int oldShow = getIntValueFromTable(db,
TABLE_GLOBAL, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, -1);
if (oldShow >= 0) {
// overwrite the default with whatever you had
loadSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, oldShow);
final SQLiteStatement deleteStmt
= db.compileStatement("DELETE FROM global WHERE name=?");
deleteStmt.bindString(1, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS);
deleteStmt.execute();
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 106;
}
if (upgradeVersion < 107) {
// Add trusted sound setting
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
+ " VALUES(?,?);");
loadStringSetting(stmt, Settings.Global.TRUSTED_SOUND,
R.string.def_trusted_sound);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 107;
}
if (upgradeVersion < 108) {
// Reset the auto-brightness setting to default since the behavior
// of the feature is now quite different and is being presented to
// the user in a new way as "adaptive brightness".
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE,
R.bool.def_screen_brightness_automatic_mode);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 108;
}
if (upgradeVersion < 109) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
R.bool.def_lock_screen_allow_private_notifications);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 109;
}
if (upgradeVersion < 110) {
// The SIP_CALL_OPTIONS value SIP_ASK_EACH_TIME is being deprecated.
// If the SIP_CALL_OPTIONS setting is set to SIP_ASK_EACH_TIME, default to
// SIP_ADDRESS_ONLY.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("UPDATE system SET value = ? " +
"WHERE name = ? AND value = ?;");
stmt.bindString(1, Settings.System.SIP_ADDRESS_ONLY);
stmt.bindString(2, Settings.System.SIP_CALL_OPTIONS);
stmt.bindString(3, Settings.System.SIP_ASK_ME_EACH_TIME);
stmt.execute();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 110;
}
if (upgradeVersion < 111) {
// reset ringer mode, so it doesn't force zen mode to follow
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt, Settings.Global.MODE_RINGER, AudioManager.RINGER_MODE_NORMAL);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 111;
}
if (upgradeVersion < 112) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
// When device name was added, we went with Manufacturer + Model, device name should
// actually be Model only.
// Update device name to Model if it wasn't modified by user.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("UPDATE global SET value = ? "
+ " WHERE name = ? AND value = ?");
stmt.bindString(1, getDefaultDeviceName()); // new default device name
stmt.bindString(2, Settings.Global.DEVICE_NAME);
stmt.bindString(3, getOldDefaultDeviceName()); // old default device name
stmt.execute();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 112;
}
if (upgradeVersion < 113) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT,
R.integer.def_sleep_timeout);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 113;
}
// We skipped 114 to handle a merge conflict with the introduction of theater mode.
if (upgradeVersion < 115) {
if (mUserHandle == UserHandle.USER_SYSTEM) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Global.THEATER_MODE_ON,
R.bool.def_theater_mode_on);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
}
upgradeVersion = 115;
}
if (upgradeVersion < 116) {
/*
* To control the default value by carrier config manager, initializing
* ENHANCED_4G_MODE_ENABLED has been removed.
*/
upgradeVersion = 116;
}
if (upgradeVersion < 117) {
db.beginTransaction();
try {
String[] systemToSecure = {
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED
};
moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, systemToSecure, true);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeVersion = 117;
}
if (upgradeVersion < 118) {
// Reset rotation-lock-for-accessibility on upgrade, since it now hides the display
// setting.
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
+ " VALUES(?,?);");
loadSetting(stmt, Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 118;
}
/*
* IMPORTANT: Do not add any more upgrade steps here as the global,
* secure, and system settings are no longer stored in a database
* but are kept in memory and persisted to XML.
*
* See: SettingsProvider.UpgradeController#onUpgradeLocked
*/
if (upgradeVersion != currentVersion) {
recreateDatabase(db, oldVersion, upgradeVersion, currentVersion);
}
}