From b780cb914e8ae07da39e771539c73bc915ac2e7c Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 21 May 2018 14:44:52 -0700 Subject: Ignore dialer OMTP VVM error if VVM is disabled The status will be stale. TEST=TAP Bug: 78831353 Test: TAP PiperOrigin-RevId: 197462056 Change-Id: Iaeeae9007f6b5ad8319889a860fdcce782be8a0d --- .../app/calllog/VisualVoicemailCallLogFragment.java | 4 ++-- .../dialer/app/voicemail/VoicemailErrorManager.java | 4 +++- .../dialer/voicemail/listui/NewVoicemailFragment.java | 4 +++- .../voicemail/listui/error/VoicemailStatus.java | 19 ++++++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index dba43a2f7..5b6eb0387 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -182,10 +182,10 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { } @VisibleForTesting - static boolean shouldAutoSync( + boolean shouldAutoSync( VoicemailErrorMessageCreator errorMessageCreator, List statuses) { for (VoicemailStatus status : statuses) { - if (!status.isActive()) { + if (!status.isActive(getContext())) { continue; } if (errorMessageCreator.isSyncBlockingError(status)) { diff --git a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java index ffaf16d18..a441e7986 100644 --- a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java +++ b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java @@ -86,9 +86,11 @@ public class VoicemailErrorManager implements CallLogQueryHandler.Listener, Voic List statuses = new ArrayList<>(); while (statusCursor.moveToNext()) { VoicemailStatus status = new VoicemailStatus(context, statusCursor); - if (status.isActive()) { + if (status.isActive(context)) { statuses.add(status); addServiceStateListener(status); + } else { + LogUtil.i("VisualVoicemailCallLogFragment.shouldAutoSync", "inactive source ignored"); } } alertItem.updateStatus(statuses, this); diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java index b2052c61e..243dc6a86 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java @@ -280,7 +280,9 @@ public final class NewVoicemailFragment extends Fragment implements LoaderCallba while (cursor.moveToNext()) { VoicemailStatus status = new VoicemailStatus(context, cursor); - if (status.isActive()) { + if (status.isActive(context)) { + LogUtil.i( + "NewVoicemailFragment.queryVoicemailStatus", "inactive source ignored"); statuses.add(status); // TODO(a bug): Handle Service State Listeners } diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java b/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java index 4f4dbbbe8..ebda0e658 100644 --- a/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java +++ b/java/com/android/dialer/voicemail/listui/error/VoicemailStatus.java @@ -34,6 +34,8 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.voicemailstatus.VoicemailStatusQuery; +import com.android.voicemail.VoicemailClient; +import com.android.voicemail.VoicemailComponent; /** Structured data from {@link android.provider.VoicemailContract.Status} */ public class VoicemailStatus { @@ -232,7 +234,22 @@ public class VoicemailStatus { } } - public boolean isActive() { + public boolean isActive(Context context) { + VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient(); + if (context.getPackageName().equals(sourcePackage)) { + if (!voicemailClient.isVoicemailModuleEnabled()) { + LogUtil.i("VoicemailStatus.isActive", "module disabled"); + return false; + } + if (!voicemailClient.hasCarrierSupport(context, getPhoneAccountHandle())) { + LogUtil.i("VoicemailStatus.isActive", "carrier not supported"); + return false; + } + if (!voicemailClient.isVoicemailEnabled(context, getPhoneAccountHandle())) { + LogUtil.i("VoicemailStatus.isActive", "VVM disabled"); + return false; + } + } switch (configurationState) { case Status.CONFIGURATION_STATE_NOT_CONFIGURED: case Status.CONFIGURATION_STATE_DISABLED: -- cgit v1.2.3