diff options
author | Xia Wang <xiaw@google.com> | 2013-09-10 18:28:16 -0700 |
---|---|---|
committer | Xia Wang <xiaw@google.com> | 2013-09-11 14:44:30 -0700 |
commit | 0076729d3880f6c71a607af42e06be02c7bda542 (patch) | |
tree | c3972432c447541aaceff7b53dc5b706dbb86dd5 /core/tests/ConnectivityManagerTest | |
parent | 706113fa2a82e5b613b8555120025b8472ffcbf3 (diff) | |
download | frameworks_base-0076729d3880f6c71a607af42e06be02c7bda542.zip frameworks_base-0076729d3880f6c71a607af42e06be02c7bda542.tar.gz frameworks_base-0076729d3880f6c71a607af42e06be02c7bda542.tar.bz2 |
Use setAirplaneMode() API for Connectivity Manager tests
Change-Id: I2e35c58e4101b6b5fe9efdb5adad922402d38b6f
Diffstat (limited to 'core/tests/ConnectivityManagerTest')
3 files changed, 11 insertions, 22 deletions
diff --git a/core/tests/ConnectivityManagerTest/AndroidManifest.xml b/core/tests/ConnectivityManagerTest/AndroidManifest.xml index 7e0202e..b76c8be 100644 --- a/core/tests/ConnectivityManagerTest/AndroidManifest.xml +++ b/core/tests/ConnectivityManagerTest/AndroidManifest.xml @@ -79,6 +79,8 @@ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> + <!-- This permission is added for API call setAirplaneMode() in ConnectivityManager --> + <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.DEVICE_POWER" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java index 463e999..a0cb1bb 100644 --- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java +++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java @@ -651,19 +651,6 @@ public class ConnectivityManagerTestActivity extends Activity { } catch (InterruptedException e) {} } - /** - * Set airplane mode - */ - public void setAirplaneMode(Context context, boolean enableAM) { - //set the airplane mode - Settings.Global.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, - enableAM ? 1 : 0); - // Post the intent - Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); - intent.putExtra("state", enableAM); - context.sendBroadcastAsUser(intent, UserHandle.ALL); - } - protected static String convertToQuotedString(String string) { return "\"" + string + "\""; } @@ -694,7 +681,7 @@ public class ConnectivityManagerTestActivity extends Activity { //A thread to set the device into airplane mode then turn on wifi. Thread setDeviceWifiAndAirplaneThread = new Thread(new Runnable() { public void run() { - setAirplaneMode(mContext, true); + mCM.setAirplaneMode(true); connectToWifi(mPowerSsid); } }); diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java index 3111489..729e1d2 100644 --- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java +++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java @@ -62,7 +62,7 @@ public class ConnectivityManagerMobileTest extends if (Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(), Settings.Global.AIRPLANE_MODE_ON) == 1) { log("airplane is not disabled, disable it."); - cmActivity.setAirplaneMode(getInstrumentation().getContext(), false); + cmActivity.mCM.setAirplaneMode(false); } if (!mWifiOnlyFlag) { @@ -87,7 +87,7 @@ public class ConnectivityManagerMobileTest extends if (Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(), Settings.Global.AIRPLANE_MODE_ON) == 1) { log("disable airplane mode if it is enabled"); - cmActivity.setAirplaneMode(getInstrumentation().getContext(), false); + cmActivity.mCM.setAirplaneMode(false); } super.tearDown(); } @@ -344,7 +344,7 @@ public class ConnectivityManagerMobileTest extends // Enable airplane mode log("Enable airplane mode"); - cmActivity.setAirplaneMode(getInstrumentation().getContext(), true); + cmActivity.mCM.setAirplaneMode(true); sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT); networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_WIFI); @@ -370,7 +370,7 @@ public class ConnectivityManagerMobileTest extends NetworkState.DO_NOTHING, State.DISCONNECTED); // disable airplane mode - cmActivity.setAirplaneMode(getInstrumentation().getContext(), false); + cmActivity.mCM.setAirplaneMode(false); assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED, ConnectivityManagerTestActivity.LONG_TIMEOUT)); @@ -400,7 +400,7 @@ public class ConnectivityManagerMobileTest extends assertNotNull("SSID is null", mTestAccessPoint); // Eanble airplane mode log("Enable airplane mode"); - cmActivity.setAirplaneMode(getInstrumentation().getContext(), true); + cmActivity.mCM.setAirplaneMode(true); NetworkInfo networkInfo; if (!mWifiOnlyFlag) { @@ -437,7 +437,7 @@ public class ConnectivityManagerMobileTest extends assertTrue("state validation failed", false); } } - cmActivity.setAirplaneMode(getInstrumentation().getContext(), false); + cmActivity.mCM.setAirplaneMode(false); } // Test case 7: test connectivity while transit from Wifi->AM->Wifi @@ -463,7 +463,7 @@ public class ConnectivityManagerMobileTest extends } // Enable airplane mode without clearing Wifi - cmActivity.setAirplaneMode(getInstrumentation().getContext(), true); + cmActivity.mCM.setAirplaneMode(true); assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED, ConnectivityManagerTestActivity.LONG_TIMEOUT)); @@ -481,7 +481,7 @@ public class ConnectivityManagerMobileTest extends networkInfo.getState(), NetworkState.TO_CONNECTION, State.CONNECTED); // Disable airplane mode - cmActivity.setAirplaneMode(getInstrumentation().getContext(), false); + cmActivity.mCM.setAirplaneMode(false); assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED, ConnectivityManagerTestActivity.WIFI_CONNECTION_TIMEOUT)); |