Switch constants to existing standard values.

Change-Id: I9196714d9fd9462034d3931282ed9dbf559a1a0d
diff --git a/src/com/android/exchange/EasAccountService.java b/src/com/android/exchange/EasAccountService.java
index a81671d..0ed5691 100644
--- a/src/com/android/exchange/EasAccountService.java
+++ b/src/com/android/exchange/EasAccountService.java
@@ -27,6 +27,7 @@
 import android.provider.CalendarContract;
 import android.provider.ContactsContract;
 import android.text.TextUtils;
+import android.text.format.DateUtils;
 import android.util.Log;
 
 import com.android.emailcommon.TrafficFlags;
@@ -112,9 +113,9 @@
     // The amount of time the account mailbox will sleep if there are no pingable mailboxes
     // This could happen if the sync time is set to "never"; we always want to check in from time
     // to time, however, for folder list/policy changes
-    static private final int ACCOUNT_MAILBOX_SLEEP_TIME = 20*MINUTES;
-    static private final String ACCOUNT_MAILBOX_SLEEP_TEXT =
-        "Account mailbox sleeping for " + (ACCOUNT_MAILBOX_SLEEP_TIME / MINUTES) + "m";
+    static private final int ACCOUNT_MAILBOX_SLEEP_TIME = (int)(20 * DateUtils.MINUTE_IN_MILLIS);
+    static private final String ACCOUNT_MAILBOX_SLEEP_TEXT = "Account mailbox sleeping for " +
+            (ACCOUNT_MAILBOX_SLEEP_TIME / DateUtils.MINUTE_IN_MILLIS) + "m";
 
     // Our heartbeat when we are waiting for ping boxes to be ready
     /*package*/ int mPingForceHeartbeat = 2*PING_MINUTES;
