am 840201d6: Merge "Update VIBRATE_ON to a supported value when upgrading from GB." into ics-mr1
* commit '840201d6e2d7d53e42a31ffeb2ef454982882d12': Update VIBRATE_ON to a supported value when upgrading from GB.
This commit is contained in:
@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
|
||||
// is properly propagated through your change. Not doing so will result in a loss of user
|
||||
// settings.
|
||||
private static final int DATABASE_VERSION = 73;
|
||||
private static final int DATABASE_VERSION = 74;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@@ -986,6 +986,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
upgradeVersion = 73;
|
||||
}
|
||||
|
||||
if (upgradeVersion == 73) {
|
||||
// update vibration settings
|
||||
upgradeVibrateSettingFromNone(db);
|
||||
upgradeVersion = 74;
|
||||
}
|
||||
|
||||
// *** Remember to update DATABASE_VERSION above!
|
||||
|
||||
if (upgradeVersion != currentVersion) {
|
||||
@@ -1091,6 +1097,28 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradeVibrateSettingFromNone(SQLiteDatabase db) {
|
||||
int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON, 0);
|
||||
// If the ringer vibrate value is invalid, set it to the default
|
||||
if ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_OFF) {
|
||||
vibrateSetting = AudioService.getValueForVibrateSetting(0,
|
||||
AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT);
|
||||
}
|
||||
// Apply the same setting to the notification vibrate value
|
||||
vibrateSetting = AudioService.getValueForVibrateSetting(vibrateSetting,
|
||||
AudioManager.VIBRATE_TYPE_NOTIFICATION, vibrateSetting);
|
||||
|
||||
SQLiteStatement stmt = null;
|
||||
try {
|
||||
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
|
||||
+ " VALUES(?,?);");
|
||||
loadSetting(stmt, Settings.System.VIBRATE_ON, vibrateSetting);
|
||||
} finally {
|
||||
if (stmt != null)
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradeScreenTimeout(SQLiteDatabase db) {
|
||||
// Change screen timeout to current default
|
||||
db.beginTransaction();
|
||||
|
||||
Reference in New Issue
Block a user