From 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 4 May 2017 08:23:17 -0700 Subject: Update Dialer to V10 RC16 This release was created following the instructions at: go/dialer-aosp-release Subsequent dialer releases will follow as O bugs are fixed, until we reach our final RC. Version: 10 Candidate: RC16 Branch: dialer-android_release_branch/153304843.1 dialer-android/dialer-android_20170416.00/dialer-android_20170416.00_RC16 This release contains the following bug fixes since RC00: Bug: 37324705 35304403 36067503 35304446 33203808 37280992 37346084 35766990 37481880 37424493 36470282 37347691 37519015 37168472 35805360 37545472 27704934 36515614 35766990 37577470 34739750 35801628 36788693 35264204 36708536 37628370 36904650 37314436 37642171 37530847 37637799 37666625 37548549 37648036 37636412 37323529 37630507 35919141 37198343 37548572 36178218 37640315 37663896 37720467 37275944 37710497 31634477 37744796 37348506 37744796 37568534 37672424 34872683 34873026 37681461 34873295 37748373 37526812 37618638 37663896 37536088 37727455 37165687 36651204 36900708 37323529 36902926 37256480 37328353 37432034 37436952 34093562 37720889 37321935 37780300 37781115 37755902 36588206 34258266 37290464 37698062 37618638 37473004 37432034 37918676 37870494 37722091 Test: make, on device Change-Id: I99e1a484ccd578c1f8a13e7a6a4b4952f0791297 --- .../LegacyVoicemailNotificationReceiver.java | 53 +++++++++++++++------- .../app/voicemail/VoicemailPlaybackPresenter.java | 3 ++ 2 files changed, 39 insertions(+), 17 deletions(-) (limited to 'java/com/android/dialer/app/voicemail') diff --git a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java index 078a40a82..a7ef4f43a 100644 --- a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java +++ b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java @@ -22,14 +22,15 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Build.VERSION_CODES; +import android.preference.PreferenceManager; import android.support.v4.os.BuildCompat; -import android.telecom.PhoneAccount; +import android.support.v4.os.UserManagerCompat; import android.telecom.PhoneAccountHandle; -import android.telecom.TelecomManager; import android.telephony.TelephonyManager; import com.android.dialer.app.calllog.DefaultVoicemailNotifier; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.PerAccountSharedPreferences; import com.android.voicemail.VoicemailComponent; /** @@ -40,6 +41,8 @@ import com.android.voicemail.VoicemailComponent; @TargetApi(VERSION_CODES.O) public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { + private static final String LEGACY_VOICEMAIL_COUNT = "legacy_voicemail_count"; + @Override public void onReceive(Context context, Intent intent) { LogUtil.i( @@ -47,31 +50,47 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { Assert.checkArgument(BuildCompat.isAtLeastO()); PhoneAccountHandle phoneAccountHandle = - intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE); - if (phoneAccountHandle == null) { - // TODO: assert instead after API has landed. - phoneAccountHandle = - context - .getSystemService(TelecomManager.class) - .getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_VOICEMAIL); - } - if (VoicemailComponent.get(context) - .getVoicemailClient() - .isActivated(context, phoneAccountHandle)) { + Assert.isNotNull(intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE)); + + // Carrier might not send voicemail count. Missing extra means there are unknown numbers of + // voicemails (One or more). Treat it as 1 so the generic version will be shown. ("Voicemail" + // instead of "X voicemails") + int count = intent.getIntExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, 1); + + // Need credential encrypted storage to access preferences. + if (UserManagerCompat.isUserUnlocked(context)) { + PerAccountSharedPreferences preferences = + new PerAccountSharedPreferences( + context, phoneAccountHandle, PreferenceManager.getDefaultSharedPreferences(context)); + // Carriers may send multiple notifications for the same voicemail. + if (count != 0 && count == preferences.getInt(LEGACY_VOICEMAIL_COUNT, -1)) { + LogUtil.i( + "LegacyVoicemailNotificationReceiver.onReceive", + "voicemail count hasn't changed, ignoring"); + return; + } + preferences.edit().putInt(LEGACY_VOICEMAIL_COUNT, count).apply(); + } else { LogUtil.i( "LegacyVoicemailNotificationReceiver.onReceive", - "visual voicemail is activated, ignoring notification"); - return; + "User locked, bypassing voicemail count check"); } - // Missing extra means there are unknown numbers of voicemails. - int count = intent.getIntExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, 1); if (count == 0) { LogUtil.i("LegacyVoicemailNotificationReceiver.onReceive", "clearing notification"); DefaultVoicemailNotifier.getInstance(context).cancelLegacyNotification(); return; } + if (VoicemailComponent.get(context) + .getVoicemailClient() + .isActivated(context, phoneAccountHandle)) { + LogUtil.i( + "LegacyVoicemailNotificationReceiver.onReceive", + "visual voicemail is activated, ignoring notification"); + return; + } + String voicemailNumber = intent.getStringExtra(TelephonyManager.EXTRA_VOICEMAIL_NUMBER); PendingIntent callVoicemailIntent = intent.getParcelableExtra(TelephonyManager.EXTRA_CALL_VOICEMAIL_INTENT); diff --git a/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java b/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java index 5ac487b2d..524873f6d 100644 --- a/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java +++ b/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java @@ -847,6 +847,9 @@ public class VoicemailPlaybackPresenter } private void showShareVoicemailButton(boolean show) { + if (mContext == null) { + return; + } if (isShareVoicemailAllowed(mContext) && shareVoicemailButtonView != null) { if (show) { Logger.get(mContext).logImpression(DialerImpression.Type.VVM_SHARE_VISIBLE); -- cgit v1.2.3