diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 7ab9afbb008..cb6f9be5d04 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -266,14 +266,16 @@
- PWD
-
+
+ - @string/wifi_ap_choose_auto
- @string/wifi_ap_choose_2G
- @string/wifi_ap_choose_5G
+ - @string/wifi_ap_choose_auto
- @string/wifi_ap_choose_2G
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4182fd95f3b..4ca5f6e4a5e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1941,6 +1941,8 @@
Show password
Select AP Band
+
+ Auto
2.4 GHz Band
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index 1e299abc2e3..4c47a0d02a3 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -18,6 +18,7 @@ package com.android.settings.wifi.tether;
import static android.net.wifi.WifiConfiguration.AP_BAND_2GHZ;
import static android.net.wifi.WifiConfiguration.AP_BAND_5GHZ;
+import static android.net.wifi.WifiConfiguration.AP_BAND_ANY;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
@@ -32,7 +33,8 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
private static final String TAG = "WifiTetherApBandPref";
private static final String PREF_KEY = "wifi_tether_network_ap_band";
private static final String[] BAND_VALUES =
- {String.valueOf(AP_BAND_2GHZ), String.valueOf(AP_BAND_5GHZ)};
+ {String.valueOf(AP_BAND_ANY), String.valueOf(AP_BAND_2GHZ),
+ String.valueOf(AP_BAND_5GHZ)};
private final String[] mBandEntries;
private int mBandIndex;
@@ -65,7 +67,7 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
} else {
preference.setEntries(mBandEntries);
preference.setEntryValues(BAND_VALUES);
- preference.setSummary(mBandEntries[mBandIndex]);
+ preference.setSummary(mBandEntries[mBandIndex + 1]);
preference.setValue(String.valueOf(mBandIndex));
}
}
@@ -78,7 +80,8 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
mBandIndex = Integer.parseInt((String) newValue);
- preference.setSummary(mBandEntries[mBandIndex]);
+ Log.d(TAG, "Band preference changed, updating band index to " + mBandIndex);
+ preference.setSummary(mBandEntries[mBandIndex + 1]);
mListener.onTetherConfigUpdated();
return true;
}
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 6832ca8e6d8..2a633d9a6c1 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -80,7 +80,7 @@ public class WifiTetherApBandPreferenceControllerTest {
mController.displayPreference(mScreen);
- assertThat(mListPreference.getEntries().length).isEqualTo(2);
+ assertThat(mListPreference.getEntries().length).isEqualTo(3);
}
@Test
@@ -113,13 +113,18 @@ public class WifiTetherApBandPreferenceControllerTest {
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
mController.displayPreference(mScreen);
+
+ // -1 is WifiConfiguration.AP_BAND_ANY, for 'Auto' option.
+ mController.onPreferenceChange(mListPreference, "-1");
+ assertThat(mController.getBandIndex()).isEqualTo(-1);
+
mController.onPreferenceChange(mListPreference, "1");
assertThat(mController.getBandIndex()).isEqualTo(1);
mController.onPreferenceChange(mListPreference, "0");
assertThat(mController.getBandIndex()).isEqualTo(0);
- verify(mListener, times(2)).onTetherConfigUpdated();
+ verify(mListener, times(3)).onTetherConfigUpdated();
}
@Test