summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKumar Anand <kumaranand@google.com>2018-06-01 00:12:40 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-06-01 00:12:40 -0700
commit42e89c9a6a1072b7618f65965265452fb9e938ba (patch)
treea60dfb3ef73acb77631dccc6768fde20e1d967de /tests
parent85f48681e87308405665dc8c458d3aa2ad4aa87d (diff)
parent6a4ab81c8842bc1115c7078c8798899e3a2e217c (diff)
wifi: do not reset country code on SIM removal
am: 6a4ab81c88 Change-Id: I516467d9f52f6c99b3c2ba0a752ba22b11a50670
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java44
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java19
2 files changed, 19 insertions, 44 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
index 69133428d..4ce5d5e40 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
@@ -126,50 +126,6 @@ public class WifiCountryCodeTest {
}
/**
- * Test if we can reset the country code upon sim card is removed.
- * @throws Exception
- */
- @Test
- public void resetCountryCodeWhenSIMCardRemoved() throws Exception {
- mWifiCountryCode.setCountryCode(mTelephonyCountryCode);
- // Supplicant started.
- mWifiCountryCode.setReadyForChange(true);
- // Wifi get L2 connected.
- mWifiCountryCode.setReadyForChange(false);
- assertEquals(mTelephonyCountryCode, mWifiCountryCode.getCountryCodeSentToDriver());
- // SIM card is removed.
- mWifiCountryCode.simCardRemoved();
- // Country code restting is not applied yet.
- assertEquals(mTelephonyCountryCode, mWifiCountryCode.getCountryCodeSentToDriver());
- mWifiCountryCode.setReadyForChange(true);
- // Country code restting is applied when supplicant is ready.
- verify(mWifiNative, times(2)).setCountryCode(any(), anyString());
- assertEquals(mDefaultCountryCode, mWifiCountryCode.getCountryCodeSentToDriver());
- }
-
- /**
- * Test if we can reset the country code upon airplane mode is enabled.
- * @throws Exception
- */
- @Test
- public void resetCountryCodeWhenAirplaneModeEnabled() throws Exception {
- mWifiCountryCode.setCountryCode(mTelephonyCountryCode);
- // Supplicant started.
- mWifiCountryCode.setReadyForChange(true);
- // Wifi get L2 connected.
- mWifiCountryCode.setReadyForChange(false);
- assertEquals(mTelephonyCountryCode, mWifiCountryCode.getCountryCodeSentToDriver());
- // Airplane mode is enabled.
- mWifiCountryCode.simCardRemoved();
- // Country code restting is not applied yet.
- assertEquals(mTelephonyCountryCode, mWifiCountryCode.getCountryCodeSentToDriver());
- mWifiCountryCode.setReadyForChange(true);
- // Country code restting is applied when supplicant is ready.
- verify(mWifiNative, times(2)).setCountryCode(any(), anyString());
- assertEquals(mDefaultCountryCode, mWifiCountryCode.getCountryCodeSentToDriver());
- }
-
- /**
* Test if we can reset to the default country code when phone is out of service, when
* |config_wifi_revert_country_code_on_cellular_loss| is set to true;
* Telephony service calls |setCountryCode| with an empty string when phone is out of service.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 102ebca15..f3d967e73 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -94,6 +94,7 @@ import android.os.test.TestLooper;
import android.support.test.filters.SmallTest;
import com.android.internal.os.PowerProfile;
+import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.AsyncChannel;
import com.android.server.wifi.WifiServiceImpl.LocalOnlyRequestorCallback;
import com.android.server.wifi.hotspot2.PasspointProvisioningTestUtil;
@@ -2768,4 +2769,22 @@ public class WifiServiceImplTest {
return apConfig;
}
+
+ /**
+ * Verifies that sim state change does not set or reset the country code
+ */
+ @Test
+ public void testSimStateChangeDoesNotResetCountryCode() {
+ mWifiServiceImpl.checkAndStartWifi();
+ verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
+ (IntentFilter) argThat((IntentFilter filter) ->
+ filter.hasAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED)));
+
+ int userHandle = TEST_USER_HANDLE;
+ // Send the broadcast
+ Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ intent.putExtra(Intent.EXTRA_USER_HANDLE, userHandle);
+ mBroadcastReceiverCaptor.getValue().onReceive(mContext, intent);
+ verifyNoMoreInteractions(mWifiCountryCode);
+ }
}