Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 834b0ade authored by Quang Luong's avatar Quang Luong
Browse files

[WifiSettings2] Remove redundant save() call for new configs

Removing call to WifiManager#save() when configuring a new network
through tapping it in the wifi picker. Since WifiManager#connect()
already saves the passed in WifiConfiguration, the call to
WifiManager#save() is redundant.

Bug: 149579116
Test: build, manual verification by connecting to a new secure network
Change-Id: I9242e7fd7e9a459e8221b6bb491ab67833970e87
parent 490eba35
Loading
Loading
Loading
Loading
+2 −25
Original line number Diff line number Diff line
@@ -423,8 +423,8 @@ public class WifiSettings2 extends RestrictedSettingsFragment
                final WifiConfiguration wifiConfiguration = data.getParcelableExtra(
                        ConfigureWifiEntryFragment.NETWORK_CONFIG_KEY);
                if (wifiConfiguration != null) {
                    mWifiManager.save(wifiConfiguration,
                            new WifiSaveThenConnectActionListener(wifiConfiguration));
                    mWifiManager.connect(wifiConfiguration,
                            new WifiConnectActionListener());
                }
            }
            return;
@@ -970,29 +970,6 @@ public class WifiSettings2 extends RestrictedSettingsFragment
                fullScreenEdit));
    }

    private class WifiSaveThenConnectActionListener implements WifiManager.ActionListener {
        final WifiConfiguration mWifiConfiguration;

        WifiSaveThenConnectActionListener(WifiConfiguration wifiConfiguration) {
            mWifiConfiguration = wifiConfiguration;
        }

        @Override
        public void onSuccess() {
            mWifiManager.connect(mWifiConfiguration, new WifiConnectActionListener());
        }

        @Override
        public void onFailure(int reason) {
            final Activity activity = getActivity();
            if (isFisishingOrDestroyed(activity)) {
                return;
            }

            Toast.makeText(activity, R.string.wifi_failed_save_message, Toast.LENGTH_SHORT).show();
        }
    };

    private class WifiConnectActionListener implements WifiManager.ActionListener {
        @Override
        public void onSuccess() {