summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-09-21 07:32:17 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-09-21 07:32:17 +0000
commit32b3afda71e106ef11db0dc1c1dccdd7bf509986 (patch)
treee6640ba5ab1729007764910064d2e9202fb8f236
parent0f3beac8f0ffb0b846ced6857383e25cbbf5f264 (diff)
parenta32e2000025fb2df125c3d14c2fa55ddecd4b790 (diff)
downloadandroid_frameworks_opt_net_wifi-32b3afda71e106ef11db0dc1c1dccdd7bf509986.tar.gz
android_frameworks_opt_net_wifi-32b3afda71e106ef11db0dc1c1dccdd7bf509986.tar.bz2
android_frameworks_opt_net_wifi-32b3afda71e106ef11db0dc1c1dccdd7bf509986.zip
release-request-bbc747ae-190b-4d38-8704-432aa6396c16-for-git_oc-mr1-release-4351869 snap-temp-L93800000104806132
Change-Id: I5560dbb11164ab7ebf1bbcc907271bee927ab3f6
-rw-r--r--service/java/com/android/server/wifi/WifiCountryCode.java21
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java27
2 files changed, 35 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java
index e69fb8e1c..66a035f08 100644
--- a/service/java/com/android/server/wifi/WifiCountryCode.java
+++ b/service/java/com/android/server/wifi/WifiCountryCode.java
@@ -83,11 +83,9 @@ public class WifiCountryCode {
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.
- if (mRevertCountryCodeOnCellularLoss) {
- mTelephonyCountryCode = null;
- if (mReady) {
- updateCountryCode();
- }
+ mTelephonyCountryCode = null;
+ if (mReady) {
+ updateCountryCode();
}
}
@@ -98,12 +96,9 @@ public class WifiCountryCode {
*/
public synchronized void airplaneModeEnabled() {
if (DBG) Log.d(TAG, "Airplane Mode Enabled");
- mTelephonyCountryCode = null;
// Airplane mode is enabled, we need to reset the country code to phone default.
- if (mRevertCountryCodeOnCellularLoss) {
- mTelephonyCountryCode = null;
- // Country code will be set upon when wpa_supplicant starts next time.
- }
+ // Country code will be set upon when wpa_supplicant starts next time.
+ mTelephonyCountryCode = null;
}
/**
@@ -133,8 +128,10 @@ public class WifiCountryCode {
if (DBG) Log.d(TAG, "Receive set country code request: " + countryCode);
// Empty country code.
if (TextUtils.isEmpty(countryCode)) {
- if (DBG) Log.d(TAG, "Received empty country code, reset to default country code");
- mTelephonyCountryCode = null;
+ if (mRevertCountryCodeOnCellularLoss) {
+ if (DBG) Log.d(TAG, "Received empty country code, reset to default country code");
+ mTelephonyCountryCode = null;
+ }
} else {
mTelephonyCountryCode = countryCode.toUpperCase();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
index 33aab60e1..fb4e71ef5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
@@ -169,7 +169,8 @@ public class WifiCountryCodeTest {
}
/**
- * Test if we can reset to the default country code when phone is out of service.
+ * 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.
* In this case we should fall back to the default country code.
* @throws Exception
@@ -184,4 +185,28 @@ public class WifiCountryCodeTest {
assertEquals(mDefaultCountryCode, mWifiCountryCode.getCountryCode());
}
+ /**
+ * Test if we can keep using the last known country code when phone is out of service, when
+ * |config_wifi_revert_country_code_on_cellular_loss| is set to false;
+ * Telephony service calls |setCountryCode| with an empty string when phone is out of service.
+ * In this case we should keep using the last known country code.
+ * @throws Exception
+ */
+ @Test
+ public void doNotResetCountryCodeWhenOutOfService() throws Exception {
+ // Refresh mWifiCountryCode with |config_wifi_revert_country_code_on_cellular_loss|
+ // setting to false.
+ mWifiCountryCode = new WifiCountryCode(
+ mWifiNative,
+ mDefaultCountryCode,
+ false /* config_wifi_revert_country_code_on_cellular_loss */);
+
+ assertEquals(mDefaultCountryCode, mWifiCountryCode.getCountryCode());
+ mWifiCountryCode.setCountryCode(mTelephonyCountryCode);
+ assertEquals(mTelephonyCountryCode, mWifiCountryCode.getCountryCode());
+ // Out of service.
+ mWifiCountryCode.setCountryCode("");
+ assertEquals(mTelephonyCountryCode, mWifiCountryCode.getCountryCode());
+ }
+
}