Move the public method HttpDateTime.parse() into AndroidHttpClient.

See bug http://b/2553589

Change-Id: Ide3399c7c63daf9c0b8c18669076f2f4d6e9a876
diff --git a/api/current.xml b/api/current.xml
index 58b9c17..5e8be99 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -90859,6 +90859,19 @@
 <parameter name="userAgent" type="java.lang.String">
 </parameter>
 </method>
+<method name="parseDate"
+ return="long"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dateString" type="java.lang.String">
+</parameter>
+</method>
 <field name="DEFAULT_SYNC_MIN_GZIP_BYTES"
  type="long"
  transient="false"
@@ -90870,38 +90883,6 @@
 >
 </field>
 </class>
-<class name="HttpDateTime"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="HttpDateTime"
- type="android.net.http.HttpDateTime"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="parse"
- return="java.lang.Long"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="timeString" type="java.lang.String">
-</parameter>
-<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
-</exception>
-</method>
-</class>
 <class name="SslCertificate"
  extends="java.lang.Object"
  abstract="false"
diff --git a/common/java/com/android/common/OperationScheduler.java b/common/java/com/android/common/OperationScheduler.java
index 08cc25b..1786957 100644
--- a/common/java/com/android/common/OperationScheduler.java
+++ b/common/java/com/android/common/OperationScheduler.java
@@ -17,7 +17,7 @@
 package com.android.common;
 
 import android.content.SharedPreferences;
-import android.net.http.HttpDateTime;
+import android.net.http.AndroidHttpClient;
 import android.text.format.Time;
 
 import java.util.Map;
@@ -243,7 +243,7 @@
             return true;
         } catch (NumberFormatException nfe) {
             try {
-                setMoratoriumTimeMillis(HttpDateTime.parse(retryAfter));
+                setMoratoriumTimeMillis(AndroidHttpClient.parseDate(retryAfter));
                 return true;
             } catch (IllegalArgumentException iae) {
                 return false;
diff --git a/core/java/android/net/http/AndroidHttpClient.java b/core/java/android/net/http/AndroidHttpClient.java
index 3517737..e07ee59 100644
--- a/core/java/android/net/http/AndroidHttpClient.java
+++ b/core/java/android/net/http/AndroidHttpClient.java
@@ -16,6 +16,7 @@
 
 package android.net.http;
 
+import com.android.internal.http.HttpDateTime;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -444,4 +445,22 @@
 
         return builder.toString();
     }
+
+    /**
+     * Returns the date of the given HTTP date string. This method can identify
+     * and parse the date formats emitted by common HTTP servers, such as
+     * <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC 822</a>,
+     * <a href="http://www.ietf.org/rfc/rfc0850.txt">RFC 850</a>,
+     * <a href="http://www.ietf.org/rfc/rfc1036.txt">RFC 1036</a>,
+     * <a href="http://www.ietf.org/rfc/rfc1123.txt">RFC 1123</a> and
+     * <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html">ANSI
+     * C's asctime()</a>.
+     *
+     * @return the number of milliseconds since Jan. 1, 1970, midnight GMT.
+     * @throws IllegalArgumentException if {@code dateString} is not a date or
+     *     of an unsupported format.
+     */
+    public static long parseDate(String dateString) {
+        return HttpDateTime.parse(dateString);
+    }
 }
diff --git a/core/java/android/webkit/CacheManager.java b/core/java/android/webkit/CacheManager.java
index d19805e..d5058b0 100644
--- a/core/java/android/webkit/CacheManager.java
+++ b/core/java/android/webkit/CacheManager.java
@@ -17,8 +17,8 @@
 package android.webkit;
 
 import android.content.Context;
+import android.net.http.AndroidHttpClient;
 import android.net.http.Headers;
-import android.net.http.HttpDateTime;
 import android.os.FileUtils;
 import android.util.Log;
 import java.io.File;
@@ -716,7 +716,7 @@
         ret.expiresString = headers.getExpires();
         if (ret.expiresString != null) {
             try {
-                ret.expires = HttpDateTime.parse(ret.expiresString);
+                ret.expires = AndroidHttpClient.parseDate(ret.expiresString);
             } catch (IllegalArgumentException ex) {
                 // Take care of the special "-1" and "0" cases
                 if ("-1".equals(ret.expiresString)
@@ -831,7 +831,7 @@
                 // 24 * 60 * 60 * 1000
                 long lastmod = System.currentTimeMillis() + 86400000;
                 try {
-                    lastmod = HttpDateTime.parse(ret.lastModified);
+                    lastmod = AndroidHttpClient.parseDate(ret.lastModified);
                 } catch (IllegalArgumentException ex) {
                     Log.e(LOGTAG, "illegal lastModified: " + ret.lastModified);
                 }
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 758a152..ac20791 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -18,7 +18,7 @@
 
 import android.net.ParseException;
 import android.net.WebAddress;
-import android.net.http.HttpDateTime;
+import android.net.http.AndroidHttpClient;
 import android.util.Log;
 
 
@@ -939,7 +939,7 @@
                     }
                     if (name.equals(EXPIRES)) {
                         try {
-                            cookie.expires = HttpDateTime.parse(value);
+                            cookie.expires = AndroidHttpClient.parseDate(value);
                         } catch (IllegalArgumentException ex) {
                             Log.e(LOGTAG,
                                     "illegal format for expires: " + value);
diff --git a/core/java/android/net/http/HttpDateTime.java b/core/java/com/android/internal/http/HttpDateTime.java
similarity index 98%
rename from core/java/android/net/http/HttpDateTime.java
rename to core/java/com/android/internal/http/HttpDateTime.java
index c7a31ee..8ebd4aa 100644
--- a/core/java/android/net/http/HttpDateTime.java
+++ b/core/java/com/android/internal/http/HttpDateTime.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.net.http;
+package com.android.internal.http;
 
 import android.text.format.Time;
 
@@ -82,7 +82,7 @@
         int second;
     }
 
-    public static Long parse(String timeString)
+    public static long parse(String timeString)
             throws IllegalArgumentException {
 
         int date = 1;
diff --git a/preloaded-classes b/preloaded-classes
index 54c7303..8114562 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -313,7 +313,7 @@
 android.net.http.EventHandler
 android.net.http.Headers
 android.net.http.HttpsConnection
-android.net.http.HttpDateTime
+com.android.internal.http.HttpDateTime
 android.net.http.Request
 android.net.http.RequestQueue
 android.net.http.SslCertificate