From 913b99435035eca3be12eb31180dca54b2c79957 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Tue, 9 Dec 2014 15:48:50 -0800 Subject: [PATCH] Skip testDnsWorks if the active network for watch is proxy. Bug: 18625962 Change-Id: I56dacf8d93c1557b44eaf80fbc80eb6a596a9436 --- .../cts/net/src/android/net/cts/DnsTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/cts/net/src/android/net/cts/DnsTest.java b/tests/cts/net/src/android/net/cts/DnsTest.java index 879a962233..0377d048e7 100644 --- a/tests/cts/net/src/android/net/cts/DnsTest.java +++ b/tests/cts/net/src/android/net/cts/DnsTest.java @@ -16,6 +16,10 @@ package android.net.cts; +import android.content.Context; +import android.content.pm.PackageManager; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.os.SystemClock; import android.test.AndroidTestCase; import android.util.Log; @@ -34,6 +38,7 @@ public class DnsTest extends AndroidTestCase { private static final boolean DBG = false; private static final String TAG = "DnsTest"; + private static final String PROXY_NETWORK_TYPE = "PROXY"; /** * @return true on success @@ -71,6 +76,14 @@ public class DnsTest extends AndroidTestCase { // We should have at least one of the addresses to connect! assertTrue(foundV4 || foundV6); + // Skip the rest of the test if the active network for watch is PROXY. + // TODO: Check NetworkInfo type in addition to type name once ag/601257 is merged. + if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH) + && activeNetworkInfoIsProxy()) { + Log.i(TAG, "Skipping test because the active network type name is PROXY."); + return; + } + try { addrs = InetAddress.getAllByName("ipv6.google.com"); } catch (UnknownHostException e) {} @@ -241,4 +254,15 @@ public class DnsTest extends AndroidTestCase { Log.e(TAG, "bad URL in testDnsPerf: " + e.toString()); } } + + private boolean activeNetworkInfoIsProxy() { + ConnectivityManager cm = (ConnectivityManager) + getContext().getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo info = cm.getActiveNetworkInfo(); + if (PROXY_NETWORK_TYPE.equals(info.getTypeName())) { + return true; + } + + return false; + } }