Prevent unnecessary reconnection for wifi privacy

Before fix, privacy toggle in the Network details page causes a
disconnection + reconnection even when selecting the same setting.

Check current setting first to prevent unnecessary reconnection.

Fix: 303093138
Test: manual - select same privacy setting
Test: unit test
Change-Id: I71208e3cd256fdc0dd5e895fa1a68fdab47aed9a
This commit is contained in:
Chaohui Wang
2023-10-07 15:42:35 +08:00
parent ec39446b76
commit 8e2e9e5d3e
3 changed files with 147 additions and 124 deletions

View File

@@ -72,6 +72,10 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
@Override
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
final int privacy = Integer.parseInt((String) newValue);
if (mWifiEntry.getPrivacy() == privacy) {
// Prevent disconnection + reconnection if settings not changed.
return true;
}
mWifiEntry.setPrivacy(privacy);
// To activate changing, we need to reconnect network. WiFi will auto connect to