summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormengsun <msun@codeaurora.org>2014-09-30 11:36:41 +0800
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:40:30 -0700
commit2a2371dd751e5d3eecf2fb0f583b36bbcaf04334 (patch)
tree2f13df3ff76e0d1d211df5e4658bce57116153df
parent4e9cdbb9317fef24e6fee5a52a9d70cbbc47cb7b (diff)
downloadandroid_packages_apps_PhoneCommon-2a2371dd751e5d3eecf2fb0f583b36bbcaf04334.tar.gz
android_packages_apps_PhoneCommon-2a2371dd751e5d3eecf2fb0f583b36bbcaf04334.tar.bz2
android_packages_apps_PhoneCommon-2a2371dd751e5d3eecf2fb0f583b36bbcaf04334.zip
PhoneCommon: Set ringtone for SIM2 using SUB ID.
Add support to set ring tone for SIM2. Change-Id: Ibeb26c16a90eb2273f5bf58826e47d2e9d939d6d
-rw-r--r--src/com/android/phone/common/util/SettingsUtil.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/com/android/phone/common/util/SettingsUtil.java b/src/com/android/phone/common/util/SettingsUtil.java
index 6a5bd1c..4ece9ec 100644
--- a/src/com/android/phone/common/util/SettingsUtil.java
+++ b/src/com/android/phone/common/util/SettingsUtil.java
@@ -116,4 +116,60 @@ public class SettingsUtil {
}
handler.sendMessage(handler.obtainMessage(msg, summary));
}
+
+ public static void updateRingtoneName(Context context, Handler handler,
+ int type, Preference preference, int msg, int phoneId) {
+ if (preference == null) {
+ return;
+ }
+
+ final Uri ringtoneUri;
+ boolean defaultRingtone = false;
+ if (type == RingtoneManager.TYPE_RINGTONE) {
+ // For ringtones, we can just lookup the system default because changing the settings
+ // in Call Settings changes the system default.
+ ringtoneUri = RingtoneManager.getActualRingtoneUriBySubId(context, phoneId);
+ } else {
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ // For voicemail notifications, we use the value saved in Phone's shared preferences.
+ String uriString = prefs.getString(preference.getKey(), null);
+ if (TextUtils.isEmpty(uriString)) {
+ // silent ringtone
+ ringtoneUri = null;
+ } else {
+ if (uriString.equals(Settings.System.DEFAULT_NOTIFICATION_URI.toString())) {
+ // If it turns out that the voicemail notification is set to the system
+ // default notification, we retrieve the actual URI to prevent it from showing
+ // up as "Unknown Ringtone".
+ defaultRingtone = true;
+ ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
+ } else {
+ ringtoneUri = Uri.parse(uriString);
+ }
+ }
+ }
+ CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown);
+ // Is it a silent ringtone?
+ if (ringtoneUri == null) {
+ summary = context.getString(com.android.internal.R.string.ringtone_silent);
+ } else {
+ // Fetch the ringtone title from the media provider
+ try {
+ Cursor cursor = context.getContentResolver().query(ringtoneUri,
+ new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ summary = cursor.getString(0);
+ }
+ cursor.close();
+ }
+ } catch (SQLiteException sqle) {
+ // Unknown title for the ringtone
+ }
+ }
+ if (defaultRingtone) {
+ summary = context.getString(R.string.default_notification_description, summary);
+ }
+ handler.sendMessage(handler.obtainMessage(msg, summary));
+ }
}