From 78c3f368c3a64197dee84df24547449220d36e2a Mon Sep 17 00:00:00 2001 From: Salvador Martinez Date: Mon, 9 Jul 2018 11:52:34 -0700 Subject: [PATCH] Fix incorrect method call to wifiManager in Tether In the WifiTetherApBandController the incorrect method was being called to check if the device is 5Ghz compatible. We were calling is5GhzBandSupported directly, but we were supposed to call isDualBandSupported instead. Test: robotests updated Bug: 110793581 Change-Id: I61d3ff10abedde6196b8e29591ebfd3272dbbcd9 --- .../WifiTetherApBandPreferenceController.java | 2 +- .../WifiTetherApBandPreferenceControllerTest.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java index 2624c736327..1eda72d7bae 100644 --- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java +++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java @@ -103,7 +103,7 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen // 3: With Dual mode support we can't have AP_BAND_5GHZ - default to ANY if (!isDualMode && WifiConfiguration.AP_BAND_ANY == band) { return WifiConfiguration.AP_BAND_5GHZ; - } else if (!mWifiManager.is5GHzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) { + } else if (!is5GhzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) { return WifiConfiguration.AP_BAND_2GHZ; } else if (isDualMode && WifiConfiguration.AP_BAND_5GHZ == band) { return WifiConfiguration.AP_BAND_ANY; diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java index 8df62c3c02e..c9a9c0040ec 100644 --- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java @@ -104,6 +104,7 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void display_5GhzNotSupported_shouldDisable() { + when(mWifiManager.getCountryCode()).thenReturn("US"); when(mWifiManager.isDualBandSupported()).thenReturn(false); mController.displayPreference(mScreen); @@ -115,7 +116,8 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void changePreference_noDualModeWith5G_shouldUpdateValue() { - when(mWifiManager.is5GHzBandSupported()).thenReturn(true); + when(mWifiManager.getCountryCode()).thenReturn("US"); + when(mWifiManager.isDualBandSupported()).thenReturn(true); mController.displayPreference(mScreen); @@ -141,7 +143,8 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void changePreference_dualModeWith5G_shouldUpdateValue() { - when(mWifiManager.is5GHzBandSupported()).thenReturn(true); + when(mWifiManager.getCountryCode()).thenReturn("US"); + when(mWifiManager.isDualBandSupported()).thenReturn(true); when(mWifiManager.isDualModeSupported()).thenReturn(true); mController.displayPreference(mScreen); @@ -167,14 +170,16 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void updateDisplay_shouldUpdateValue() { + when(mWifiManager.getCountryCode()).thenReturn("US"); + when(mWifiManager.isDualBandSupported()).thenReturn(true); + // Set controller band index to 1 and verify is set. - when(mWifiManager.is5GHzBandSupported()).thenReturn(true); mController.displayPreference(mScreen); mController.onPreferenceChange(mPreference, "1"); assertThat(mController.getBandIndex()).isEqualTo(1); // Disable 5Ghz band - when(mWifiManager.is5GHzBandSupported()).thenReturn(false); + when(mWifiManager.isDualBandSupported()).thenReturn(false); // Call updateDisplay and verify it's changed. mController.updateDisplay();