am 69c69f15: am a89ee93f: Merge "Stop WifiManagerTest from disabling current network." into froyo

* commit '69c69f156bebe834cfbb13eb7f93dc9e25ee723b':
  Stop WifiManagerTest from disabling current network.
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index edcea9a..cfe0872 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -97,67 +97,6 @@
         assertFalse(ConnectivityManager.isNetworkTypeValid(-1));
     }
 
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getNetworkPreference",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.SUFFICIENT,
-            method = "setNetworkPreference",
-            args = {int.class}
-        )
-    })
-    public void testAccessNetworkPreference() {
-        int initialSetting = mCm.getNetworkPreference();
-
-        // Changing the network preference requires android.permission.WRITE_SECURE_SETTINGS,
-        // which is only available to signed or system applications.
-
-        // Setting the same preference that is already set is a no-op and does not throw
-        // a SecurityException.
-        mCm.setNetworkPreference(initialSetting);
-        assertEquals(initialSetting, mCm.getNetworkPreference());
-
-        // find a valid setting that is different from the initial setting
-        int validSetting = -1;
-        NetworkInfo[] ni = mCm.getAllNetworkInfo();
-        for (NetworkInfo n : ni) {
-            int type = n.getType();
-            if (type != initialSetting) {
-                validSetting = type;
-                break;
-            }
-        }
-        if (validSetting >= 0) {
-            try {
-                mCm.setNetworkPreference(validSetting);
-                fail("Trying to change the network preference should throw SecurityException");
-            } catch (SecurityException expected) {
-                // expected
-            }
-        }
-
-        // find an invalid setting
-        int invalidSetting = -1;
-        for (int i = 0; i < 10; i++) {
-            if (!ConnectivityManager.isNetworkTypeValid(i)) {
-                invalidSetting = i;
-                break;
-            }
-        }
-        if (invalidSetting >= 0) {
-            // illegal setting should be ignored
-            mCm.setNetworkPreference(invalidSetting);
-            assertEquals(initialSetting, mCm.getNetworkPreference());
-        }
-
-        // illegal setting should be ignored
-        mCm.setNetworkPreference(-1);
-        assertEquals(initialSetting, mCm.getNetworkPreference());
-    }
-
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         notes = "Test getAllNetworkInfo().",
diff --git a/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java b/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
index 6cd5d6f..258ac4d 100644
--- a/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
+++ b/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
@@ -21,6 +21,7 @@
 import java.net.Socket;
 
 import javax.net.SocketFactory;
+import javax.net.ssl.SSLPeerUnverifiedException;
 
 import android.net.SSLCertificateSocketFactory;
 import android.test.AndroidTestCase;
@@ -141,4 +142,73 @@
         // The socket level is invalid.
     }
 
+    // a host and port that are expected to be available but have
+    // a cert with a different CN, in this case CN=mtalk.google.com
+    private static String TEST_CREATE_SOCKET_HOST = "mobile-gtalk.l.google.com";
+    private static int TEST_CREATE_SOCKET_PORT = 5228;
+
+    /**
+     * b/2807618 Make sure that hostname verifcation in cases were it
+     * is documented to be included by various
+     * SSLCertificateSocketFactory.createSocket messages.
+     *
+     * NOTE: Test will fail if external server is not available.
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "createSocket",
+        args = {String.class, int.class}
+    )
+    public void test_createSocket_simple() throws Exception {
+        try {
+            mFactory.createSocket(TEST_CREATE_SOCKET_HOST, TEST_CREATE_SOCKET_PORT);
+            fail();
+        } catch (SSLPeerUnverifiedException expected) {
+            // expected
+        }
+    }
+
+    /**
+     * b/2807618 Make sure that hostname verifcation in cases were it
+     * is documented to be included by various
+     * SSLCertificateSocketFactory.createSocket messages.
+     *
+     * NOTE: Test will fail if external server is not available.
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "createSocket",
+        args = {Socket.class, String.class, int.class, boolean.class}
+    )
+    public void test_createSocket_wrapping() throws Exception {
+        try {
+            Socket underlying = new Socket(TEST_CREATE_SOCKET_HOST, TEST_CREATE_SOCKET_PORT);
+            mFactory.createSocket(
+                    underlying, TEST_CREATE_SOCKET_HOST, TEST_CREATE_SOCKET_PORT, true);
+            fail();
+        } catch (SSLPeerUnverifiedException expected) {
+            // expected
+        }
+    }
+
+    /**
+     * b/2807618 Make sure that hostname verifcation in cases were it
+     * is documented to be included by various
+     * SSLCertificateSocketFactory.createSocket messages.
+     *
+     * NOTE: Test will fail if external server is not available.
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "createSocket",
+        args = {String.class, int.class, InetAddress.class, int.class}
+    )
+    public void test_createSocket_bind() throws Exception {
+        try {
+            mFactory.createSocket(TEST_CREATE_SOCKET_HOST, TEST_CREATE_SOCKET_PORT, null, 0);
+            fail();
+        } catch (SSLPeerUnverifiedException expected) {
+            // expected
+        }
+    }
 }