Import of Volley from GitHub to AOSP.
am: e926546a73

Change-Id: Ic3b1df081cd93f4d7daafecb1ddc208e51dc38dc
diff --git a/.travis.yml b/.travis.yml
index 44ff763..fb6481a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,14 +1,19 @@
 language: android
 android:
+  licenses:
+    - 'android-sdk-preview-license-.+'
+    - 'android-sdk-license-.+'
+    - 'google-gdk-license-.+'
+
   components:
-    # Workaround to be able to install v25 SDK and build tools.
+    # Workaround to be able to install v28 SDK and build tools.
     # See https://github.com/travis-ci/travis-ci/issues/6040
     - tools # to update the repository XML files
     - tools # to update the SDK tools themselves
 
     - platform-tools
-    - build-tools-25.0.2
-    - android-25
+    - build-tools-28.0.3
+    - android-28
 
 jdk:
   - oraclejdk8
diff --git a/Android.bp b/Android.bp
index 8113313..e101494 100644
--- a/Android.bp
+++ b/Android.bp
@@ -21,5 +21,5 @@
     srcs: ["src/main/java/**/*.java"],
 
     // Only needed at compile-time.
-    libs: ["android-support-annotations"],
+    libs: ["androidx.annotation_annotation"],
 }
diff --git a/bintray.gradle b/bintray.gradle
index 05700a4..9007c31 100644
--- a/bintray.gradle
+++ b/bintray.gradle
@@ -3,7 +3,7 @@
         jcenter()
     }
     dependencies {
-        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0"
+        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1"
     }
 }
 
diff --git a/build.gradle b/build.gradle
index 318d4c0..1765a3a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,9 +17,10 @@
 buildscript {
     repositories {
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.2.1'
     }
 }
 
@@ -37,18 +38,20 @@
 
 repositories {
     jcenter()
-    maven {
-        url 'https://maven.google.com/'
-        name 'Google'
-    }
+    google()
 }
 
 group = 'com.android.volley'
 version = '1.2.0-SNAPSHOT'
 
 android {
-    compileSdkVersion 25
-    buildToolsVersion = '25.0.2'
+    compileSdkVersion 28
+    buildToolsVersion = '28.0.3'
+
+    defaultConfig {
+        // Keep in sync with src/main/AndroidManifest.xml
+        minSdkVersion 8
+    }
 }
 
 tasks.withType(JavaCompile) {
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..5465fec
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,2 @@
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 602f949..9d8a946 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
diff --git a/rules.gradle b/rules.gradle
index 49aa24b..fd660cd 100644
--- a/rules.gradle
+++ b/rules.gradle
@@ -20,15 +20,15 @@
 }
 
 dependencies {
-  provided "com.android.support:support-annotations:27.1.1"
+    implementation "androidx.annotation:annotation:1.0.1"
 }
 
 // Check if the android plugin version supports unit testing.
 if (configurations.findByName("testCompile")) {
   dependencies {
-    testCompile "junit:junit:4.12"
-    testCompile "org.hamcrest:hamcrest-library:1.3"
-    testCompile "org.mockito:mockito-core:2.2.29"
-    testCompile "org.robolectric:robolectric:3.0"
+      testCompile "junit:junit:4.12"
+      testCompile "org.hamcrest:hamcrest-library:1.3"
+      testCompile "org.mockito:mockito-core:2.19.0"
+      testCompile "org.robolectric:robolectric:3.4.2"
   }
 }
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 16eec15..da8d33e 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -1,10 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     package="com.android.volley"
     android:versionCode="1"
     android:versionName="1.0" >
 
-    <uses-sdk android:minSdkVersion="8" />
+    <!-- Keep in sync with build.gradle -->
+    <uses-sdk
+        android:minSdkVersion="8"
+        tools:ignore="GradleOverrides" />
 
     <application />
 
diff --git a/src/main/java/com/android/volley/CacheDispatcher.java b/src/main/java/com/android/volley/CacheDispatcher.java
index 13f250b..be06d1f 100644
--- a/src/main/java/com/android/volley/CacheDispatcher.java
+++ b/src/main/java/com/android/volley/CacheDispatcher.java
@@ -17,7 +17,7 @@
 package com.android.volley;
 
 import android.os.Process;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
