diff options
author | Ningyuan Wang <nywang@google.com> | 2016-06-03 14:21:27 -0700 |
---|---|---|
committer | Ningyuan Wang <nywang@google.com> | 2016-06-06 13:07:18 -0700 |
commit | 0091305175e8c6fe7fc6d01efb9d405961db4ac7 (patch) | |
tree | b30d35ba8001455ba1b1946824be8989d0ea72f3 /tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java | |
parent | d722d068b68772e52dd7621cfb915fce5ac08482 (diff) | |
download | android_frameworks_opt_net_wifi-0091305175e8c6fe7fc6d01efb9d405961db4ac7.tar.gz android_frameworks_opt_net_wifi-0091305175e8c6fe7fc6d01efb9d405961db4ac7.tar.bz2 android_frameworks_opt_net_wifi-0091305175e8c6fe7fc6d01efb9d405961db4ac7.zip |
Continue supporting persisting country code
Some devices rely on Setup Wizard to set a persistent country
code.
This CL honors the persistent option, fixing corresponding 5GHz AP
problem.
This also includes addtional unit tests for this change.
BUG=28127280
TEST=compile
TEST=runtest frameworks-wifi
Change-Id: I2f36216e143d0ac4959f26a9965def061a06aabf
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java index 33cf2170b..2e62a309b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java @@ -18,6 +18,7 @@ package com.android.server.wifi; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -38,6 +39,7 @@ public class WifiCountryCodeTest { private static final String TAG = "WifiCountryCodeTest"; private String mDefaultCountryCode = "US"; private String mTelephonyCountryCode = "JP"; + private String mPersistCountryCode = ""; private boolean mRevertCountryCodeOnCellularLoss = true; @Mock WifiNative mWifiNative; private WifiCountryCode mWifiCountryCode; @@ -51,7 +53,10 @@ public class WifiCountryCodeTest { when(mWifiNative.setCountryCode(anyString())).thenReturn(true); - mWifiCountryCode = new WifiCountryCode(mWifiNative, mDefaultCountryCode, + mWifiCountryCode = new WifiCountryCode( + mWifiNative, + mDefaultCountryCode, + mPersistCountryCode, mRevertCountryCodeOnCellularLoss); } @@ -75,7 +80,7 @@ public class WifiCountryCodeTest { */ @Test public void useTelephonyCountryCode() throws Exception { - mWifiCountryCode.setCountryCode(mTelephonyCountryCode); + mWifiCountryCode.setCountryCode(mTelephonyCountryCode, false); assertEquals(null, mWifiCountryCode.getCurrentCountryCode()); // Supplicant started. mWifiCountryCode.setReadyForChange(true); @@ -95,7 +100,7 @@ public class WifiCountryCodeTest { mWifiCountryCode.setReadyForChange(true); assertEquals(mDefaultCountryCode, mWifiCountryCode.getCurrentCountryCode()); // Telephony country code arrives. - mWifiCountryCode.setCountryCode(mTelephonyCountryCode); + mWifiCountryCode.setCountryCode(mTelephonyCountryCode, false); // Wifi get L2 connected. mWifiCountryCode.setReadyForChange(false); verify(mWifiNative, times(2)).setCountryCode(anyString()); @@ -113,7 +118,7 @@ public class WifiCountryCodeTest { // Wifi get L2 connected. mWifiCountryCode.setReadyForChange(false); // Telephony country code arrives. - mWifiCountryCode.setCountryCode(mTelephonyCountryCode); + mWifiCountryCode.setCountryCode(mTelephonyCountryCode, false); // Telephony coutry code won't be applied at this time. assertEquals(mDefaultCountryCode, mWifiCountryCode.getCurrentCountryCode()); mWifiCountryCode.setReadyForChange(true); @@ -128,7 +133,7 @@ public class WifiCountryCodeTest { */ @Test public void resetCountryCodeWhenSIMCardRemoved() throws Exception { - mWifiCountryCode.setCountryCode(mTelephonyCountryCode); + mWifiCountryCode.setCountryCode(mTelephonyCountryCode, false); // Supplicant started. mWifiCountryCode.setReadyForChange(true); // Wifi get L2 connected. @@ -150,7 +155,7 @@ public class WifiCountryCodeTest { */ @Test public void resetCountryCodeWhenAirplaneModeEnabled() throws Exception { - mWifiCountryCode.setCountryCode(mTelephonyCountryCode); + mWifiCountryCode.setCountryCode(mTelephonyCountryCode, false); // Supplicant started. mWifiCountryCode.setReadyForChange(true); // Wifi get L2 connected. @@ -165,4 +170,24 @@ public class WifiCountryCodeTest { verify(mWifiNative, times(2)).setCountryCode(anyString()); assertEquals(mDefaultCountryCode, mWifiCountryCode.getCurrentCountryCode()); } + + /** + * Test if we will set the persistent country code if it is not empty. + * @throws Exception + */ + @Test + public void usePersistentCountryCode() throws Exception { + String persistentCountryCode = "CH"; + mWifiCountryCode = new WifiCountryCode( + mWifiNative, + mDefaultCountryCode, + persistentCountryCode, + mRevertCountryCodeOnCellularLoss); + // Supplicant started. + mWifiCountryCode.setReadyForChange(true); + // Wifi get L2 connected. + mWifiCountryCode.setReadyForChange(false); + verify(mWifiNative).setCountryCode(anyString()); + assertEquals(persistentCountryCode, mWifiCountryCode.getCurrentCountryCode()); + } } |