Merge "Do not retry if port number is unavailable." into mnc-dev
diff --git a/src/com/android/phone/vvm/omtp/fetch/FetchVoicemailReceiver.java b/src/com/android/phone/vvm/omtp/fetch/FetchVoicemailReceiver.java
index 83e9633..43724e4 100644
--- a/src/com/android/phone/vvm/omtp/fetch/FetchVoicemailReceiver.java
+++ b/src/com/android/phone/vvm/omtp/fetch/FetchVoicemailReceiver.java
@@ -135,6 +135,12 @@
public void run() {
while (mRetryCount > 0) {
ImapHelper imapHelper = new ImapHelper(mContext, mPhoneAccount, network);
+ if (!imapHelper.isSuccessfullyInitialized()) {
+ Log.w(TAG, "Can't retrieve Imap credentials.");
+ releaseNetwork();
+ return;
+ }
+
boolean success = imapHelper.fetchVoicemailPayload(
new VoicemailFetchedCallback(mContext, mUri), mUid);
if (!success && mRetryCount > 0) {
diff --git a/src/com/android/phone/vvm/omtp/imap/ImapHelper.java b/src/com/android/phone/vvm/omtp/imap/ImapHelper.java
index b40cf1e..1d20dbd 100644
--- a/src/com/android/phone/vvm/omtp/imap/ImapHelper.java
+++ b/src/com/android/phone/vvm/omtp/imap/ImapHelper.java
@@ -79,10 +79,19 @@
mImapStore = new ImapStore(
context, username, password, port, serverName, ImapStore.FLAG_NONE, network);
} catch (NumberFormatException e) {
- LogUtils.e(TAG, e, "Could not parse port number");
+ LogUtils.w(TAG, "Could not parse port number");
}
}
+ /**
+ * If mImapStore is null, this means that there was a missing or badly formatted port number,
+ * which means there aren't sufficient credentials for login. If mImapStore is succcessfully
+ * initialized, then ImapHelper is ready to go.
+ */
+ public boolean isSuccessfullyInitialized() {
+ return mImapStore != null;
+ }
+
/** The caller thread will block until the method returns. */
public boolean markMessagesAsRead(List<Voicemail> voicemails) {
return setFlags(voicemails, Flag.SEEN);
diff --git a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
index d96f058..d0c6231 100644
--- a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
+++ b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
@@ -200,6 +200,15 @@
downloadSuccess = true;
ImapHelper imapHelper = new ImapHelper(mContext, mPhoneAccount, network);
+
+ if (!imapHelper.isSuccessfullyInitialized()) {
+ Log.w(TAG, "Can't retrieve Imap credentials.");
+ releaseNetwork(this);
+ VisualVoicemailSettingsUtil.resetVisualVoicemailRetryInterval(mContext,
+ mPhoneAccount);
+ return;
+ }
+
if (SYNC_FULL_SYNC.equals(mAction) || SYNC_UPLOAD_ONLY.equals(mAction)) {
uploadSuccess = upload(imapHelper);
}
diff --git a/src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java b/src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java
index d4b84d4..84449d7 100644
--- a/src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java
+++ b/src/com/android/phone/vvm/omtp/sync/VvmPhoneStateListener.java
@@ -55,7 +55,9 @@
true /* firstAttempt */);
mContext.startService(serviceIntent);
}
- } else {
+ }
+
+ if (!OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
OmtpVvmCarrierConfigHelper carrierConfigHelper = new OmtpVvmCarrierConfigHelper(
mContext, PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
carrierConfigHelper.startActivation();