diff options
author | Jerome Poichet <jpoichet@google.com> | 2014-09-12 20:33:45 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-12 20:33:46 +0000 |
commit | 3d68c108542376ff077c25674ce892e6d854a6ed (patch) | |
tree | 64be7967442709e01e050ac16d6209055feb544f /packages/SettingsProvider | |
parent | 607bd848269fb802550e63aa61945790616f97a7 (diff) | |
parent | 550021ec5a2c8d741506c3fe5d1ee85139bc794a (diff) | |
download | frameworks_base-3d68c108542376ff077c25674ce892e6d854a6ed.zip frameworks_base-3d68c108542376ff077c25674ce892e6d854a6ed.tar.gz frameworks_base-3d68c108542376ff077c25674ce892e6d854a6ed.tar.bz2 |
Merge "Update default device name to MODEL only" into lmp-dev
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/res/values/defaults.xml | 7 | ||||
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 33 |
2 files changed, 35 insertions, 5 deletions
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index a3bed4f..625dc96 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -193,8 +193,11 @@ <!-- 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> + <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL--> + <string name="def_device_name">%1$s</string> + + <!-- Default for Settings.Global.DEVICE_NAME $1=MANUFACTURER $2=MODEL--> + <string name="def_device_name_old">%1$s %2$s</string> <!-- Default for Settings.Secure.WAKE_GESTURE_ENABLED --> <bool name="def_wake_gesture_enabled">true</bool> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 6d08970..bdb167f 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 = 111; + private static final int DATABASE_VERSION = 112; private Context mContext; private int mUserHandle; @@ -1788,6 +1788,29 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 111; } + if (upgradeVersion < 112) { + if (mUserHandle == UserHandle.USER_OWNER) { + // When device name was added, we went with Manufacturer + Model, device name should + // actually be Model only. + // Update device name to Model if it wasn't modified by user. + db.beginTransaction(); + SQLiteStatement stmt = null; + try { + stmt = db.compileStatement("UPDATE global SET value = ? " + + " WHERE name = ? AND value = ?"); + stmt.bindString(1, getDefaultDeviceName()); // new default device name + stmt.bindString(2, Settings.Global.DEVICE_NAME); + stmt.bindString(3, getOldDefaultDeviceName()); // old default device name + stmt.execute(); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + if (stmt != null) stmt.close(); + } + } + upgradeVersion = 112; + } + // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { @@ -2585,8 +2608,12 @@ public class DatabaseHelper extends SQLiteOpenHelper { return defaultValue; } + private String getOldDefaultDeviceName() { + return mContext.getResources().getString(R.string.def_device_name_old, + Build.MANUFACTURER, Build.MODEL); + } + private String getDefaultDeviceName() { - return mContext.getResources().getString(R.string.def_device_name, Build.MANUFACTURER, - Build.MODEL); + return mContext.getResources().getString(R.string.def_device_name, Build.MODEL); } } |