diff --git a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java
index 06e6ad8ccf..3a824e23fd 100644
--- a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java
+++ b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java
@@ -36,14 +36,20 @@ import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.MethodDescriptor;
import io.grpc.internal.GrpcUtil;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSocketFactory;
/**
* Builds a {@link ManagedChannel} that, when provided with a {@link Context}, will automatically
* monitor the Android device's network state to smoothly handle intermittent network failures.
*
+ *
Currently only compatible with gRPC's OkHttp transport, which must be available at runtime.
+ *
*
Requires the Android ACCESS_NETWORK_STATE permission.
*
* @since 1.12.0
@@ -96,6 +102,56 @@ public final class AndroidChannelBuilder extends ForwardingChannelBuilder delegate() {
return delegateBuilder;
diff --git a/android/src/test/java/io/grpc/android/AndroidChannelBuilderTest.java b/android/src/test/java/io/grpc/android/AndroidChannelBuilderTest.java
index faf998f724..0477c34a01 100644
--- a/android/src/test/java/io/grpc/android/AndroidChannelBuilderTest.java
+++ b/android/src/test/java/io/grpc/android/AndroidChannelBuilderTest.java
@@ -31,8 +31,18 @@ import io.grpc.CallOptions;
import io.grpc.ClientCall;
import io.grpc.ManagedChannel;
import io.grpc.MethodDescriptor;
+import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -86,6 +96,39 @@ public final class AndroidChannelBuilderTest {
AndroidChannelBuilder.forTarget("target");
}
+ @Test
+ public void transportExecutor() {
+ AndroidChannelBuilder.forTarget("target")
+ .transportExecutor(
+ new Executor() {
+ @Override
+ public void execute(Runnable r) {}
+ });
+ }
+
+ @Test
+ public void hostnameVerifier() {
+ AndroidChannelBuilder.forTarget("target")
+ .hostnameVerifier(
+ new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ }
+
+ @Test
+ public void sslSocketFactory() {
+ AndroidChannelBuilder.forTarget("target")
+ .sslSocketFactory((SSLSocketFactory) SSLSocketFactory.getDefault());
+ }
+
+ @Test
+ public void scheduledExecutorService() {
+ AndroidChannelBuilder.forTarget("target").scheduledExecutorService(new ScheduledExecutorImpl());
+ }
+
@Test
@Config(sdk = 23)
public void nullContextDoesNotThrow_api23() {
@@ -370,4 +413,94 @@ public final class AndroidChannelBuilderTest {
enterIdleCount++;
}
}
+
+ private static class ScheduledExecutorImpl implements ScheduledExecutorService {
+ @Override
+ public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ScheduledFuture> schedule(Runnable cmd, long delay, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ScheduledFuture> scheduleAtFixedRate(
+ Runnable command, long initialDelay, long period, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ScheduledFuture> scheduleWithFixedDelay(
+ Runnable command, long initialDelay, long delay, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean awaitTermination(long timeout, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List> invokeAll(Collection extends Callable> tasks) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List> invokeAll(
+ Collection extends Callable> tasks, long timeout, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T invokeAny(Collection extends Callable> tasks) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T invokeAny(Collection extends Callable> tasks, long timeout, TimeUnit unit) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void shutdown() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List shutdownNow() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Future submit(Callable task) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Future> submit(Runnable task) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Future submit(Runnable task, T result) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void execute(Runnable command) {
+ throw new UnsupportedOperationException();
+ }
+ }
}