Update default for auto-brightness.

Bug: 3297046
Change-Id: I92e34a85332988bb3faa1e1997ccc85abf4b5dec
This commit is contained in:
Amith Yamasani
2011-01-07 11:32:30 -08:00
parent 808751fe7a
commit f50c5113d0

View File

@ -61,7 +61,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 = 62;
private static final int DATABASE_VERSION = 63;
private Context mContext;
@ -441,18 +441,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
if (upgradeVersion == 39) {
db.beginTransaction();
try {
String value =
mContext.getResources().getBoolean(
R.bool.def_screen_brightness_automatic_mode) ? "1" : "0";
db.execSQL("INSERT OR IGNORE INTO system(name,value) values('" +
Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
upgradeAutoBrightness(db);
upgradeVersion = 40;
}
@ -802,6 +791,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 62;
}
// Change the default for screen auto-brightness mode
if (upgradeVersion == 62) {
upgradeAutoBrightness(db);
upgradeVersion = 63;
}
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != currentVersion) {
@ -924,6 +919,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
}
private void upgradeAutoBrightness(SQLiteDatabase db) {
db.beginTransaction();
try {
String value =
mContext.getResources().getBoolean(
R.bool.def_screen_brightness_automatic_mode) ? "1" : "0";
db.execSQL("INSERT OR REPLACE INTO system(name,value) values('" +
Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
/**
* Loads the default set of bookmarked shortcuts from an xml file.
*