Merge "tether setting: Remove dual mode check for band convert"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d6f9b89061
@@ -276,24 +276,14 @@
|
|||||||
<item>Require all non-trusted certificate statuses</item>
|
<item>Require all non-trusted certificate statuses</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
|
<!-- Wi-Fi AP band settings. Either 2.4GHz or 5GHz prefer. -->
|
||||||
<!-- 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 translatable="false" name="wifi_ap_band_config_full">
|
<string-array translatable="false" name="wifi_ap_band">
|
||||||
<item>1</item>
|
|
||||||
<item>2</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array translatable="false" name="wifi_ap_band_summary_full">
|
|
||||||
<item>@string/wifi_ap_choose_2G</item>
|
|
||||||
<item>@string/wifi_ap_choose_5G</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array translatable="false" name="wifi_ap_band_dual_mode">
|
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array translatable="false" name="wifi_ap_band_dual_mode_summary">
|
<string-array translatable="false" name="wifi_ap_band_summary">
|
||||||
<item>@string/wifi_ap_choose_2G</item>
|
<item>@string/wifi_ap_choose_2G</item>
|
||||||
<item>@string/wifi_ap_prefer_5G</item>
|
<item>@string/wifi_ap_prefer_5G</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
@@ -39,12 +39,10 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
|||||||
private String[] mBandEntries;
|
private String[] mBandEntries;
|
||||||
private String[] mBandSummaries;
|
private String[] mBandSummaries;
|
||||||
private int mBandIndex;
|
private int mBandIndex;
|
||||||
private boolean isDualMode;
|
|
||||||
|
|
||||||
public WifiTetherApBandPreferenceController(Context context,
|
public WifiTetherApBandPreferenceController(Context context,
|
||||||
OnTetherConfigUpdateListener listener) {
|
OnTetherConfigUpdateListener listener) {
|
||||||
super(context, listener);
|
super(context, listener);
|
||||||
isDualMode = mWifiManager.isStaApConcurrencySupported();
|
|
||||||
updatePreferenceEntries();
|
updatePreferenceEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,16 +104,12 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
|||||||
|
|
||||||
private int validateSelection(int band) {
|
private int validateSelection(int band) {
|
||||||
// unsupported states:
|
// unsupported states:
|
||||||
// 1: no dual mode means we can't have multiband - default to 5GHZ
|
// 1: BAND_5GHZ only - include 2GHZ since some of countries doesn't support 5G hotspot
|
||||||
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
|
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
|
||||||
// 3: With Dual mode support we can't have BAND_5GHZ only - include 2GHZ
|
if (SoftApConfiguration.BAND_5GHZ == band) {
|
||||||
if (!isDualMode
|
if (!is5GhzBandSupported()) {
|
||||||
&& ((band & SoftApConfiguration.BAND_5GHZ) != 0)
|
|
||||||
&& ((band & SoftApConfiguration.BAND_2GHZ) != 0)) {
|
|
||||||
return SoftApConfiguration.BAND_5GHZ;
|
|
||||||
} else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
|
|
||||||
return SoftApConfiguration.BAND_2GHZ;
|
return SoftApConfiguration.BAND_2GHZ;
|
||||||
} else if (isDualMode && SoftApConfiguration.BAND_5GHZ == band) {
|
}
|
||||||
return SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ;
|
return SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,13 +119,8 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void updatePreferenceEntries() {
|
void updatePreferenceEntries() {
|
||||||
Resources res = mContext.getResources();
|
Resources res = mContext.getResources();
|
||||||
int entriesRes = R.array.wifi_ap_band_config_full;
|
int entriesRes = R.array.wifi_ap_band;
|
||||||
int summariesRes = R.array.wifi_ap_band_summary_full;
|
int summariesRes = R.array.wifi_ap_band_summary;
|
||||||
// change the list options if this is a dual mode device
|
|
||||||
if (isDualMode) {
|
|
||||||
entriesRes = R.array.wifi_ap_band_dual_mode;
|
|
||||||
summariesRes = R.array.wifi_ap_band_dual_mode_summary;
|
|
||||||
}
|
|
||||||
mBandEntries = res.getStringArray(entriesRes);
|
mBandEntries = res.getStringArray(entriesRes);
|
||||||
mBandSummaries = res.getStringArray(summariesRes);
|
mBandSummaries = res.getStringArray(summariesRes);
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,6 @@ public class WifiTetherApBandPreferenceControllerTest {
|
|||||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||||
when(mWifiManager.getSoftApConfiguration()).thenReturn(
|
when(mWifiManager.getSoftApConfiguration()).thenReturn(
|
||||||
new SoftApConfiguration.Builder().build());
|
new SoftApConfiguration.Builder().build());
|
||||||
when(mWifiManager.isStaApConcurrencySupported()).thenReturn(false);
|
|
||||||
|
|
||||||
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
||||||
}
|
}
|
||||||
@@ -90,9 +89,8 @@ public class WifiTetherApBandPreferenceControllerTest {
|
|||||||
public void display_5GhzSupported_shouldDisplayFullList() {
|
public void display_5GhzSupported_shouldDisplayFullList() {
|
||||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||||
when(mWifiManager.isStaApConcurrencySupported()).thenReturn(true);
|
|
||||||
|
|
||||||
// Create a new instance to pick the proper value of isDualModeSupported()
|
// Create a new instance
|
||||||
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -126,38 +124,10 @@ public class WifiTetherApBandPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changePreference_noDualModeWith5G_shouldUpdateValue() {
|
public void changePreference_With5G_shouldUpdateValue() {
|
||||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
// 'Auto' option should be prevented from being set since
|
|
||||||
// it is invalid for this configuration
|
|
||||||
mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
|
|
||||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
|
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
|
|
||||||
verify(mListener, times(1)).onTetherConfigUpdated(mController);
|
|
||||||
|
|
||||||
// set to 5 Ghz
|
|
||||||
mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
|
|
||||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
|
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
|
|
||||||
verify(mListener, times(2)).onTetherConfigUpdated(mController);
|
|
||||||
|
|
||||||
// set to 2 Ghz
|
|
||||||
mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
|
|
||||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
|
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
|
|
||||||
verify(mListener, times(3)).onTetherConfigUpdated(mController);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void changePreference_dualModeWith5G_shouldUpdateValue() {
|
|
||||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
|
||||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
|
||||||
when(mWifiManager.isStaApConcurrencySupported()).thenReturn(true);
|
|
||||||
|
|
||||||
// Create a new instance to pick the proper value of isDualModeSupported()
|
// Create a new instance to pick the proper value of isDualModeSupported()
|
||||||
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user