Merge "Wifi Settings: Add auto option for softap"
This commit is contained in:
committed by
Android (Google) Code Review
commit
0608d2dc9d
@@ -266,14 +266,16 @@
|
|||||||
<item>PWD</item>
|
<item>PWD</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Wi-Fi AP band settings. Either 2.4GHz or 5GHz. -->
|
<!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
|
||||||
<!-- Note that adding/removing/moving the items will need wifi settings code change. -->
|
<!-- Note that adding/removing/moving the items will need wifi settings code change. -->
|
||||||
<string-array name="wifi_ap_band_config_full">
|
<string-array name="wifi_ap_band_config_full">
|
||||||
|
<item>@string/wifi_ap_choose_auto</item>
|
||||||
<item>@string/wifi_ap_choose_2G</item>
|
<item>@string/wifi_ap_choose_2G</item>
|
||||||
<item>@string/wifi_ap_choose_5G</item>
|
<item>@string/wifi_ap_choose_5G</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="wifi_ap_band_config_2G_only">
|
<string-array name="wifi_ap_band_config_2G_only">
|
||||||
|
<item>@string/wifi_ap_choose_auto</item>
|
||||||
<item>@string/wifi_ap_choose_2G</item>
|
<item>@string/wifi_ap_choose_2G</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@@ -1941,6 +1941,8 @@
|
|||||||
<string name="wifi_show_password">Show password</string>
|
<string name="wifi_show_password">Show password</string>
|
||||||
<!-- Label for the RadioGroup to choose wifi ap band -->
|
<!-- Label for the RadioGroup to choose wifi ap band -->
|
||||||
<string name="wifi_ap_band_config">Select AP Band</string>
|
<string name="wifi_ap_band_config">Select AP Band</string>
|
||||||
|
<!-- Label for the radio button to choose wifi ap channel automatically-->
|
||||||
|
<string name="wifi_ap_choose_auto">Auto</string>
|
||||||
<!-- Label for the radio button to choose wifi ap 2.4 GHz band -->
|
<!-- Label for the radio button to choose wifi ap 2.4 GHz band -->
|
||||||
<string name="wifi_ap_choose_2G">2.4 GHz Band</string>
|
<string name="wifi_ap_choose_2G">2.4 GHz Band</string>
|
||||||
<!-- Label for the radio button to choose wifi ap 5GHz band -->
|
<!-- Label for the radio button to choose wifi ap 5GHz band -->
|
||||||
|
@@ -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_2GHZ;
|
||||||
import static android.net.wifi.WifiConfiguration.AP_BAND_5GHZ;
|
import static android.net.wifi.WifiConfiguration.AP_BAND_5GHZ;
|
||||||
|
import static android.net.wifi.WifiConfiguration.AP_BAND_ANY;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
@@ -32,7 +33,8 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
|||||||
private static final String TAG = "WifiTetherApBandPref";
|
private static final String TAG = "WifiTetherApBandPref";
|
||||||
private static final String PREF_KEY = "wifi_tether_network_ap_band";
|
private static final String PREF_KEY = "wifi_tether_network_ap_band";
|
||||||
private static final String[] BAND_VALUES =
|
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 final String[] mBandEntries;
|
||||||
private int mBandIndex;
|
private int mBandIndex;
|
||||||
@@ -65,7 +67,7 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
|||||||
} else {
|
} else {
|
||||||
preference.setEntries(mBandEntries);
|
preference.setEntries(mBandEntries);
|
||||||
preference.setEntryValues(BAND_VALUES);
|
preference.setEntryValues(BAND_VALUES);
|
||||||
preference.setSummary(mBandEntries[mBandIndex]);
|
preference.setSummary(mBandEntries[mBandIndex + 1]);
|
||||||
preference.setValue(String.valueOf(mBandIndex));
|
preference.setValue(String.valueOf(mBandIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +80,8 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
mBandIndex = Integer.parseInt((String) 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();
|
mListener.onTetherConfigUpdated();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,7 @@ public class WifiTetherApBandPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
assertThat(mListPreference.getEntries().length).isEqualTo(2);
|
assertThat(mListPreference.getEntries().length).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -113,13 +113,18 @@ public class WifiTetherApBandPreferenceControllerTest {
|
|||||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
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");
|
mController.onPreferenceChange(mListPreference, "1");
|
||||||
assertThat(mController.getBandIndex()).isEqualTo(1);
|
assertThat(mController.getBandIndex()).isEqualTo(1);
|
||||||
|
|
||||||
mController.onPreferenceChange(mListPreference, "0");
|
mController.onPreferenceChange(mListPreference, "0");
|
||||||
assertThat(mController.getBandIndex()).isEqualTo(0);
|
assertThat(mController.getBandIndex()).isEqualTo(0);
|
||||||
|
|
||||||
verify(mListener, times(2)).onTetherConfigUpdated();
|
verify(mListener, times(3)).onTetherConfigUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user