diff --git a/android-interop-testing/app/src/androidTest/AndroidManifest.xml b/android-interop-testing/app/src/androidTest/AndroidManifest.xml
new file mode 100644
index 0000000000..98447551fa
--- /dev/null
+++ b/android-interop-testing/app/src/androidTest/AndroidManifest.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java b/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java
index a7adf4b2df..f156025da5 100644
--- a/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java
+++ b/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java
@@ -19,6 +19,7 @@ package io.grpc.android.integrationtest;
import static junit.framework.Assert.assertEquals;
import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
@@ -31,13 +32,14 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class InteropInstrumentationTest {
private static final int TIMEOUT_SECONDS = 10;
- private static String LOG_TAG = "GrpcInteropInstrumentationTest";
+ private static final String LOG_TAG = "GrpcInteropInstrumentationTest";
private String host;
private int port;
@@ -46,6 +48,12 @@ public class InteropInstrumentationTest {
private boolean useTestCa;
private String testCase;
+ // Ensures Looper is initialized for tests running on API level 15. Otherwise instantiating an
+ // AsyncTask throws an exception.
+ @Rule
+ public ActivityTestRule activityRule =
+ new ActivityTestRule(TesterActivity.class);
+
@Before
public void setUp() throws Exception {
host = InstrumentationRegistry.getArguments().getString("server_host", "10.0.2.2");
@@ -107,7 +115,6 @@ public class InteropInstrumentationTest {
new Listener() {
@Override
public void onComplete(String result) {
-
resultFuture.set(result);
}
};
diff --git a/android-interop-testing/app/src/main/AndroidManifest.xml b/android-interop-testing/app/src/main/AndroidManifest.xml
index 4e0409f33c..cb9f81e242 100644
--- a/android-interop-testing/app/src/main/AndroidManifest.xml
+++ b/android-interop-testing/app/src/main/AndroidManifest.xml
@@ -13,7 +13,8 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
- android:theme="@style/Base.V7.Theme.AppCompat.Light" >
+ android:theme="@style/Base.V7.Theme.AppCompat.Light"
+ android:name="android.support.multidex.MultiDexApplication" >
diff --git a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java
index 2ce2b1ab64..d1d181df28 100644
--- a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java
+++ b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java
@@ -67,7 +67,7 @@ final class InteropTask extends AsyncTask {
// Then print to the error message.
StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
- return "Failed... : " + t.getMessage() + "\n" + sw.toString();
+ return "Failed... : " + t.getMessage() + "\n" + sw;
} finally {
try {
tester.tearDown();
@@ -147,7 +147,7 @@ final class InteropTask extends AsyncTask {
}
}
- private class Tester extends AbstractInteropTest {
+ private static class Tester extends AbstractInteropTest {
private final ManagedChannel channel;
private final List interceptors;
diff --git a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterOkHttpChannelBuilder.java b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterOkHttpChannelBuilder.java
index e537eb7785..417df61096 100644
--- a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterOkHttpChannelBuilder.java
+++ b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterOkHttpChannelBuilder.java
@@ -16,15 +16,11 @@
package io.grpc.android.integrationtest;
-import android.annotation.TargetApi;
-import android.net.SSLCertificateSocketFactory;
-import android.os.Build;
import android.support.annotation.Nullable;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.okhttp.OkHttpChannelBuilder;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.security.KeyStore;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
@@ -74,37 +70,6 @@ class TesterOkHttpChannelBuilder {
return context.getSocketFactory();
}
- @TargetApi(14)
- private static SSLCertificateSocketFactory getSslCertificateSocketFactory(
- @Nullable InputStream testCa, String androidSocketFatoryTls) throws Exception {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH /* API level 14 */) {
- throw new RuntimeException(
- "android_socket_factory_tls doesn't work with API level less than 14.");
- }
- SSLCertificateSocketFactory factory = (SSLCertificateSocketFactory)
- SSLCertificateSocketFactory.getDefault(5000 /* Timeout in ms*/);
- // Use HTTP/2.0
- byte[] h2 = "h2".getBytes();
- byte[][] protocols = new byte[][]{h2};
- if (androidSocketFatoryTls.equals("alpn")) {
- Method setAlpnProtocols =
- factory.getClass().getDeclaredMethod("setAlpnProtocols", byte[][].class);
- setAlpnProtocols.invoke(factory, new Object[] { protocols });
- } else if (androidSocketFatoryTls.equals("npn")) {
- Method setNpnProtocols =
- factory.getClass().getDeclaredMethod("setNpnProtocols", byte[][].class);
- setNpnProtocols.invoke(factory, new Object[]{protocols});
- } else {
- throw new RuntimeException("Unknown protocol: " + androidSocketFatoryTls);
- }
-
- if (testCa != null) {
- factory.setTrustManagers(getTrustManagers(testCa));
- }
-
- return factory;
- }
-
private static TrustManager[] getTrustManagers(InputStream testCa) throws Exception {
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null);