diff options
4 files changed, 19 insertions, 60 deletions
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java index 6f61d474a..ff9ff0200 100644 --- a/service/java/com/android/server/wifi/WifiCountryCode.java +++ b/service/java/com/android/server/wifi/WifiCountryCode.java @@ -79,20 +79,6 @@ public class WifiCountryCode { } /** - * This is called when sim card is removed. - * In this case we should invalid all other country codes except the - * phone default one. - */ - public synchronized void simCardRemoved() { - if (DBG) Log.d(TAG, "SIM Card Removed"); - // SIM card is removed, we need to reset the country code to phone default. - mTelephonyCountryCode = null; - if (mReady) { - updateCountryCode(); - } - } - - /** * This is called when airplane mode is enabled. * In this case we should invalidate all other country code except the * phone default one. diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index ad5f133dc..e01266f2c 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -538,8 +538,6 @@ public class WifiServiceImpl extends IWifiManager.Stub { if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(state)) { Log.d(TAG, "resetting networks because SIM was removed"); mWifiStateMachine.resetSimAuthNetworks(false); - Log.d(TAG, "resetting country code because SIM is removed"); - mCountryCode.simCardRemoved(); } else if (IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(state)) { Log.d(TAG, "resetting networks because SIM was loaded"); mWifiStateMachine.resetSimAuthNetworks(true); 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); + } } |