From b6e6ffae3564f0c8935cd2d307ffa4d17c57f992 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Mon, 29 Mar 2010 17:58:53 -0700 Subject: Fix for Never not existing in latest timeout values. Bug: 2535288 Change-Id: I15ca60c7afe58fbe57e557e6d0028dc200d8b322 --- .../android/providers/settings/DatabaseHelper.java | 40 +++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'packages/SettingsProvider') diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 2ad663d..d0e9dd9 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -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 = 54; + private static final int DATABASE_VERSION = 55; private Context mContext; @@ -681,6 +681,21 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 54; } + if (upgradeVersion == 54) { + /* + * Update the screen timeout value if set to never + */ + db.beginTransaction(); + try { + upgradeScreenTimeoutFromNever(db); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + + upgradeVersion = 55; + } + // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { @@ -762,6 +777,29 @@ public class DatabaseHelper extends SQLiteOpenHelper { } } + private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) { + // See if the timeout is -1 (for "Never"). + Cursor c = db.query("system", new String[] { "_id", "value" }, "name=? AND value=?", + new String[] { Settings.System.SCREEN_OFF_TIMEOUT, "-1" }, + null, null, null); + + SQLiteStatement stmt = null; + if (c.getCount() > 0) { + c.close(); + try { + stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" + + " VALUES(?,?);"); + + // Set the timeout to 30 minutes in milliseconds + loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, 30 * 60 * 1000); + } finally { + if (stmt != null) stmt.close(); + } + } else { + c.close(); + } + } + /** * Loads the default set of bookmarked shortcuts from an xml file. * -- cgit v1.1