Permalink
Browse files

Update VIBRATE_ON to a supported value when upgrading from GB.

Bug: 5738552

If value has ringer set to VIBRATE_OFF, we need to update it to the
now default, as VIBRATE_OFF is inconsistent with the new UI controls.

Make sure notification vibrate setting follows ringer vibrate setting.
Change-Id: I6638c8a8729d850e71db10d27a0b50d24dc11f19
  • Loading branch information...
Amith Yamasani
Amith Yamasani committed Dec 12, 2011
1 parent a5cbf02 commit 3066afdc6f729279b1dfd743bbdead73f889249f
Showing with 29 additions and 1 deletion.
  1. +29 −1 packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -63,7 +63,7 @@
// 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 void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
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 @@ private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) {
}
}
+ 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();

0 comments on commit 3066afd

Please sign in to comment.