summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2019-10-22 15:41:27 -0700
committerDavid Su <dysu@google.com>2019-10-23 18:21:24 -0700
commitc67c01d936b541857223d55b6afccd8f976daa61 (patch)
treea39873bb14a97c089d341be05ab90a17abeec80d
parentfcf90c3ee9492cd3da770785c3ca58d1da2a6b2c (diff)
Do not clear Wifi country code upon entering airplane mode
Previously, Wifi and telephony would both clear the country code upon entering airplane mode, and telephony would update the Wifi country code upon exiting airplane mode. Now telephony no longer clears the country code immediately upon entering airplane mode, but Wifi will still clear its country code immediately. If airplane mode is exited before telephony clears the country code, telephony will not update Wifi's country code since it believes that Wifi still has it's previous country code. With a cleared country code, Wifi hotspot will always use the 2.4 GHz band, even when the user specified that 5 GHz is preferred. Fix this by not clearing the Wifi country code immediately upon entering airplane mode. Telephony will do the right thing and clear/update the Wifi country code as needed. Bug: 140392836 Test: atest FrameworksWifiTests Test: reboot device, turn airplane mode on, then quickly turn it off, turn on hotspot with 5 GHz preferred, verify that hotspot is indeed on 5 GHz band. Change-Id: I80ab05bed795453077fc1d9d476d91fda1db5ddf Merged-In: I80ab05bed795453077fc1d9d476d91fda1db5ddf
-rw-r--r--service/java/com/android/server/wifi/WifiCountryCode.java12
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java19
3 files changed, 19 insertions, 16 deletions
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java
index 499c159fa..f9d147c6b 100644
--- a/service/java/com/android/server/wifi/WifiCountryCode.java
+++ b/service/java/com/android/server/wifi/WifiCountryCode.java
@@ -84,18 +84,6 @@ public class WifiCountryCode {
}
/**
- * This is called when airplane mode is enabled.
- * In this case we should invalidate all other country code except the
- * phone default one.
- */
- public synchronized void airplaneModeEnabled() {
- Log.d(TAG, "Airplane Mode Enabled");
- // Airplane mode is enabled, we need to reset the country code to phone default.
- // Country code will be set upon when wpa_supplicant starts next time.
- mTelephonyCountryCode = null;
- }
-
- /**
* Change the state to indicates if wpa_supplicant is ready to handle country code changing
* request or not.
* We call native code to request country code changes only when wpa_supplicant is
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 650f33d36..4dbf71fd7 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -528,10 +528,6 @@ public class WifiServiceImpl extends BaseWifiService {
if (mSettingsStore.handleAirplaneModeToggled()) {
mWifiController.sendMessage(CMD_AIRPLANE_TOGGLED);
}
- if (mSettingsStore.isAirplaneModeOn()) {
- Log.d(TAG, "resetting country code because Airplane mode is ON");
- mCountryCode.airplaneModeEnabled();
- }
}
},
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 3f7d73bb4..bd8129a38 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -3430,6 +3430,25 @@ public class WifiServiceImplTest {
}
/**
+ * Verifies that entering airplane mode does not reset country code.
+ */
+ @Test
+ public void testEnterAirplaneModeNotResetCountryCode() {
+ mWifiServiceImpl.checkAndStartWifi();
+ verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
+ (IntentFilter) argThat((IntentFilter filter) ->
+ filter.hasAction(Intent.ACTION_AIRPLANE_MODE_CHANGED)));
+
+ when(mSettingsStore.isAirplaneModeOn()).thenReturn(true);
+
+ // Send the broadcast
+ Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
+ mBroadcastReceiverCaptor.getValue().onReceive(mContext, intent);
+
+ verifyNoMoreInteractions(mWifiCountryCode);
+ }
+
+ /**
* Verify calls to notify users of a softap config change check the NETWORK_SETTINGS permission.
*/
@Test