@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
6363 // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
6464 // is properly propagated through your change. Not doing so will result in a loss of user
6565 // settings.
66- private static final int DATABASE_VERSION = 73 ;
66+ private static final int DATABASE_VERSION = 74 ;
6767
6868 private Context mContext ;
6969
@@ -986,6 +986,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
986986 upgradeVersion = 73 ;
987987 }
988988
989+ if (upgradeVersion == 73 ) {
990+ // update vibration settings
991+ upgradeVibrateSettingFromNone (db );
992+ upgradeVersion = 74 ;
993+ }
994+
989995 // *** Remember to update DATABASE_VERSION above!
990996
991997 if (upgradeVersion != currentVersion ) {
@@ -1091,6 +1097,28 @@ private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) {
10911097 }
10921098 }
10931099
1100+ private void upgradeVibrateSettingFromNone (SQLiteDatabase db ) {
1101+ int vibrateSetting = getIntValueFromSystem (db , Settings .System .VIBRATE_ON , 0 );
1102+ // If the ringer vibrate value is invalid, set it to the default
1103+ if ((vibrateSetting & 3 ) == AudioManager .VIBRATE_SETTING_OFF ) {
1104+ vibrateSetting = AudioService .getValueForVibrateSetting (0 ,
1105+ AudioManager .VIBRATE_TYPE_RINGER , AudioManager .VIBRATE_SETTING_ONLY_SILENT );
1106+ }
1107+ // Apply the same setting to the notification vibrate value
1108+ vibrateSetting = AudioService .getValueForVibrateSetting (vibrateSetting ,
1109+ AudioManager .VIBRATE_TYPE_NOTIFICATION , vibrateSetting );
1110+
1111+ SQLiteStatement stmt = null ;
1112+ try {
1113+ stmt = db .compileStatement ("INSERT OR REPLACE INTO system(name,value)"
1114+ + " VALUES(?,?);" );
1115+ loadSetting (stmt , Settings .System .VIBRATE_ON , vibrateSetting );
1116+ } finally {
1117+ if (stmt != null )
1118+ stmt .close ();
1119+ }
1120+ }
1121+
10941122 private void upgradeScreenTimeout (SQLiteDatabase db ) {
10951123 // Change screen timeout to current default
10961124 db .beginTransaction ();
0 commit comments