diff --git a/src/main/java/com/android/volley/NetworkDispatcher.java b/src/main/java/com/android/volley/NetworkDispatcher.java
index 762e030..06057c3 100644
--- a/src/main/java/com/android/volley/NetworkDispatcher.java
+++ b/src/main/java/com/android/volley/NetworkDispatcher.java
@@ -21,7 +21,7 @@
 import android.os.Build;
 import android.os.Process;
 import android.os.SystemClock;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
 import java.util.concurrent.BlockingQueue;
 
 /**
diff --git a/src/main/java/com/android/volley/Request.java b/src/main/java/com/android/volley/Request.java
index 0b18abb..104b046 100644
--- a/src/main/java/com/android/volley/Request.java
+++ b/src/main/java/com/android/volley/Request.java
@@ -20,10 +20,10 @@
 import android.net.Uri;
 import android.os.Handler;
 import android.os.Looper;
-import android.support.annotation.CallSuper;
-import android.support.annotation.GuardedBy;
-import android.support.annotation.Nullable;
 import android.text.TextUtils;
+import androidx.annotation.CallSuper;
+import androidx.annotation.GuardedBy;
+import androidx.annotation.Nullable;
 import com.android.volley.VolleyLog.MarkerLog;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
diff --git a/src/main/java/com/android/volley/RequestQueue.java b/src/main/java/com/android/volley/RequestQueue.java
index 42b3fa2..c127c7f 100644
--- a/src/main/java/com/android/volley/RequestQueue.java
+++ b/src/main/java/com/android/volley/RequestQueue.java
@@ -18,7 +18,7 @@
 
 import android.os.Handler;
 import android.os.Looper;
-import android.support.annotation.IntDef;
+import androidx.annotation.IntDef;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
diff --git a/src/main/java/com/android/volley/toolbox/AndroidAuthenticator.java b/src/main/java/com/android/volley/toolbox/AndroidAuthenticator.java
index 72271fc..f3381ae 100644
--- a/src/main/java/com/android/volley/toolbox/AndroidAuthenticator.java
+++ b/src/main/java/com/android/volley/toolbox/AndroidAuthenticator.java
@@ -23,7 +23,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
 import com.android.volley.AuthFailureError;
 
 /**
diff --git a/src/main/java/com/android/volley/toolbox/BaseHttpStack.java b/src/main/java/com/android/volley/toolbox/BaseHttpStack.java
index 4f596e1..99a9899 100644
--- a/src/main/java/com/android/volley/toolbox/BaseHttpStack.java
+++ b/src/main/java/com/android/volley/toolbox/BaseHttpStack.java
@@ -77,7 +77,7 @@
         for (Header header : response.getHeaders()) {
             headers.add(new BasicHeader(header.getName(), header.getValue()));
         }
-        apacheResponse.setHeaders(headers.toArray(new org.apache.http.Header[headers.size()]));
+        apacheResponse.setHeaders(headers.toArray(new org.apache.http.Header[0]));
 
         InputStream responseStream = response.getContent();
         if (responseStream != null) {
diff --git a/src/main/java/com/android/volley/toolbox/DiskBasedCache.java b/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
index 75c217f..a6a0c83 100644
--- a/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
+++ b/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
@@ -17,8 +17,8 @@
 package com.android.volley.toolbox;
 
 import android.os.SystemClock;
-import android.support.annotation.VisibleForTesting;
 import android.text.TextUtils;
+import androidx.annotation.VisibleForTesting;
 import com.android.volley.Cache;
 import com.android.volley.Header;
 import com.android.volley.VolleyLog;
diff --git a/src/main/java/com/android/volley/toolbox/HurlStack.java b/src/main/java/com/android/volley/toolbox/HurlStack.java
index 5af18ef..f85d42c 100644
--- a/src/main/java/com/android/volley/toolbox/HurlStack.java
+++ b/src/main/java/com/android/volley/toolbox/HurlStack.java
@@ -16,7 +16,7 @@
 
 package com.android.volley.toolbox;
 
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
 import com.android.volley.AuthFailureError;
 import com.android.volley.Header;
 import com.android.volley.Request;
diff --git a/src/main/java/com/android/volley/toolbox/ImageLoader.java b/src/main/java/com/android/volley/toolbox/ImageLoader.java
index 270935f..b80072b 100644
--- a/src/main/java/com/android/volley/toolbox/ImageLoader.java
+++ b/src/main/java/com/android/volley/toolbox/ImageLoader.java
@@ -17,9 +17,9 @@
 import android.graphics.Bitmap.Config;
 import android.os.Handler;
 import android.os.Looper;
-import android.support.annotation.MainThread;
 import android.widget.ImageView;
 import android.widget.ImageView.ScaleType;
+import androidx.annotation.MainThread;
 import com.android.volley.Request;
 import com.android.volley.RequestQueue;
 import com.android.volley.Response.ErrorListener;
diff --git a/src/main/java/com/android/volley/toolbox/ImageRequest.java b/src/main/java/com/android/volley/toolbox/ImageRequest.java
index 59e468f..32b5aa3 100644
--- a/src/main/java/com/android/volley/toolbox/ImageRequest.java
+++ b/src/main/java/com/android/volley/toolbox/ImageRequest.java
@@ -19,10 +19,10 @@
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.graphics.BitmapFactory;
-import android.support.annotation.GuardedBy;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
 import android.widget.ImageView.ScaleType;
+import androidx.annotation.GuardedBy;
+import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
 import com.android.volley.DefaultRetryPolicy;
 import com.android.volley.NetworkResponse;
 import com.android.volley.ParseError;
diff --git a/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java b/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java
index 1abaec7..86ed9e9 100644
--- a/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java
+++ b/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java
@@ -16,7 +16,7 @@
 
 package com.android.volley.toolbox;
 
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
 import com.android.volley.NetworkResponse;
 import com.android.volley.ParseError;
 import com.android.volley.Response;
diff --git a/src/main/java/com/android/volley/toolbox/JsonObjectRequest.java b/src/main/java/com/android/volley/toolbox/JsonObjectRequest.java
index cee5efe..8dca0ec 100644
--- a/src/main/java/com/android/volley/toolbox/JsonObjectRequest.java
+++ b/src/main/java/com/android/volley/toolbox/JsonObjectRequest.java
@@ -16,7 +16,7 @@
 
 package com.android.volley.toolbox;
 
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
 import com.android.volley.NetworkResponse;
 import com.android.volley.ParseError;
 import com.android.volley.Response;
diff --git a/src/main/java/com/android/volley/toolbox/JsonRequest.java b/src/main/java/com/android/volley/toolbox/JsonRequest.java
index c00d3db..bc035ae 100644
--- a/src/main/java/com/android/volley/toolbox/JsonRequest.java
+++ b/src/main/java/com/android/volley/toolbox/JsonRequest.java
@@ -16,8 +16,8 @@
 
 package com.android.volley.toolbox;
 
-import android.support.annotation.GuardedBy;
-import android.support.annotation.Nullable;
+import androidx.annotation.GuardedBy;
+import androidx.annotation.Nullable;
 import com.android.volley.NetworkResponse;
 import com.android.volley.Request;
 import com.android.volley.Response;
diff --git a/src/main/java/com/android/volley/toolbox/NetworkImageView.java b/src/main/java/com/android/volley/toolbox/NetworkImageView.java
index 6ad1e49..53affc3 100644
--- a/src/main/java/com/android/volley/toolbox/NetworkImageView.java
+++ b/src/main/java/com/android/volley/toolbox/NetworkImageView.java
@@ -15,12 +15,12 @@
 
 import android.content.Context;
 import android.graphics.Bitmap;
-import android.support.annotation.MainThread;
-import android.support.annotation.Nullable;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.ViewGroup.LayoutParams;
 import android.widget.ImageView;
+import androidx.annotation.MainThread;
+import androidx.annotation.Nullable;
 import com.android.volley.VolleyError;
 import com.android.volley.toolbox.ImageLoader.ImageContainer;
 import com.android.volley.toolbox.ImageLoader.ImageListener;
@@ -100,12 +100,10 @@
      * Sets the default image resource ID to be used for this view until the attempt to load it
      * completes.
      *
-     * <p>Cannot be called with {@link NetworkImageView#setDefaultImageBitmap}.
+     * <p>This will clear anything set by {@link NetworkImageView#setDefaultImageBitmap}.
      */
     public void setDefaultImageResId(int defaultImage) {
-        if (mDefaultImageBitmap != null) {
-            throw new IllegalArgumentException("Can't have a default image resource ID and bitmap");
-        }
+        mDefaultImageBitmap = null;
         mDefaultImageId = defaultImage;
     }
 
