summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/provider/Settings.java58
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java60
2 files changed, 93 insertions, 25 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 8825f58..8f1210b 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3078,30 +3078,6 @@ public final class Settings {
public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
/**
- * Get the key that retrieves a bluetooth headset's priority.
- * @hide
- */
- public static final String getBluetoothHeadsetPriorityKey(String address) {
- return ("bluetooth_headset_priority_" + address.toUpperCase());
- }
-
- /**
- * Get the key that retrieves a bluetooth a2dp sink's priority.
- * @hide
- */
- public static final String getBluetoothA2dpSinkPriorityKey(String address) {
- return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase());
- }
-
- /**
- * Get the key that retrieves a bluetooth Input Device's priority.
- * @hide
- */
- public static final String getBluetoothInputDevicePriorityKey(String address) {
- return ("bluetooth_input_device_priority_" + address.toUpperCase());
- }
-
- /**
* @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
*/
@Deprecated
@@ -5160,6 +5136,40 @@ public final class Settings {
*/
public static final String DEFAULT_DNS_SERVER = "default_dns_server";
+ /** {@hide} */
+ public static final String
+ BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
+ /** {@hide} */
+ public static final String
+ BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
+ /** {@hide} */
+ public static final String
+ BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
+
+ /**
+ * Get the key that retrieves a bluetooth headset's priority.
+ * @hide
+ */
+ public static final String getBluetoothHeadsetPriorityKey(String address) {
+ return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase();
+ }
+
+ /**
+ * Get the key that retrieves a bluetooth a2dp sink's priority.
+ * @hide
+ */
+ public static final String getBluetoothA2dpSinkPriorityKey(String address) {
+ return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase();
+ }
+
+ /**
+ * Get the key that retrieves a bluetooth Input Device's priority.
+ * @hide
+ */
+ public static final String getBluetoothInputDevicePriorityKey(String address) {
+ return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase();
+ }
+
// Populated lazily, guarded by class object:
private static NameValueCache sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index c8ce3cd..06c8e11 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -68,7 +68,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 = 89;
+ private static final int DATABASE_VERSION = 90;
private Context mContext;
private int mUserHandle;
@@ -1380,6 +1380,26 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 89;
}
+ if (upgradeVersion == 89) {
+ if (mUserHandle == UserHandle.USER_OWNER) {
+ db.beginTransaction();
+ try {
+ String[] prefixesToMove = {
+ Settings.Global.BLUETOOTH_HEADSET_PRIORITY_PREFIX,
+ Settings.Global.BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX,
+ Settings.Global.BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX,
+ };
+
+ movePrefixedSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, prefixesToMove);
+
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ }
+ upgradeVersion = 90;
+ }
+
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != currentVersion) {
@@ -1446,6 +1466,44 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
}
+ /**
+ * Move any settings with the given prefixes from the source table to the
+ * destination table.
+ */
+ private void movePrefixedSettingsToNewTable(
+ SQLiteDatabase db, String sourceTable, String destTable, String[] prefixesToMove) {
+ SQLiteStatement insertStmt = null;
+ SQLiteStatement deleteStmt = null;
+
+ db.beginTransaction();
+ try {
+ insertStmt = db.compileStatement("INSERT INTO " + destTable
+ + " (name,value) SELECT name,value FROM " + sourceTable
+ + " WHERE substr(name,0,?)=?");
+ deleteStmt = db.compileStatement(
+ "DELETE FROM " + sourceTable + " WHERE substr(name,0,?)=?");
+
+ for (String prefix : prefixesToMove) {
+ insertStmt.bindLong(1, prefix.length() + 1);
+ insertStmt.bindString(2, prefix);
+ insertStmt.execute();
+
+ deleteStmt.bindLong(1, prefix.length() + 1);
+ deleteStmt.bindString(2, prefix);
+ deleteStmt.execute();
+ }
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ if (insertStmt != null) {
+ insertStmt.close();
+ }
+ if (deleteStmt != null) {
+ deleteStmt.close();
+ }
+ }
+ }
+
private void upgradeLockPatternLocation(SQLiteDatabase db) {
Cursor c = db.query(TABLE_SYSTEM, new String[] {"_id", "value"}, "name='lock_pattern'",
null, null, null, null);