Skip to content

Commit 3066afd

Browse files
author
Amith Yamasani
committed
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
1 parent a5cbf02 commit 3066afd

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)