summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKumar Anand <kumaranand@google.com>2018-05-25 15:55:14 -0700
committerKumar Anand <kumaranand@google.com>2018-05-31 23:26:42 +0000
commit6a4ab81c8842bc1115c7078c8798899e3a2e217c (patch)
treebeac8c88c01e6e4204ce4828dbaa132f577919dd /tests
parent7321b5dc86ba9f9de31588bf726008bf8a13138a (diff)
wifi: do not reset country code on SIM removal
Telephony will set country code even in no sim case based on emergency cell information. Hence Wifi framework should not reset the country code set by telephony blindly upon sim removal event. Bug: 79955190 Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Iebf7ce88d3d19ce1e00e3170e9809eb938201648
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);
+ }
}