Move Voicemail notification settings into util.
This utility localizes related functions/constants in a class,
in preparation for adding more functionality to make both
voicemail ringtone and vibration settings MSIM-capable, and also
handle associated necessary migrations.
Besides fixing voicemail notifications (before it did not update when
the value is changed), there should be no change in functionality.
+ Add utility for settings related to voicemail notifications.
+ Handle get/set ringtone uri in new util.
+ Handle get/set vibrate in new util.
+ Make keys for shared preferences independent of preference names.
There was an implicit relationship between these before. I think
it is safer if the two are not correlated, and the shared preferences
key needs to be changed shortly to consider subscription id anyways.
+ Handle saving ringtone uri in VoicemailRingtonePreference. For now
this has no change in behavior, but in a subsequent CL we will save
the ringtone by subscription id here.
- Don't use default values on VoicemailRingtonePreference; default
values use the preference's key as the shared preference key, but we
will need to use subscription ids for our keys.
Bug: 18232725
Change-Id: Ifb52f47073418c76ad4bcf86c57c0ed75d05d0ca
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index e06684c..77daabb 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -42,6 +42,7 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.TelephonyCapabilities;
+import com.android.phone.settings.VoicemailNotificationSettingsUtil;
import java.util.List;
@@ -313,16 +314,7 @@
Intent intent = new Intent(Intent.ACTION_CALL,
Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null));
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
- Uri ringtoneUri;
- String uriString = prefs.getString(
- CallFeaturesSetting.BUTTON_VOICEMAIL_NOTIFICATION_RINGTONE_KEY, null);
- if (!TextUtils.isEmpty(uriString)) {
- ringtoneUri = Uri.parse(uriString);
- } else {
- ringtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI;
- }
+ Uri ringtoneUri = VoicemailNotificationSettingsUtil.getRingtoneUri(mContext);
Notification.Builder builder = new Notification.Builder(mContext);
builder.setSmallIcon(resId)
@@ -334,10 +326,7 @@
.setColor(mContext.getResources().getColor(R.color.dialer_theme_color))
.setOngoing(true);
- CallFeaturesSetting.migrateVoicemailVibrationSettingsIfNeeded(prefs);
- final boolean vibrate = prefs.getBoolean(
- CallFeaturesSetting.BUTTON_VOICEMAIL_NOTIFICATION_VIBRATE_KEY, false);
- if (vibrate) {
+ if (VoicemailNotificationSettingsUtil.isVibrationEnabled(mContext)) {
builder.setDefaults(Notification.DEFAULT_VIBRATE);
}