summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2016-01-14 00:39:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-01-14 00:39:34 +0000
commit5a2e66ce9aa28b0f2d942f5c9dd772690c0fd5da (patch)
tree95c31967710733809348f4b1195e1dc668642cb3 /src
parent45a66c09a96e76fe6b0ecec3390bf0cb88a9dfe1 (diff)
parent5cfa2c31a9877563a383c3c6ee10790af9db61d0 (diff)
Merge "Use telephony voicemail notification settings for vvm." into ub-contactsdialer-b-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/DefaultVoicemailNotifier.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
index 2b894a12d..13ec0292a 100644
--- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
+++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Maps;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
@@ -33,7 +34,9 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.PhoneLookup;
+import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -194,13 +197,24 @@ public class DefaultVoicemailNotifier {
// TODO: Use the photo of contact if all calls are from the same person.
final int icon = android.R.drawable.stat_notify_voicemail;
+ Uri ringtoneUri = null;
+ boolean shouldVibrate = callToNotify != null;
+ if (callToNotify != null) {
+ PhoneAccountHandle accountHandle = new PhoneAccountHandle(
+ ComponentName.unflattenFromString(callToNotify.accountComponentName),
+ callToNotify.accountId);
+ ringtoneUri = getTelephonyManager().getVoicemailRingtoneUri(accountHandle);
+ shouldVibrate = getTelephonyManager().isVoicemailVibrationEnabled(accountHandle);
+ }
+
Notification.Builder notificationBuilder = new Notification.Builder(mContext)
.setSmallIcon(icon)
.setContentTitle(title)
.setContentText(callers)
.setStyle(new Notification.BigTextStyle().bigText(transcription))
+ .setSound(ringtoneUri)
.setColor(resources.getColor(R.color.dialer_theme_color))
- .setDefaults(callToNotify != null ? Notification.DEFAULT_ALL : 0)
+ .setDefaults(shouldVibrate ? Notification.DEFAULT_VIBRATE : 0)
.setDeleteIntent(createMarkNewVoicemailsAsOldIntent())
.setAutoCancel(true);
@@ -224,6 +238,10 @@ public class DefaultVoicemailNotifier {
mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, notificationBuilder.build());
}
+ private TelephonyManager getTelephonyManager() {
+ return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ }
+
/** Creates a pending intent that marks all new voicemails as old. */
private PendingIntent createMarkNewVoicemailsAsOldIntent() {
Intent intent = new Intent(mContext, CallLogNotificationsService.class);