From c05f58c6fd8a2d740a53034629b8a6af6d4e1b53 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Tue, 12 Apr 2016 12:20:43 -0700 Subject: Call correct number from missing call notification. Change-Id: I9daa0fd75fdeb201f5d7973a1431579ec7251bf7 Fix: 28068914 --- .../android/dialer/calllog/MissedCallNotifier.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/com') diff --git a/src/com/android/dialer/calllog/MissedCallNotifier.java b/src/com/android/dialer/calllog/MissedCallNotifier.java index 98d02d095..3afc112b2 100644 --- a/src/com/android/dialer/calllog/MissedCallNotifier.java +++ b/src/com/android/dialer/calllog/MissedCallNotifier.java @@ -96,6 +96,7 @@ public class MissedCallNotifier { boolean useCallLog = newCalls != null && newCalls.size() == count; NewCall newestCall = useCallLog ? newCalls.get(0) : null; long timeMs = useCallLog ? newestCall.dateMs : System.currentTimeMillis(); + String missedNumber = useCallLog ? newestCall.number : number; Notification.Builder builder = new Notification.Builder(mContext); // Display the first line of the notification: @@ -104,7 +105,7 @@ public class MissedCallNotifier { if (count == 1) { //TODO: look up caller ID that is not in contacts. ContactInfo contactInfo = CallLogNotificationsHelper.getInstance(mContext) - .getContactInfo(useCallLog ? newestCall.number : number, + .getContactInfo(missedNumber, useCallLog ? newestCall.numberPresentation : Calls.PRESENTATION_ALLOWED, useCallLog ? newestCall.countryIso : null); @@ -156,17 +157,17 @@ public class MissedCallNotifier { // Add additional actions when there is only 1 missed call and the user isn't locked if (UserManagerCompat.isUserUnlocked(mContext) && count == 1) { - if (!TextUtils.isEmpty(number) + if (!TextUtils.isEmpty(missedNumber) && !TextUtils.equals( - number, mContext.getString(R.string.handle_restricted))) { + missedNumber, mContext.getString(R.string.handle_restricted))) { builder.addAction(R.drawable.ic_phone_24dp, mContext.getString(R.string.notification_missedCall_call_back), - createCallBackPendingIntent(number)); + createCallBackPendingIntent(missedNumber)); - if (!PhoneNumberHelper.isUriNumber(number)) { + if (!PhoneNumberHelper.isUriNumber(missedNumber)) { builder.addAction(R.drawable.ic_message_24dp, mContext.getString(R.string.notification_missedCall_message), - createSendSmsFromNotificationPendingIntent(number)); + createSendSmsFromNotificationPendingIntent(missedNumber)); } } } @@ -254,7 +255,8 @@ public class MissedCallNotifier { intent.setAction( CallLogNotificationsService.ACTION_CALL_BACK_FROM_MISSED_CALL_NOTIFICATION); intent.putExtra(CallLogNotificationsService.EXTRA_MISSED_CALL_NUMBER, number); - return PendingIntent.getService(mContext, 0, intent, 0); + // Use FLAG_ONE_SHOT to avoid reusing previous PendingIntent with different number. + return PendingIntent.getService(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); } private PendingIntent createSendSmsFromNotificationPendingIntent(String number) { @@ -262,7 +264,8 @@ public class MissedCallNotifier { intent.setAction( CallLogNotificationsService.ACTION_SEND_SMS_FROM_MISSED_CALL_NOTIFICATION); intent.putExtra(CallLogNotificationsService.EXTRA_MISSED_CALL_NUMBER, number); - return PendingIntent.getService(mContext, 0, intent, 0); + // Use FLAG_ONE_SHOT to avoid reusing previous PendingIntent with different number. + return PendingIntent.getService(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); } /** -- cgit v1.2.3