wifi settings: Fix incorrect maximum compativibility toggle behavior

Correct behavior:

maximize_compatibility (enabled) 2.4 GHz Single AP
maximize_compatibility (disabled) 5 GHz Preferred Single AP

Bug: 184802466
Bug: 184802508
Test: Manual Test to check toggle behavior
Test: RunSettingsRoboTests
Test: atest -c WifiTetherMaximizeCompatibilityPreferenceControllerTest
Change-Id: I0e97455ea9cf62294b50514ce912ef66d274db8d
This commit is contained in:
lesl
2021-04-09 05:48:37 +08:00
parent 1f7c6f03b9
commit 80af71b92c
2 changed files with 10 additions and 10 deletions

View File

@@ -99,10 +99,10 @@ public class WifiTetherMaximizeCompatibilityPreferenceController extends
} }
// If the BridgedAp Concurrency is not supported in early Pixel devices (e.g. Pixel 2~5), // If the BridgedAp Concurrency is not supported in early Pixel devices (e.g. Pixel 2~5),
// show toggle on if the band includes SoftApConfiguration.BAND_5GHZ. // show toggle on when band is 2.4G only.
final int band = config.getBand(); final int band = config.getBand();
Log.d(TAG, "getBand:" + band); Log.d(TAG, "getBand:" + band);
return (band & SoftApConfiguration.BAND_5GHZ) > 0; return band == SoftApConfiguration.BAND_2GHZ;
} }
/** /**
@@ -128,8 +128,8 @@ public class WifiTetherMaximizeCompatibilityPreferenceController extends
builder.setBridgedModeOpportunisticShutdownEnabled(!enabled); builder.setBridgedModeOpportunisticShutdownEnabled(!enabled);
} else { } else {
int band = enabled int band = enabled
? SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ ? SoftApConfiguration.BAND_2GHZ
: SoftApConfiguration.BAND_2GHZ; : SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ;
Log.d(TAG, "setBand:" + band); Log.d(TAG, "setBand:" + band);
builder.setBand(band); builder.setBand(band);
} }

View File

@@ -168,7 +168,7 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
.build(); .build();
doReturn(config).when(mWifiManager).getSoftApConfiguration(); doReturn(config).when(mWifiManager).getSoftApConfiguration();
assertThat(mController.isMaximizeCompatibilityEnabled()).isEqualTo(false); assertThat(mController.isMaximizeCompatibilityEnabled()).isEqualTo(true);
} }
@Test @Test
@@ -179,7 +179,7 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
.build(); .build();
doReturn(config).when(mWifiManager).getSoftApConfiguration(); doReturn(config).when(mWifiManager).getSoftApConfiguration();
assertThat(mController.isMaximizeCompatibilityEnabled()).isEqualTo(true); assertThat(mController.isMaximizeCompatibilityEnabled()).isEqualTo(false);
} }
@Test @Test
@@ -190,7 +190,7 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
.build(); .build();
doReturn(config).when(mWifiManager).getSoftApConfiguration(); doReturn(config).when(mWifiManager).getSoftApConfiguration();
assertThat(mController.isMaximizeCompatibilityEnabled()).isEqualTo(true); assertThat(mController.isMaximizeCompatibilityEnabled()).isEqualTo(false);
} }
@Test @Test
@@ -223,7 +223,8 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
SoftApConfiguration.Builder builder = new SoftApConfiguration.Builder(); SoftApConfiguration.Builder builder = new SoftApConfiguration.Builder();
mController.setupMaximizeCompatibility(builder); mController.setupMaximizeCompatibility(builder);
assertThat(builder.build().getBand()).isEqualTo(SoftApConfiguration.BAND_2GHZ); assertThat(builder.build().getBand())
.isEqualTo(SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ);
} }
@Test @Test
@@ -234,7 +235,6 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
SoftApConfiguration.Builder builder = new SoftApConfiguration.Builder(); SoftApConfiguration.Builder builder = new SoftApConfiguration.Builder();
mController.setupMaximizeCompatibility(builder); mController.setupMaximizeCompatibility(builder);
assertThat(builder.build().getBand()) assertThat(builder.build().getBand()).isEqualTo(SoftApConfiguration.BAND_2GHZ);
.isEqualTo(SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ);
} }
} }