summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Poichet <jpoichet@google.com>2014-05-12 18:13:27 -0700
committerJerome Poichet <jpoichet@google.com>2014-05-13 12:06:52 -0700
commit147b4d75e1d4ca795d45ffe51d83efd19a754cf2 (patch)
treed9a39dd8ef4b4c3ca407a7bb59b190c0d5e386b6
parent4cf7965767e102e6f5a20437c58cc56619da10ff (diff)
downloadframeworks_base-147b4d75e1d4ca795d45ffe51d83efd19a754cf2.zip
frameworks_base-147b4d75e1d4ca795d45ffe51d83efd19a754cf2.tar.gz
frameworks_base-147b4d75e1d4ca795d45ffe51d83efd19a754cf2.tar.bz2
Adding device name
A new global settings to name a device. This will centralize the notion of device name/nickname and should be used by Cast, Bluetooth, TV Remote and other advertising applications/services. Change-Id: I2294deb5c0d1002fb2fc158f62a2d5643d90d749
-rw-r--r--core/java/android/provider/Settings.java7
-rw-r--r--packages/SettingsProvider/res/values/defaults.xml3
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java27
3 files changed, 36 insertions, 1 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e1fd46e..3cf51b4 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6147,6 +6147,13 @@ public final class Settings {
/** @hide */ public static final int HEADS_UP_ON = 1;
/**
+ * The name of the device
+ *
+ * @hide
+ */
+ public static final String DEVICE_NAME = "device_name";
+
+ /**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
*
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 59b486f..bf97fc0 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -189,4 +189,7 @@
<!-- Default for Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, 1==on -->
<integer name="def_heads_up_enabled">1</integer>
+ <!-- Default for Settings.Global.DEVICE_NAME $1=BRAND $2=MODEL-->
+ <string name="def_device_name">%1$s %2$s</string>
+
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 58086c4..909c32e 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -31,6 +31,7 @@ import android.database.sqlite.SQLiteStatement;
import android.media.AudioManager;
import android.media.AudioService;
import android.net.ConnectivityManager;
+import android.os.Build;
import android.os.Environment;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -69,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 = 101;
+ private static final int DATABASE_VERSION = 102;
private Context mContext;
private int mUserHandle;
@@ -1614,6 +1615,23 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 101;
}
+ if (upgradeVersion == 101) {
+ if (mUserHandle == UserHandle.USER_OWNER) {
+ db.beginTransaction();
+ SQLiteStatement stmt = null;
+ try {
+ stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)"
+ + " VALUES(?,?);");
+ loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName());
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ if (stmt != null) stmt.close();
+ }
+ }
+ upgradeVersion = 102;
+ }
+
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != currentVersion) {
@@ -2342,6 +2360,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED,
R.integer.def_heads_up_enabled);
+ loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName());
+
// --- New global settings start here
} finally {
if (stmt != null) stmt.close();
@@ -2398,4 +2418,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
return defaultValue;
}
+
+ private String getDefaultDeviceName() {
+ return mContext.getResources().getString(R.string.def_device_name, Build.BRAND,
+ Build.MODEL);
+ }
}