diff options
author | Danesh M <danesh@cyngn.com> | 2016-05-11 18:59:00 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-05-13 13:35:13 -0700 |
commit | 68665286e88abdd369bbf48ac77fc2422f9f3b9b (patch) | |
tree | 297a50caeb6bcdec983b05bb12f9ff91157f5af8 /packages | |
parent | 61137013376ee0bd5ddcd07343f05ca044876485 (diff) | |
download | vendor_cmsdk-68665286e88abdd369bbf48ac77fc2422f9f3b9b.zip vendor_cmsdk-68665286e88abdd369bbf48ac77fc2422f9f3b9b.tar.gz vendor_cmsdk-68665286e88abdd369bbf48ac77fc2422f9f3b9b.tar.bz2 |
CMSettings : Move force_show_navbar to global
Keep feature inline with 12.1, only allow owner to
control the feature and mirror across users.
Also add additional checks for moved settings.
Change-Id: Ida11b71bc5ce9463628f8c5d76e59902d47d59bb
Diffstat (limited to 'packages')
-rw-r--r-- | packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMDatabaseHelper.java | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMDatabaseHelper.java b/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMDatabaseHelper.java index 5a1e50d..5a3bb9b 100644 --- a/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMDatabaseHelper.java +++ b/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMDatabaseHelper.java @@ -46,7 +46,7 @@ public class CMDatabaseHelper extends SQLiteOpenHelper{ private static final boolean LOCAL_LOGV = false; private static final String DATABASE_NAME = "cmsettings.db"; - private static final int DATABASE_VERSION = 5; + private static final int DATABASE_VERSION = 6; public static class CMTableNames { public static final String TABLE_SYSTEM = "system"; @@ -219,6 +219,16 @@ public class CMDatabaseHelper extends SQLiteOpenHelper{ upgradeVersion = 5; } + if (upgradeVersion < 6) { + // Move force_show_navbar to global + if (mUserHandle == UserHandle.USER_OWNER) { + moveSettingsToNewTable(db, CMTableNames.TABLE_SECURE, + CMTableNames.TABLE_GLOBAL, new String[] { + CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR + }, true); + } + upgradeVersion = 6; + } // *** Remember to update DATABASE_VERSION above! if (upgradeVersion < newVersion) { @@ -237,6 +247,40 @@ public class CMDatabaseHelper extends SQLiteOpenHelper{ } } + private void moveSettingsToNewTable(SQLiteDatabase db, + String sourceTable, String destTable, + String[] settingsToMove, boolean doIgnore) { + // Copy settings values from the source table to the dest, and remove from the source + SQLiteStatement insertStmt = null; + SQLiteStatement deleteStmt = null; + + db.beginTransaction(); + try { + insertStmt = db.compileStatement("INSERT " + + (doIgnore ? " OR IGNORE " : "") + + " INTO " + destTable + " (name,value) SELECT name,value FROM " + + sourceTable + " WHERE name=?"); + deleteStmt = db.compileStatement("DELETE FROM " + sourceTable + " WHERE name=?"); + + for (String setting : settingsToMove) { + insertStmt.bindString(1, setting); + insertStmt.execute(); + + deleteStmt.bindString(1, setting); + deleteStmt.execute(); + } + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + if (insertStmt != null) { + insertStmt.close(); + } + if (deleteStmt != null) { + deleteStmt.close(); + } + } + } + /** * Drops the table and index for the specified database and table name * @param db The {@link SQLiteDatabase} to drop the table and index in. |