Fixed speed selection lost when changing password in Wi-Fi hotspot settings

- Use current SoftApConfiguration to build new SoftApConfiguration to keep unchanged properties

Bug: 279717060
Test: manual test
atest -c WifiTetherSettingsTest

Change-Id: I3ee7960b13b339445cc79c3d440f5c56c78c015f
This commit is contained in:
Weng Su
2023-04-26 18:40:58 +08:00
parent 4132d3b560
commit 8c50edd1e7
2 changed files with 44 additions and 6 deletions

View File

@@ -80,11 +80,14 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
@VisibleForTesting
SettingsMainSwitchBar mMainSwitchBar;
private WifiTetherSwitchBarController mSwitchBarController;
private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
@VisibleForTesting
WifiTetherSSIDPreferenceController mSSIDPreferenceController;
@VisibleForTesting
WifiTetherPasswordPreferenceController mPasswordPreferenceController;
private WifiTetherSecurityPreferenceController mSecurityPreferenceController;
private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController;
private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
@VisibleForTesting
WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
private boolean mUnavailable;
private WifiRestriction mWifiRestriction;
@@ -269,10 +272,12 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
setLoading(restarting, false);
}
private SoftApConfiguration buildNewConfig() {
SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
@VisibleForTesting
SoftApConfiguration buildNewConfig() {
SoftApConfiguration currentConfig = mWifiTetherViewModel.getSoftApConfiguration();
SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(currentConfig);
int securityType = (mWifiTetherViewModel.isSpeedFeatureAvailable())
? mWifiTetherViewModel.getSoftApConfiguration().getSecurityType()
? currentConfig.getSecurityType()
: mSecurityPreferenceController.getSecurityType();
configBuilder.setSsid(mSSIDPreferenceController.getSSID());
if (securityType != SoftApConfiguration.SECURITY_TYPE_OPEN) {