@@ -113,12 +111,10 @@
      * Sets the default image bitmap to be used for this view until the attempt to load it
      * completes.
      *
-     * <p>Cannot be called with {@link NetworkImageView#setDefaultImageResId}.
+     * <p>This will clear anything set by {@link NetworkImageView#setDefaultImageResId}.
      */
     public void setDefaultImageBitmap(Bitmap defaultImage) {
-        if (mDefaultImageId != 0) {
-            throw new IllegalArgumentException("Can't have a default image resource ID and bitmap");
-        }
+        mDefaultImageId = 0;
         mDefaultImageBitmap = defaultImage;
     }
 
@@ -126,12 +122,10 @@
      * Sets the error image resource ID to be used for this view in the event that the image
      * requested fails to load.
      *
-     * <p>Cannot be called with {@link NetworkImageView#setErrorImageBitmap}.
+     * <p>This will clear anything set by {@link NetworkImageView#setErrorImageBitmap}.
      */
     public void setErrorImageResId(int errorImage) {
-        if (mErrorImageBitmap != null) {
-            throw new IllegalArgumentException("Can't have an error image resource ID and bitmap");
-        }
+        mErrorImageBitmap = null;
         mErrorImageId = errorImage;
     }
 
@@ -139,12 +133,10 @@
      * Sets the error image bitmap to be used for this view in the event that the image requested
      * fails to load.
      *
-     * <p>Cannot be called with {@link NetworkImageView#setErrorImageResId}.
+     * <p>This will clear anything set by {@link NetworkImageView#setErrorImageResId}.
      */
     public void setErrorImageBitmap(Bitmap errorImage) {
-        if (mErrorImageId != 0) {
-            throw new IllegalArgumentException("Can't have an error image resource ID and bitmap");
-        }
+        mErrorImageId = 0;
         mErrorImageBitmap = errorImage;
     }
 
diff --git a/src/main/java/com/android/volley/toolbox/StringRequest.java b/src/main/java/com/android/volley/toolbox/StringRequest.java
index c4c89b5..df7b386 100644
--- a/src/main/java/com/android/volley/toolbox/StringRequest.java
+++ b/src/main/java/com/android/volley/toolbox/StringRequest.java
@@ -16,8 +16,8 @@
 
 package com.android.volley.toolbox;
 
-import android.support.annotation.GuardedBy;
-import android.support.annotation.Nullable;
+import androidx.annotation.GuardedBy;
+import androidx.annotation.Nullable;
 import com.android.volley.NetworkResponse;
 import com.android.volley.Request;
 import com.android.volley.Response;
diff --git a/src/test/java/com/android/volley/NetworkResponseTest.java b/src/test/java/com/android/volley/NetworkResponseTest.java
index 48b1f6d..70210da 100644
--- a/src/test/java/com/android/volley/NetworkResponseTest.java
+++ b/src/test/java/com/android/volley/NetworkResponseTest.java
@@ -29,9 +29,7 @@
         expectedHeaders.add(new Header("key1", "value1"));
         expectedHeaders.add(new Header("key2", "value2"));
 
-        assertThat(
-                expectedHeaders,
-                containsInAnyOrder(resp.allHeaders.toArray(new Header[resp.allHeaders.size()])));
+        assertThat(expectedHeaders, containsInAnyOrder(resp.allHeaders.toArray(new Header[0])));
     }
 
     @Test
diff --git a/src/test/java/com/android/volley/toolbox/BasicNetworkTest.java b/src/test/java/com/android/volley/toolbox/BasicNetworkTest.java
index adf695d..fec0694 100644
--- a/src/test/java/com/android/volley/toolbox/BasicNetworkTest.java
+++ b/src/test/java/com/android/volley/toolbox/BasicNetworkTest.java
@@ -121,10 +121,7 @@
         expectedHeaders.add(new Header("SharedCaseInsensitiveKey", "ServerValueShared2"));
         expectedHeaders.add(new Header("CachedKeyA", "CachedValueA"));
         expectedHeaders.add(new Header("CachedKeyB", "CachedValueB"));
-        assertThat(
-                expectedHeaders,
-                containsInAnyOrder(
-                        response.allHeaders.toArray(new Header[response.allHeaders.size()])));
+        assertThat(expectedHeaders, containsInAnyOrder(response.allHeaders.toArray(new Header[0])));
     }
 
     @Test
@@ -158,10 +155,7 @@
         expectedHeaders.add(new Header("SharedCaseInsensitiveKey", "ServerValueShared2"));
         expectedHeaders.add(new Header("CachedKeyA", "CachedValueA"));
         expectedHeaders.add(new Header("CachedKeyB", "CachedValueB"));
-        assertThat(
-                expectedHeaders,
-                containsInAnyOrder(
-                        response.allHeaders.toArray(new Header[response.allHeaders.size()])));
+        assertThat(expectedHeaders, containsInAnyOrder(response.allHeaders.toArray(new Header[0])));
     }
 
     @Test