diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-15 02:01:57 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-15 02:01:57 +0000 |
commit | d1377ffccb1b47ed8631f0477cf16290acf49dde (patch) | |
tree | d8a94538711392cbdd9caca9b23f1dcf94cab22c | |
parent | 8e73315e0e318b19f370f3cfe18fa0affc06b7e9 (diff) | |
parent | 6bca65986c02f8a444fa3670b6455773d84885e4 (diff) | |
download | okhttp-android12-mainline-captiveportallogin-release.tar.gz |
Snap for 7550930 from 6bca65986c02f8a444fa3670b6455773d84885e4 to mainline-captiveportallogin-releaseandroid-mainline-12.0.0_r6android-mainline-12.0.0_r23android12-mainline-captiveportallogin-release
Change-Id: Ic49f57e0d89a97986e917978732aa1c4874cf184
9 files changed, 313 insertions, 99 deletions
@@ -16,6 +16,20 @@ package { default_visibility: ["//visibility:private"], + default_applicable_licenses: ["external_okhttp_license"], +} + +// Added automatically by a large-scale-change +// See: http://go/android-license-faq +license { + name: "external_okhttp_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-Apache-2.0", + ], + license_text: [ + "LICENSE.txt", + ], } // The source files that contribute to Android's core library APIs. @@ -55,54 +69,100 @@ java_library { java_version: "1.7", } +// The source implementation files, used to build okhttp and core-all. It is +// used in the latter case to break the cycle where okhttp depends on core-all +// and core-all depends on okhttp. By including the source into core-all it +// ensures that the code can all build correctly and then that is used to build +// the separate parts. +filegroup { + name: "okhttp_impl_files", + visibility: ["//libcore"], + srcs: [ + // Although some of the classes in the android/ directory are already in the correct + // package and do not need to be moved to another package they are transformed as they + // reference other classes that do require repackaging. + "repackaged/android/src/main/java/**/*.java", + "repackaged/okhttp/src/main/java/**/*.java", + "repackaged/okhttp-urlconnection/src/main/java/**/*.java", + "repackaged/okhttp-android-support/src/main/java/**/*.java", + "repackaged/okio/okio/src/main/java/**/*.java", + ], +} + java_library { name: "okhttp", - host_supported: true, visibility: [ "//art/build/apex", + "//art/build/sdk", "//external/grpc-grpc-java/okhttp", "//external/robolectric-shadows", "//libcore", + "//packages/modules/ArtPrebuilt", + ], + srcs: [ + ":okhttp_impl_files", ], - target: { - android: { - srcs: [ - // Although some of the classes in the android/ directory are already in the correct - // package and do not need to be moved to another package they are transformed as they - // reference other classes that do require repackaging. - "repackaged/android/src/main/java/**/*.java", - "repackaged/okhttp/src/main/java/**/*.java", - "repackaged/okhttp-urlconnection/src/main/java/**/*.java", - "repackaged/okhttp-android-support/src/main/java/**/*.java", - "repackaged/okio/okio/src/main/java/**/*.java", - ], - libs: [ - "conscrypt.module.intra.core.api", - ], - }, - host: { - srcs: [ - "okhttp/src/main/java/**/*.java", - "okhttp-urlconnection/src/main/java/**/*.java", - "okio/okio/src/main/java/**/*.java", - ":okhttp_version.java", - ], - libs: [ - "okhttp-android-util-log", - ], - }, - }, hostdex: true, installable: true, - system_modules: "core-all-system-modules", sdk_version: "none", + system_modules: "core-all-system-modules", + libs: [ + "conscrypt.module.intra.core.api", + ], java_version: "1.7", apex_available: [ + "com.android.art", "com.android.art.debug", - "com.android.art.release", ], + min_sdk_version: "31", +} + +// Java library for use on host, e.g. by robolectric. +java_library { + name: "okhttp-for-host", + visibility: [ + "//art/build/sdk", + "//external/robolectric-shadows", + ], + static_libs: [ + "okhttp", + ], + sdk_version: "none", + system_modules: "none", +} + +// Java Library for both Host and Android that does not use the repackaged okhttp libraries +// (com.android.okhttp) and instead uses the original (com.squareup.okhttp) packages. +// This should not end up on the bootclasspath and instead should only be used to build +// third-party or unbundled applications or libraries that require OkHttp. +java_library { + name: "okhttp-norepackage", + host_supported: true, + + visibility: [ + "//art/build/sdk", + "//external/grpc-grpc-java/okhttp", + ], + + srcs: [ + "okhttp/src/main/java/**/*.java", + "okhttp-urlconnection/src/main/java/**/*.java", + "okio/okio/src/main/java/**/*.java", + ":okhttp_version.java", + ], + + target: { + host: { + libs: [ + "okhttp-android-util-log", + ], + }, + }, + + installable: true, + sdk_version: "current", } // Generate Version.java based on the version number from pom.xml. diff --git a/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java b/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java index a7a5eba..0a25b88 100644 --- a/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java +++ b/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java @@ -16,7 +16,15 @@ package com.android.okhttp.internalandroidapi; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + +import android.annotation.SystemApi; + import com.android.okhttp.internalandroidapi.HasCacheHolder.CacheHolder; + +import libcore.util.NonNull; +import libcore.util.Nullable; + import com.squareup.okhttp.Cache; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; @@ -38,14 +46,21 @@ import java.util.Map; * classes appearing on method signatures. * @hide */ -@libcore.api.CorePlatformApi +@SystemApi(client = MODULE_LIBRARIES) +@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public final class AndroidResponseCacheAdapter { private final CacheHolder cacheHolder; private final Cache okHttpCache; - @libcore.api.CorePlatformApi - public AndroidResponseCacheAdapter(CacheHolder cacheHolder) { + /** + * Creates an instance from {@link CacheHolder} + * + * @hide + */ + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public AndroidResponseCacheAdapter(@NonNull CacheHolder cacheHolder) { this.cacheHolder = cacheHolder; // Avoid one level of dereferencing by storing the reference to the OkHttp cache for later. this.okHttpCache = cacheHolder.getCache(); @@ -54,19 +69,25 @@ public final class AndroidResponseCacheAdapter { /** * Returns the {@link CacheHolder} associated with this instance and can be used by OkHttp * internal code to obtain the underlying OkHttp Cache object. + * + * @hide */ - @libcore.api.CorePlatformApi - public CacheHolder getCacheHolder() { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public @NonNull CacheHolder getCacheHolder() { return cacheHolder; } /** * Used to implement {@link java.net.ResponseCache#get(URI, String, Map)}. See that method for * details. + * + * @hide */ - @libcore.api.CorePlatformApi - public CacheResponse get(URI uri, String requestMethod, - Map<String, List<String>> requestHeaders) throws IOException { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public @Nullable CacheResponse get(@NonNull URI uri, @NonNull String requestMethod, + @Nullable Map<String, List<String>> requestHeaders) throws IOException { Request okRequest = JavaApiConverter.createOkRequest(uri, requestMethod, requestHeaders); Response okResponse = okHttpCache.internalCache.get(okRequest); if (okResponse == null) { @@ -78,9 +99,13 @@ public final class AndroidResponseCacheAdapter { /** * Used to implement {@link java.net.ResponseCache#put(URI, URLConnection)}. See that method for * details. + * + * @hide */ - @libcore.api.CorePlatformApi - public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public @Nullable CacheRequest put(@NonNull URI uri, @NonNull URLConnection urlConnection) + throws IOException { Response okResponse = JavaApiConverter.createOkResponseForCachePut(uri, urlConnection); if (okResponse == null) { // The URLConnection is not cacheable or could not be converted. Stop. @@ -98,8 +123,11 @@ public final class AndroidResponseCacheAdapter { * Returns the number of bytes currently being used to store the values in * this cache. This may be greater than the {@link #getMaxSize()} if a background * deletion is pending. IOException is thrown if the size cannot be determined. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public long getSize() throws IOException { return okHttpCache.getSize(); } @@ -107,8 +135,11 @@ public final class AndroidResponseCacheAdapter { /** * Returns the maximum number of bytes that this cache should use to store * its data. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public long getMaxSize() { return okHttpCache.getMaxSize(); } @@ -117,8 +148,11 @@ public final class AndroidResponseCacheAdapter { * Force buffered operations to the filesystem. This ensures that responses * written to the cache will be available the next time the cache is opened, * even if this process is killed. IOException is thrown if the flush fails. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public void flush() throws IOException { okHttpCache.flush(); } @@ -126,8 +160,11 @@ public final class AndroidResponseCacheAdapter { /** * Returns the number of HTTP requests that required the network to either * supply a response or validate a locally cached response. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public int getNetworkCount() { return okHttpCache.getNetworkCount(); } @@ -136,8 +173,11 @@ public final class AndroidResponseCacheAdapter { * Returns the number of HTTP requests whose response was provided by the * cache. This may include conditional {@code GET} requests that were * validated over the network. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public int getHitCount() { return okHttpCache.getHitCount(); } @@ -146,14 +186,22 @@ public final class AndroidResponseCacheAdapter { * Returns the total number of HTTP requests that were made. This includes * both client requests and requests that were made on the client's behalf * to handle a redirects and retries. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public int getRequestCount() { return okHttpCache.getRequestCount(); } - /** Closes this cache. Stored values will remain on the filesystem. */ - @libcore.api.CorePlatformApi + /** + * Closes this cache. Stored values will remain on the filesystem. + * + * @hide + */ + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public void close() throws IOException { okHttpCache.close(); } @@ -162,8 +210,11 @@ public final class AndroidResponseCacheAdapter { * Closes the cache and deletes all of its stored values. This will delete * all files in the cache directory including files that weren't created by * the cache. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public void delete() throws IOException { okHttpCache.delete(); } diff --git a/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java b/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java index 6558dfe..41c623f 100644 --- a/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java +++ b/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java @@ -24,12 +24,12 @@ import java.util.List; * A domain name service that resolves IP addresses for host names. * @hide */ -@libcore.api.CorePlatformApi public interface Dns { /** * Returns the IP addresses of {@code hostname}, in the order they should * be attempted. + * + * @hide */ - @libcore.api.CorePlatformApi List<InetAddress> lookup(String hostname) throws UnknownHostException; } diff --git a/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java b/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java index e990af4..6341b5f 100644 --- a/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java +++ b/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java @@ -16,6 +16,12 @@ package com.android.okhttp.internalandroidapi; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + +import android.annotation.SystemApi; + +import libcore.util.NonNull; + import com.squareup.okhttp.Cache; import java.io.File; @@ -24,21 +30,26 @@ import java.io.File; * An interface used to indicate a class can return a {@link CacheHolder} object. * @hide */ -@libcore.api.CorePlatformApi +@SystemApi(client = MODULE_LIBRARIES) +@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public interface HasCacheHolder { /** * Returns the {@link CacheHolder} object. + * + * @hide */ - @libcore.api.CorePlatformApi - CacheHolder getCacheHolder(); + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + @NonNull CacheHolder getCacheHolder(); /** * A holder for an OkHttp internal Cache object. This class exists as an opaque layer over * OkHttp internal classes. * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) final class CacheHolder { private final Cache okHttpCache; @@ -68,9 +79,12 @@ public interface HasCacheHolder { * * @param directory a writable directory * @param maxSizeBytes the maximum number of bytes this cache should use to store + * + * @hide */ - @libcore.api.CorePlatformApi - public static CacheHolder create(File directory, long maxSizeBytes) { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public static @NonNull CacheHolder create(@NonNull File directory, long maxSizeBytes) { Cache cache = new Cache(directory, maxSizeBytes); return new CacheHolder(cache); } @@ -78,9 +92,12 @@ public interface HasCacheHolder { /** * Returns true if the arguments supplied would result in an equivalent cache to this one * being created if they were passed to {@link #create(File, long)}. + * + * @hide */ - @libcore.api.CorePlatformApi - public boolean isEquivalent(File directory, long maxSizeBytes) { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public boolean isEquivalent(@NonNull File directory, long maxSizeBytes) { return (okHttpCache.getDirectory().equals(directory) && okHttpCache.getMaxSize() == maxSizeBytes && !okHttpCache.isClosed()); diff --git a/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java b/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java index a7d0bbf..eb223c4 100644 --- a/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java +++ b/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java @@ -51,27 +51,27 @@ import javax.net.SocketFactory; * * @hide */ -@libcore.api.CorePlatformApi public final class HttpURLConnectionFactory { private ConnectionPool connectionPool; private com.squareup.okhttp.Dns dns; - @libcore.api.CorePlatformApi + /** @hide */ public HttpURLConnectionFactory() { } /** * Sets a new ConnectionPool, specific to this URLFactory and not shared with * any other connections, with the given configuration. + * + * @hide */ - @libcore.api.CorePlatformApi public void setNewConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit) { this.connectionPool = new ConnectionPool(maxIdleConnections, keepAliveDuration, timeUnit); } - @libcore.api.CorePlatformApi + /** @hide */ public void setDns(Dns dns) { Objects.requireNonNull(dns); this.dns = new DnsAdapter(dns); @@ -79,6 +79,8 @@ public final class HttpURLConnectionFactory { /** * Opens a connection that uses the system default proxy settings and SocketFactory. + * + * @hide */ public URLConnection openConnection(URL url) throws IOException { return internalOpenConnection(url, null /* socketFactory */, null /* proxy */); @@ -87,6 +89,8 @@ public final class HttpURLConnectionFactory { /** * Opens a connection that uses the system default SocketFactory and the specified * proxy settings. + * + * @hide */ public URLConnection openConnection(URL url, Proxy proxy) throws IOException { Objects.requireNonNull(proxy); @@ -96,6 +100,8 @@ public final class HttpURLConnectionFactory { /** * Opens a connection that uses the specified SocketFactory and the system default * proxy settings. + * + * @hide */ public URLConnection openConnection(URL url, SocketFactory socketFactory) throws IOException { Objects.requireNonNull(socketFactory); @@ -105,8 +111,9 @@ public final class HttpURLConnectionFactory { /** * Opens a connection using the specified SocketFactory and the specified proxy * settings, overriding any system wide configuration. + * + * @hide */ - @libcore.api.CorePlatformApi public URLConnection openConnection(URL url, SocketFactory socketFactory, Proxy proxy) throws IOException { Objects.requireNonNull(socketFactory); @@ -148,6 +155,8 @@ public final class HttpURLConnectionFactory { /** * Adapts a {@link Dns} as a {@link com.squareup.okhttp.Dns}. + * + * @hide */ static final class DnsAdapter implements com.squareup.okhttp.Dns { private final Dns adaptee; diff --git a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java index b7f5002..1c5c6e6 100644 --- a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java +++ b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/AndroidResponseCacheAdapter.java @@ -17,7 +17,15 @@ package com.android.okhttp.internalandroidapi; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + +import android.annotation.SystemApi; + import com.android.okhttp.internalandroidapi.HasCacheHolder.CacheHolder; + +import libcore.util.NonNull; +import libcore.util.Nullable; + import com.android.okhttp.Cache; import com.android.okhttp.Request; import com.android.okhttp.Response; @@ -40,14 +48,21 @@ import java.util.Map; * @hide * @hide This class is not part of the Android public SDK API */ -@libcore.api.CorePlatformApi +@SystemApi(client = MODULE_LIBRARIES) +@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public final class AndroidResponseCacheAdapter { private final CacheHolder cacheHolder; private final Cache okHttpCache; - @libcore.api.CorePlatformApi - public AndroidResponseCacheAdapter(CacheHolder cacheHolder) { + /** + * Creates an instance from {@link CacheHolder} + * + * @hide + */ + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public AndroidResponseCacheAdapter(@NonNull CacheHolder cacheHolder) { this.cacheHolder = cacheHolder; // Avoid one level of dereferencing by storing the reference to the OkHttp cache for later. this.okHttpCache = cacheHolder.getCache(); @@ -56,19 +71,25 @@ public final class AndroidResponseCacheAdapter { /** * Returns the {@link CacheHolder} associated with this instance and can be used by OkHttp * internal code to obtain the underlying OkHttp Cache object. + * + * @hide */ - @libcore.api.CorePlatformApi - public CacheHolder getCacheHolder() { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public @NonNull CacheHolder getCacheHolder() { return cacheHolder; } /** * Used to implement {@link java.net.ResponseCache#get(URI, String, Map)}. See that method for * details. + * + * @hide */ - @libcore.api.CorePlatformApi - public CacheResponse get(URI uri, String requestMethod, - Map<String, List<String>> requestHeaders) throws IOException { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public @Nullable CacheResponse get(@NonNull URI uri, @NonNull String requestMethod, + @Nullable Map<String, List<String>> requestHeaders) throws IOException { Request okRequest = JavaApiConverter.createOkRequest(uri, requestMethod, requestHeaders); Response okResponse = okHttpCache.internalCache.get(okRequest); if (okResponse == null) { @@ -80,9 +101,13 @@ public final class AndroidResponseCacheAdapter { /** * Used to implement {@link java.net.ResponseCache#put(URI, URLConnection)}. See that method for * details. + * + * @hide */ - @libcore.api.CorePlatformApi - public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public @Nullable CacheRequest put(@NonNull URI uri, @NonNull URLConnection urlConnection) + throws IOException { Response okResponse = JavaApiConverter.createOkResponseForCachePut(uri, urlConnection); if (okResponse == null) { // The URLConnection is not cacheable or could not be converted. Stop. @@ -100,8 +125,11 @@ public final class AndroidResponseCacheAdapter { * Returns the number of bytes currently being used to store the values in * this cache. This may be greater than the {@link #getMaxSize()} if a background * deletion is pending. IOException is thrown if the size cannot be determined. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public long getSize() throws IOException { return okHttpCache.getSize(); } @@ -109,8 +137,11 @@ public final class AndroidResponseCacheAdapter { /** * Returns the maximum number of bytes that this cache should use to store * its data. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public long getMaxSize() { return okHttpCache.getMaxSize(); } @@ -119,8 +150,11 @@ public final class AndroidResponseCacheAdapter { * Force buffered operations to the filesystem. This ensures that responses * written to the cache will be available the next time the cache is opened, * even if this process is killed. IOException is thrown if the flush fails. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public void flush() throws IOException { okHttpCache.flush(); } @@ -128,8 +162,11 @@ public final class AndroidResponseCacheAdapter { /** * Returns the number of HTTP requests that required the network to either * supply a response or validate a locally cached response. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public int getNetworkCount() { return okHttpCache.getNetworkCount(); } @@ -138,8 +175,11 @@ public final class AndroidResponseCacheAdapter { * Returns the number of HTTP requests whose response was provided by the * cache. This may include conditional {@code GET} requests that were * validated over the network. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public int getHitCount() { return okHttpCache.getHitCount(); } @@ -148,14 +188,22 @@ public final class AndroidResponseCacheAdapter { * Returns the total number of HTTP requests that were made. This includes * both client requests and requests that were made on the client's behalf * to handle a redirects and retries. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public int getRequestCount() { return okHttpCache.getRequestCount(); } - /** Closes this cache. Stored values will remain on the filesystem. */ - @libcore.api.CorePlatformApi + /** + * Closes this cache. Stored values will remain on the filesystem. + * + * @hide + */ + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public void close() throws IOException { okHttpCache.close(); } @@ -164,8 +212,11 @@ public final class AndroidResponseCacheAdapter { * Closes the cache and deletes all of its stored values. This will delete * all files in the cache directory including files that weren't created by * the cache. + * + * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public void delete() throws IOException { okHttpCache.delete(); } diff --git a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java index 859ea80..4da9d8f 100644 --- a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java +++ b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/Dns.java @@ -26,12 +26,12 @@ import java.util.List; * @hide * @hide This class is not part of the Android public SDK API */ -@libcore.api.CorePlatformApi public interface Dns { /** * Returns the IP addresses of {@code hostname}, in the order they should * be attempted. + * + * @hide */ - @libcore.api.CorePlatformApi List<InetAddress> lookup(String hostname) throws UnknownHostException; } diff --git a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java index aa90bf3..67ae1ca 100644 --- a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java +++ b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HasCacheHolder.java @@ -17,6 +17,12 @@ package com.android.okhttp.internalandroidapi; +import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; + +import android.annotation.SystemApi; + +import libcore.util.NonNull; + import com.android.okhttp.Cache; import java.io.File; @@ -26,21 +32,26 @@ import java.io.File; * @hide * @hide This class is not part of the Android public SDK API */ -@libcore.api.CorePlatformApi +@SystemApi(client = MODULE_LIBRARIES) +@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) public interface HasCacheHolder { /** * Returns the {@link CacheHolder} object. + * + * @hide */ - @libcore.api.CorePlatformApi - CacheHolder getCacheHolder(); + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + @NonNull CacheHolder getCacheHolder(); /** * A holder for an OkHttp internal Cache object. This class exists as an opaque layer over * OkHttp internal classes. * @hide */ - @libcore.api.CorePlatformApi + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) final class CacheHolder { private final Cache okHttpCache; @@ -70,9 +81,12 @@ public interface HasCacheHolder { * * @param directory a writable directory * @param maxSizeBytes the maximum number of bytes this cache should use to store + * + * @hide */ - @libcore.api.CorePlatformApi - public static CacheHolder create(File directory, long maxSizeBytes) { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public static @NonNull CacheHolder create(@NonNull File directory, long maxSizeBytes) { Cache cache = new Cache(directory, maxSizeBytes); return new CacheHolder(cache); } @@ -80,9 +94,12 @@ public interface HasCacheHolder { /** * Returns true if the arguments supplied would result in an equivalent cache to this one * being created if they were passed to {@link #create(File, long)}. + * + * @hide */ - @libcore.api.CorePlatformApi - public boolean isEquivalent(File directory, long maxSizeBytes) { + @SystemApi(client = MODULE_LIBRARIES) + @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) + public boolean isEquivalent(@NonNull File directory, long maxSizeBytes) { return (okHttpCache.getDirectory().equals(directory) && okHttpCache.getMaxSize() == maxSizeBytes && !okHttpCache.isClosed()); diff --git a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java index 7f83ee5..f4403b8 100644 --- a/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java +++ b/repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/HttpURLConnectionFactory.java @@ -53,27 +53,27 @@ import javax.net.SocketFactory; * @hide * @hide This class is not part of the Android public SDK API */ -@libcore.api.CorePlatformApi public final class HttpURLConnectionFactory { private ConnectionPool connectionPool; private com.android.okhttp.Dns dns; - @libcore.api.CorePlatformApi + /** @hide */ public HttpURLConnectionFactory() { } /** * Sets a new ConnectionPool, specific to this URLFactory and not shared with * any other connections, with the given configuration. + * + * @hide */ - @libcore.api.CorePlatformApi public void setNewConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit) { this.connectionPool = new ConnectionPool(maxIdleConnections, keepAliveDuration, timeUnit); } - @libcore.api.CorePlatformApi + /** @hide */ public void setDns(Dns dns) { Objects.requireNonNull(dns); this.dns = new DnsAdapter(dns); @@ -81,6 +81,8 @@ public final class HttpURLConnectionFactory { /** * Opens a connection that uses the system default proxy settings and SocketFactory. + * + * @hide */ public URLConnection openConnection(URL url) throws IOException { return internalOpenConnection(url, null /* socketFactory */, null /* proxy */); @@ -89,6 +91,8 @@ public final class HttpURLConnectionFactory { /** * Opens a connection that uses the system default SocketFactory and the specified * proxy settings. + * + * @hide */ public URLConnection openConnection(URL url, Proxy proxy) throws IOException { Objects.requireNonNull(proxy); @@ -98,6 +102,8 @@ public final class HttpURLConnectionFactory { /** * Opens a connection that uses the specified SocketFactory and the system default * proxy settings. + * + * @hide */ public URLConnection openConnection(URL url, SocketFactory socketFactory) throws IOException { Objects.requireNonNull(socketFactory); @@ -107,8 +113,9 @@ public final class HttpURLConnectionFactory { /** * Opens a connection using the specified SocketFactory and the specified proxy * settings, overriding any system wide configuration. + * + * @hide */ - @libcore.api.CorePlatformApi public URLConnection openConnection(URL url, SocketFactory socketFactory, Proxy proxy) throws IOException { Objects.requireNonNull(socketFactory); @@ -150,6 +157,8 @@ public final class HttpURLConnectionFactory { /** * Adapts a {@link Dns} as a {@link com.android.okhttp.Dns}. + * + * @hide */ static final class DnsAdapter implements com.android.okhttp.Dns { private final Dns adaptee; |