@@ -255,7 +256,7 @@
             // Determine our protocol version, if we haven't already and save it in the Account
             // Also re-check protocol version at least once a day (in case of upgrade)
             if (mAccount.mProtocolVersion == null || firstSync ||
-                   ((System.currentTimeMillis() - mMailbox.mSyncTime) > DAYS)) {
+                   ((System.currentTimeMillis() - mMailbox.mSyncTime) > DateUtils.DAY_IN_MILLIS)) {
                 userLog("Determine EAS protocol version");
                 EasResponse resp = sendHttpClientOptions();
                 try {
@@ -521,7 +522,7 @@
 
     private void sleep(long ms, boolean runAsleep) {
         if (runAsleep) {
-            ExchangeService.runAsleep(mMailboxId, ms+(5*SECONDS));
+            ExchangeService.runAsleep(mMailboxId, ms + (5 * DateUtils.SECOND_IN_MILLIS));
         }
         try {
             Thread.sleep(ms);
@@ -540,7 +541,7 @@
            userLog("Send ping, timeout: " + heartbeat + "s, high: " + mPingHighWaterMark + 's');
        }
        return sendHttpClientPost(EasSyncService.PING_COMMAND, new ByteArrayEntity(bytes),
-               (heartbeat+5)*SECONDS);
+               (int)((heartbeat + 5) * DateUtils.SECOND_IN_MILLIS));
     }
 
     private void runPingLoop() throws IOException, StaleFolderListException,
@@ -548,7 +549,7 @@
         int pingHeartbeat = mPingHeartbeat;
         userLog("runPingLoop");
         // Do push for all sync services here
-        long endTime = System.currentTimeMillis() + (30*MINUTES);
+        long endTime = System.currentTimeMillis() + (30 * DateUtils.MINUTE_IN_MILLIS);
         HashMap<String, Integer> pingErrorMap = new HashMap<String, Integer>();
         ArrayList<String> readyMailboxes = new ArrayList<String>();
         ArrayList<String> notReadyMailboxes = new ArrayList<String>();
@@ -781,11 +782,11 @@
                 // In this case, there aren't any boxes that are pingable, but there are boxes
                 // waiting (for IOExceptions)
                 userLog("pingLoop waiting 60s for any pingable boxes");
-                sleep(60*SECONDS, true);
+                sleep(60 * DateUtils.SECOND_IN_MILLIS, true);
             } else if (pushCount > 0) {
                 // If we want to Ping, but can't just yet, wait a little bit
                 // TODO Change sleep to wait and use notify from ExchangeService when a sync ends
-                sleep(2*SECONDS, false);
+                sleep(2 * DateUtils.SECOND_IN_MILLIS, false);
                 pingWaitCount++;
                 //userLog("pingLoop waited 2s for: ", (pushCount - canPushCount), " box(es)");
             } else if (uninitCount > 0) {
@@ -793,10 +794,10 @@
                 // is typically a one-time case, I'm ok with trying again every 10 seconds until
                 // we're in one of the other possible states.
                 userLog("pingLoop waiting for initial sync of ", uninitCount, " box(es)");
-                sleep(10*SECONDS, true);
+                sleep(10 * DateUtils.SECOND_IN_MILLIS, true);
             } else if (inboxId == -1) {
                 // In this case, we're still syncing mailboxes, so sleep for only a short time
-                sleep(45*SECONDS, true);
+                sleep(45 * DateUtils.SECOND_IN_MILLIS, true);
             } else {
                 // We've got nothing to do, so we'll check again in 20 minutes at which time
                 // we'll update the folder list, check for policy changes and/or remote wipe, etc.
diff --git a/src/com/android/exchange/EasOutboxService.java b/src/com/android/exchange/EasOutboxService.java
index 71a81b8..7ba09a5 100644
--- a/src/com/android/exchange/EasOutboxService.java
+++ b/src/com/android/exchange/EasOutboxService.java
@@ -24,6 +24,7 @@
 import android.net.TrafficStats;
 import android.net.Uri;
 import android.os.RemoteException;
+import android.text.format.DateUtils;
 
 import com.android.emailcommon.TrafficFlags;
 import com.android.emailcommon.internet.Rfc822Output;
@@ -79,7 +80,7 @@
     // as to effectively "hang" sending of mail.  The standard 30 second timeout isn't long enough
     // for pictures and the like.  For now, we'll use 15 minutes, in the knowledge that any socket
     // failure would probably generate an Exception before timing out anyway
-    public static final int SEND_MAIL_TIMEOUT = 15*MINUTES;
+    public static final int SEND_MAIL_TIMEOUT = (int)(15 * DateUtils.MINUTE_IN_MILLIS);
 
     protected EasOutboxService(Context _context, Mailbox _mailbox) {
         super(_context, _mailbox);
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index aafba9b..adf6c34 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -31,6 +31,7 @@
 import android.provider.CalendarContract.Attendees;
 import android.provider.CalendarContract.Events;
 import android.text.TextUtils;
+import android.text.format.DateUtils;
 import android.util.Base64;
 import android.util.Log;
 import android.util.Xml;
@@ -112,11 +113,11 @@
     // Command timeout is the the time allowed for reading data from an open connection before an
     // IOException is thrown.  After a small added allowance, our watchdog alarm goes off (allowing
     // us to detect a silently dropped connection).  The allowance is defined below.
-    static public final int COMMAND_TIMEOUT = 30*SECONDS;
+    static public final int COMMAND_TIMEOUT = (int)(30 * DateUtils.SECOND_IN_MILLIS);
     // Connection timeout is the time given to connect to the server before reporting an IOException
-    static private final int CONNECTION_TIMEOUT = 20*SECONDS;
+    static private final int CONNECTION_TIMEOUT = (int)(20 * DateUtils.SECOND_IN_MILLIS);
     // The extra time allowed beyond the COMMAND_TIMEOUT before which our watchdog alarm triggers
-    static private final int WATCHDOG_TIMEOUT_ALLOWANCE = 30*SECONDS;
+    static private final int WATCHDOG_TIMEOUT_ALLOWANCE = (int)(30 * DateUtils.SECOND_IN_MILLIS);
 
     static private final String AUTO_DISCOVER_SCHEMA_PREFIX =
         "http://schemas.microsoft.com/exchange/autodiscover/mobilesync/";
@@ -130,7 +131,7 @@
 
     static public final int MESSAGE_FLAG_MOVED_MESSAGE = 1 << Message.FLAG_SYNC_ADAPTER_SHIFT;
     // The amount of time we allow for a thread to release its post lock after receiving an alert
-    static private final int POST_LOCK_TIMEOUT = 10*SECONDS;
+    static private final int POST_LOCK_TIMEOUT = (int)(10 * DateUtils.SECOND_IN_MILLIS);
 
     // The EAS protocol Provision status for "we implement all of the policies"
     static private final String PROVISION_STATUS_OK = "1";
@@ -214,6 +215,7 @@
         }
     }
 
+    @Override
     public void resetCalendarSyncKey() {
         CalendarSyncAdapter adapter = new CalendarSyncAdapter(this);
             try {
@@ -1513,7 +1515,6 @@
      * Acknowledge that we support the policies provided by the server, and that these policies
      * are in force.
      * @param tempKey the initial (temporary) policy key sent by the server
-     * @return the final policy key, which can be used for syncing
      * @throws IOException
      */
     private static void acknowledgeRemoteWipe(EasSyncService svc, String tempKey)
@@ -1673,7 +1674,7 @@
             target.sendSyncOptions(mProtocolVersionDouble, s, initialSync);
             if (initialSync) {
                 // Use enormous timeout for initial sync, which empirically can take a while longer
-                timeout = 120*SECONDS;
+                timeout = (int)(120 * DateUtils.SECOND_IN_MILLIS);
             }
             // Send our changes up to the server
             if (mUpsyncFailed) {