Merge "VVM: Do not do full sync more than once within a 1 minute span." into mnc-dev
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 2223466..315929b 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -956,6 +956,15 @@
     }
 
     /**
+     * Dismisses the message waiting (voicemail) indicator.
+     *
+     * @param subId the subscription id we should dismiss the notification for.
+     */
+    public void clearMwiIndicator(int subId) {
+        notificationMgr.updateMwi(subId, false);
+    }
+
+    /**
      * "Call origin" may be used by Contacts app to specify where the phone call comes from.
      * Currently, the only permitted value for this extra is {@link #ALLOWED_EXTRA_CALL_ORIGIN}.
      * Any other value will be ignored, to make sure that malicious apps can't trick the in-call
diff --git a/src/com/android/phone/VvmPhoneStateListener.java b/src/com/android/phone/vvm/omtp/VvmPhoneStateListener.java
similarity index 95%
rename from src/com/android/phone/VvmPhoneStateListener.java
rename to src/com/android/phone/vvm/omtp/VvmPhoneStateListener.java
index 53eff79..1b2e34e 100644
--- a/src/com/android/phone/VvmPhoneStateListener.java
+++ b/src/com/android/phone/vvm/omtp/VvmPhoneStateListener.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License
  */
-package com.android.phone;
+package com.android.phone.vvm.omtp;
 
 import android.content.Context;
 import android.content.Intent;
@@ -23,8 +23,8 @@
 import android.telephony.ServiceState;
 import android.util.Log;
 
-import com.android.phone.vvm.omtp.LocalLogHelper;
-import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
+import com.android.phone.PhoneGlobals;
+import com.android.phone.PhoneUtils;
 import com.android.phone.vvm.omtp.sync.OmtpVvmSourceManager;
 import com.android.phone.vvm.omtp.sync.OmtpVvmSyncService;
 import com.android.phone.vvm.omtp.sync.VoicemailStatusQueryHelper;
@@ -66,8 +66,8 @@
                             VoicemailContract.Status.CONFIGURATION_STATE_OK,
                             VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
                             VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
-                    PhoneGlobals.getInstance().notificationMgr.updateMwi(
-                            PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount), false);
+                    PhoneGlobals.getInstance().clearMwiIndicator(
+                            PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
                 }
             }
 
diff --git a/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java b/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
index 4260a37..3eefbee 100644
--- a/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
+++ b/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
@@ -27,6 +27,7 @@
 import android.util.Log;
 
 import com.android.internal.telephony.PhoneConstants;
+import com.android.phone.PhoneGlobals;
 import com.android.phone.PhoneUtils;
 import com.android.phone.settings.VisualVoicemailSettingsUtil;
 import com.android.phone.vvm.omtp.LocalLogHelper;
@@ -150,6 +151,9 @@
                     mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount,
                     true /* firstAttempt */);
             mContext.startService(serviceIntent);
+
+            PhoneGlobals.getInstance().clearMwiIndicator(
+                    PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
         } else {
             Log.w(TAG, "Visual voicemail not available for subscriber.");
             // Override default isEnabled setting to false since visual voicemail is unable to
diff --git a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java
index 7668dad..0520098 100644
--- a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java
+++ b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSourceManager.java
@@ -24,7 +24,7 @@
 
 import com.android.internal.telephony.Phone;
 import com.android.phone.PhoneUtils;
-import com.android.phone.VvmPhoneStateListener;
+import com.android.phone.vvm.omtp.VvmPhoneStateListener;
 
 import java.util.Collections;
 import java.util.Map;
diff --git a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
index 5667b94..3c47975 100644
--- a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
+++ b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
@@ -271,25 +271,11 @@
         @Override
         public void onLost(Network network) {
             releaseNetwork(this);
-
-            if (mRetryCount > 0) {
-                mRetryCount--;
-                requestNetwork(this);
-            } else {
-                setRetryAlarm(mPhoneAccount, mAction);
-            }
         }
 
         @Override
         public void onUnavailable() {
             releaseNetwork(this);
-
-            if (mRetryCount> 0) {
-                mRetryCount--;
-                requestNetwork(this);
-            } else {
-                setRetryAlarm(mPhoneAccount, mAction);
-            }
         }
     }