CMSettings: Fix upgrade from cm-12.1 after weather changes

* Only the owner can write to the global db

Change-Id: Iec7736c28ff0bc7a35dae8bbc85ca2b1c137da49
This commit is contained in:
Michael Bestas 2016-05-08 01:14:37 +03:00
parent b77b8b5a70
commit 4a0ad7cfbb

View File

@ -202,17 +202,19 @@ public class CMDatabaseHelper extends SQLiteOpenHelper{
}
if (upgradeVersion < 5) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO global(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, CMSettings.Global.WEATHER_TEMPERATURE_UNIT,
R.integer.def_temperature_unit);
db.setTransactionSuccessful();
} finally {
if (stmt != null) stmt.close();
db.endTransaction();
if (mUserHandle == UserHandle.USER_OWNER) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT INTO global(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, CMSettings.Global.WEATHER_TEMPERATURE_UNIT,
R.integer.def_temperature_unit);
db.setTransactionSuccessful();
} finally {
if (stmt != null) stmt.close();
db.endTransaction();
}
}
upgradeVersion = 5;
}