Skip to content

Commit aefc0ed

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Don't upgrade some settings from GB to ICS." into ics-mr1
2 parents 3a7e2c0 + 5cd1500 commit aefc0ed

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

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

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
723723
upgradeVersion = 57;
724724
}
725725

726+
/************* The following are Honeycomb changes ************/
727+
726728
if (upgradeVersion == 57) {
727729
/*
728730
* New settings to:
@@ -751,13 +753,13 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
751753

752754
if (upgradeVersion == 58) {
753755
/* Add default for new Auto Time Zone */
756+
int autoTimeValue = getIntValueFromSystem(db, Settings.System.AUTO_TIME, 0);
754757
db.beginTransaction();
755758
SQLiteStatement stmt = null;
756759
try {
757-
stmt = db.compileStatement("INSERT INTO secure(name,value)"
758-
+ " VALUES(?,?);");
759-
loadBooleanSetting(stmt, Settings.System.AUTO_TIME_ZONE,
760-
R.bool.def_auto_time_zone); // Sync timezone to NITZ
760+
stmt = db.compileStatement("INSERT INTO system(name,value)" + " VALUES(?,?);");
761+
loadSetting(stmt, Settings.System.AUTO_TIME_ZONE,
762+
autoTimeValue); // Sync timezone to NITZ if auto_time was enabled
761763
db.setTransactionSuccessful();
762764
} finally {
763765
db.endTransaction();
@@ -784,18 +786,24 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
784786
}
785787

786788
if (upgradeVersion == 60) {
787-
upgradeScreenTimeout(db);
789+
// Don't do this for upgrades from Gingerbread
790+
// Were only required for intra-Honeycomb upgrades for testing
791+
// upgradeScreenTimeout(db);
788792
upgradeVersion = 61;
789793
}
790794

791795
if (upgradeVersion == 61) {
792-
upgradeScreenTimeout(db);
796+
// Don't do this for upgrades from Gingerbread
797+
// Were only required for intra-Honeycomb upgrades for testing
798+
// upgradeScreenTimeout(db);
793799
upgradeVersion = 62;
794800
}
795801

796802
// Change the default for screen auto-brightness mode
797803
if (upgradeVersion == 62) {
798-
upgradeAutoBrightness(db);
804+
// Don't do this for upgrades from Gingerbread
805+
// Were only required for intra-Honeycomb upgrades for testing
806+
// upgradeAutoBrightness(db);
799807
upgradeVersion = 63;
800808
}
801809

@@ -839,6 +847,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
839847
upgradeVersion = 65;
840848
}
841849

850+
/************* The following are Ice Cream Sandwich changes ************/
851+
842852
if (upgradeVersion == 65) {
843853
/*
844854
* Animations are removed from Settings. Turned on by default
@@ -1232,12 +1242,13 @@ private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) {
12321242
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
12331243
+ " VALUES(?,?);");
12341244

1235-
// Vibrate off by default for ringer, on for notification
1245+
// Vibrate on by default for ringer, on for notification
12361246
int vibrate = 0;
12371247
vibrate = AudioService.getValueForVibrateSetting(vibrate,
1238-
AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ON);
1248+
AudioManager.VIBRATE_TYPE_NOTIFICATION,
1249+
AudioManager.VIBRATE_SETTING_ONLY_SILENT);
12391250
vibrate |= AudioService.getValueForVibrateSetting(vibrate,
1240-
AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
1251+
AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT);
12411252
loadSetting(stmt, Settings.System.VIBRATE_ON, vibrate);
12421253
} finally {
12431254
if (stmt != null) stmt.close();
@@ -1509,4 +1520,20 @@ private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, in
15091520
loadSetting(stmt, key,
15101521
Float.toString(mContext.getResources().getFraction(resid, base, base)));
15111522
}
1523+
1524+
private int getIntValueFromSystem(SQLiteDatabase db, String name, int defaultValue) {
1525+
int value = defaultValue;
1526+
Cursor c = null;
1527+
try {
1528+
c = db.query("system", new String[] { Settings.System.VALUE }, "name='" + name + "'",
1529+
null, null, null, null);
1530+
if (c != null && c.moveToFirst()) {
1531+
String val = c.getString(0);
1532+
value = val == null ? defaultValue : Integer.parseInt(val);
1533+
}
1534+
} finally {
1535+
if (c != null) c.close();
1536+
}
1537+
return value;
1538+
}
15121539
}

0 commit comments

Comments
 (0)