diff options
author | Dan Sandler <dsandler@android.com> | 2014-07-22 23:14:54 -0400 |
---|---|---|
committer | Dan Sandler <dsandler@android.com> | 2014-08-06 18:00:53 +0000 |
commit | 52e5701eea2da526191e997f9df5c41ef1e1c938 (patch) | |
tree | 33a48d4653299f655eb4a867d4af3e01ff9ff1a1 /packages/SettingsProvider | |
parent | ea844f92a324ec08818d8dbd9f7ff1ec45e4a812 (diff) | |
download | frameworks_base-52e5701eea2da526191e997f9df5c41ef1e1c938.zip frameworks_base-52e5701eea2da526191e997f9df5c41ef1e1c938.tar.gz frameworks_base-52e5701eea2da526191e997f9df5c41ef1e1c938.tar.bz2 |
Move LOCK_SCREEN_SHOW_NOTIFICATIONS to per-user Settings.Secure.
Bug: 15331132
Change-Id: Ia80ccb2cfdf60116bd50601e60ff131619eafcc5
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/res/values/defaults.xml | 2 | ||||
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 75 |
2 files changed, 38 insertions, 39 deletions
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index a92ab7e..478a5de 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -183,7 +183,7 @@ <!-- Default for Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE --> <integer name="def_wifi_scan_always_available">0</integer> - <!-- Default for Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1==on --> + <!-- Default for Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1==on --> <integer name="def_lock_screen_show_notifications">1</integer> <!-- Default for Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, 1==on --> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 09e6a94..7c92cde 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -70,7 +70,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 = 105; + private static final int DATABASE_VERSION = 106; private Context mContext; private int mUserHandle; @@ -1558,54 +1558,25 @@ public class DatabaseHelper extends SQLiteOpenHelper { } if (upgradeVersion == 98) { - if (mUserHandle == UserHandle.USER_OWNER) { - db.beginTransaction(); - SQLiteStatement stmt = null; - try { - stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" - + " VALUES(?,?);"); - loadIntegerSetting(stmt, Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, - R.integer.def_lock_screen_show_notifications); - db.setTransactionSuccessful(); - } finally { - db.endTransaction(); - if (stmt != null) stmt.close(); - } - } + // no-op; LOCK_SCREEN_SHOW_NOTIFICATIONS now handled in version 106 upgradeVersion = 99; } if (upgradeVersion == 99) { - if (mUserHandle == UserHandle.USER_OWNER) { - db.beginTransaction(); - SQLiteStatement stmt = null; - try { - stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" - + " VALUES(?,?);"); - loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED, - R.integer.def_heads_up_enabled); - db.setTransactionSuccessful(); - } finally { - db.endTransaction(); - if (stmt != null) stmt.close(); - } - } + // no-op; HEADS_UP_NOTIFICATIONS_ENABLED now handled in version 100 upgradeVersion = 100; } + if (upgradeVersion == 100) { - // Catch devices that were initialized to version 100 and missed these in onCreate() + // note: LOCK_SCREEN_SHOW_NOTIFICATIONS now handled in version 106 if (mUserHandle == UserHandle.USER_OWNER) { db.beginTransaction(); SQLiteStatement stmt = null; try { - stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" + stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" + " VALUES(?,?);"); - loadIntegerSetting(stmt, Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, - R.integer.def_lock_screen_show_notifications); - loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED, R.integer.def_heads_up_enabled); - db.setTransactionSuccessful(); } finally { db.endTransaction(); @@ -1695,6 +1666,34 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 105; } + if (upgradeVersion < 106) { + // LOCK_SCREEN_SHOW_NOTIFICATIONS is now per-user. + db.beginTransaction(); + SQLiteStatement stmt = null; + try { + stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" + + " VALUES(?,?);"); + loadBooleanSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, + R.bool.def_guest_user_enabled); + if (mUserHandle == UserHandle.USER_OWNER) { + final int oldShow = getIntValueFromTable(db, + TABLE_GLOBAL, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, -1); + if (oldShow >= 0) { + // overwrite the default with whatever you had + loadSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, oldShow); + final SQLiteStatement deleteStmt + = db.compileStatement("DELETE FROM global WHERE name=?"); + deleteStmt.bindString(1, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS); + deleteStmt.execute(); + } + } + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + if (stmt != null) stmt.close(); + } + upgradeVersion = 106; + } // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { @@ -2260,6 +2259,9 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadBooleanSetting(stmt, Settings.Secure.WAKE_GESTURE_ENABLED, R.bool.def_wake_gesture_enabled); + loadIntegerSetting(stmt, Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, + R.integer.def_lock_screen_show_notifications); + } finally { if (stmt != null) stmt.close(); } @@ -2420,9 +2422,6 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadIntegerSetting(stmt, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, R.integer.def_wifi_scan_always_available); - loadIntegerSetting(stmt, Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, - R.integer.def_lock_screen_show_notifications); - loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED, R.integer.def_heads_up_enabled); |