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

Commit 9284d48a authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android (Google) Code Review
Browse files

Merge "Autojoin new unsecured networks without dialog"

parents 778e5240 22d441ac
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -358,4 +358,19 @@ class AccessPoint extends Preference {
            setSummary(summary.toString());
        }
    }

    /**
     * Generate and save a default wifiConfiguration with common values.
     * Can only be called for unsecured networks.
     * @hide
     */
    protected void generateOpenNetworkConfig() {
        if (security != SECURITY_NONE)
            throw new IllegalStateException();
        if (mConfig != null)
            return;
        mConfig = new WifiConfiguration();
        mConfig.SSID = AccessPoint.convertToQuotedString(ssid);
        mConfig.allowedKeyManagement.set(KeyMgmt.NONE);
    }
}
+12 −6
Original line number Diff line number Diff line
@@ -353,11 +353,9 @@ public class WifiSettings extends SettingsPreferenceFragment
                        mWifiManager.connectNetwork(mSelectedAccessPoint.networkId);
                    }
                } else if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE) {
                    // Shortcut for open networks.
                    WifiConfiguration config = new WifiConfiguration();
                    config.SSID = AccessPoint.convertToQuotedString(mSelectedAccessPoint.ssid);
                    config.allowedKeyManagement.set(KeyMgmt.NONE);
                    mWifiManager.connectNetwork(config);
                    /** Bypass dialog for unsecured networks */
                    mSelectedAccessPoint.generateOpenNetworkConfig();
                    mWifiManager.connectNetwork(mSelectedAccessPoint.getConfig());
                } else {
                    showConfigUi(mSelectedAccessPoint, true);
                }
@@ -379,7 +377,14 @@ public class WifiSettings extends SettingsPreferenceFragment
    public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
        if (preference instanceof AccessPoint) {
            mSelectedAccessPoint = (AccessPoint) preference;
            /** Bypass dialog for unsecured, unsaved networks */
            if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE &&
                    mSelectedAccessPoint.networkId == INVALID_NETWORK_ID) {
                mSelectedAccessPoint.generateOpenNetworkConfig();
                mWifiManager.connectNetwork(mSelectedAccessPoint.getConfig());
            } else {
                showConfigUi(mSelectedAccessPoint, false);
            }
        } else {
            return super.onPreferenceTreeClick(screen, preference);
        }
@@ -623,6 +628,7 @@ public class WifiSettings extends SettingsPreferenceFragment
        }

        void forceScan() {
            removeMessages(0);
            sendEmptyMessage(0);
        }