Merge "Make Settings app not use cleartext network traffic."
This commit is contained in:
@@ -82,7 +82,8 @@
|
|||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:requiredForAllUsers="true"
|
android:requiredForAllUsers="true"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:allowBackup="false">
|
android:allowBackup="false"
|
||||||
|
android:usesCleartextTraffic="false">
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
|
|
||||||
|
@@ -754,7 +754,7 @@ public class RadioInfo extends Activity {
|
|||||||
HttpURLConnection urlConnection = null;
|
HttpURLConnection urlConnection = null;
|
||||||
try {
|
try {
|
||||||
// TODO: Hardcoded for now, make it UI configurable
|
// TODO: Hardcoded for now, make it UI configurable
|
||||||
URL url = new URL("http://www.google.com");
|
URL url = new URL("https://www.google.com");
|
||||||
urlConnection = (HttpURLConnection) url.openConnection();
|
urlConnection = (HttpURLConnection) url.openConnection();
|
||||||
if (urlConnection.getResponseCode() == 200) {
|
if (urlConnection.getResponseCode() == 200) {
|
||||||
mHttpClientTestResult = "Pass";
|
mHttpClientTestResult = "Pass";
|
||||||
|
@@ -396,7 +396,7 @@ public class WifiStatusTest extends Activity {
|
|||||||
HttpURLConnection urlConnection = null;
|
HttpURLConnection urlConnection = null;
|
||||||
try {
|
try {
|
||||||
// TODO: Hardcoded for now, make it UI configurable
|
// TODO: Hardcoded for now, make it UI configurable
|
||||||
URL url = new URL("http://www.google.com");
|
URL url = new URL("https://www.google.com");
|
||||||
urlConnection = (HttpURLConnection) url.openConnection();
|
urlConnection = (HttpURLConnection) url.openConnection();
|
||||||
if (urlConnection.getResponseCode() == 200) {
|
if (urlConnection.getResponseCode() == 200) {
|
||||||
mHttpClientTestResult = "Pass";
|
mHttpClientTestResult = "Pass";
|
||||||
|
@@ -24,6 +24,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.security.Credentials;
|
import android.security.Credentials;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
|
import android.security.NetworkSecurityPolicy;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import android.test.InstrumentationTestRunner;
|
import android.test.InstrumentationTestRunner;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
@@ -225,6 +226,13 @@ public class VpnTests extends InstrumentationTestCase {
|
|||||||
private String getIpAddress() {
|
private String getIpAddress() {
|
||||||
String ip = null;
|
String ip = null;
|
||||||
HttpURLConnection urlConnection = null;
|
HttpURLConnection urlConnection = null;
|
||||||
|
// TODO: Rewrite this test to use an HTTPS URL.
|
||||||
|
// Because this test uses cleartext HTTP, the network security policy of this app needs to
|
||||||
|
// be temporarily relaxed to permit such traffic.
|
||||||
|
NetworkSecurityPolicy networkSecurityPolicy = NetworkSecurityPolicy.getInstance();
|
||||||
|
boolean cleartextTrafficPermittedBeforeTest =
|
||||||
|
networkSecurityPolicy.isCleartextTrafficPermitted();
|
||||||
|
networkSecurityPolicy.setCleartextTrafficPermitted(true);
|
||||||
try {
|
try {
|
||||||
URL url = new URL(EXTERNAL_SERVER);
|
URL url = new URL(EXTERNAL_SERVER);
|
||||||
urlConnection = (HttpURLConnection) url.openConnection();
|
urlConnection = (HttpURLConnection) url.openConnection();
|
||||||
@@ -248,6 +256,7 @@ public class VpnTests extends InstrumentationTestCase {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.e(TAG, "exception while creating JSONObject: " + e.toString());
|
Log.e(TAG, "exception while creating JSONObject: " + e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
networkSecurityPolicy.setCleartextTrafficPermitted(cleartextTrafficPermittedBeforeTest);
|
||||||
if (urlConnection != null) {
|
if (urlConnection != null) {
|
||||||
urlConnection.disconnect();
|
urlConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user