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

Commit b75d6151 authored by Fang Yunong's avatar Fang Yunong Committed by Linux Build Service Account
Browse files

Passpoint:add passpoint swither in settings

Add passpoint switcher in settings.user can control whether enanle it
via it.

CRs-Fixed: 1039339

Change-Id: I3f8ec5cc21fc1ac5bf4a27d07ae5a95e24f7e57e
parent 14c635e8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1538,6 +1538,9 @@
    <string name="wifi_notify_open_networks">Network notification</string>
    <!-- Checkbox summary for option to notify user when open networks are nearby [CHAR LIMIT=60]-->
    <string name="wifi_notify_open_networks_summary">Notify whenever a public network is available</string>
    <string name="wifi_enable_hs2_title">Passpoint On</string>
    <!-- Checkbox title for option to toggle poor network detection -->
    <string name="wifi_poor_network_detection">Avoid poor connections</string>
    <!-- Checkbox summary for option to toggle poor network detection -->
+6 −0
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@
            android:title="@string/wifi_install_credentials"
            android:persistent="false" />

    <!-- android:dependency="enable_wifi" -->
    <SwitchPreference
            android:key="enable_hs2"
            android:title="@string/wifi_enable_hs2_title"
            android:persistent="false" />

    <Preference
            android:key="wifi_direct"
            android:title="@string/wifi_menu_p2p"
+23 −1
Original line number Diff line number Diff line
@@ -25,12 +25,14 @@ import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
import android.security.Credentials;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;

import android.util.Log;
import android.widget.Toast;

@@ -77,7 +79,7 @@ public class AdvancedWifiSettings extends RestrictedSettingsFragment

    private static final String KEY_CONNECT_NOTIFY = "notify_ap_connected";
    private static final String NOTIFY_USER_CONNECT = "notify_user_when_connect_cmcc";

    private static final String KEY_ENABLE_HS2 = "enable_hs2";
    private static final int NOTIFY_USER = 0;
    private static final int DO_NOT_NOTIFY_USER = -1;

@@ -132,7 +134,27 @@ public class AdvancedWifiSettings extends RestrictedSettingsFragment
        intent.putExtra(Credentials.EXTRA_INSTALL_AS_UID, android.os.Process.WIFI_UID);
        Preference pref = findPreference(KEY_INSTALL_CREDENTIALS);
        pref.setIntent(intent);
        SwitchPreference enableHs2 =
                (SwitchPreference) findPreference(KEY_ENABLE_HS2);
        if (enableHs2 != null && getResources().getBoolean(
                com.android.internal.R.bool.config_passpoint_setting_on)) {
            enableHs2.setOnPreferenceClickListener(new OnPreferenceClickListener() {
                public boolean onPreferenceClick(Preference preference) {
                    String key = preference.getKey();
                    if (KEY_ENABLE_HS2.equals(key)) {
                        Settings.Global.putInt(getContentResolver(),
                                Settings.Global.WIFI_HOTSPOT2_ENABLED,
                                ((SwitchPreference) preference).isChecked() ? 1 : 0);
                    }
                return true;
                }
            });

            enableHs2.setChecked(Settings.Global.getInt(getContentResolver(),
                    Settings.Global.WIFI_HOTSPOT2_ENABLED, WIFI_HS2_DISABLED) == WIFI_HS2_ENABLED);
        } else {
            getPreferenceScreen().removePreference(enableHs2);
        }

        Intent wifiDirectIntent = new Intent(context,
                com.android.settings.Settings.WifiP2pSettingsActivity.class);
+23 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiManager;
import android.net.wifi.WpsInfo;
import android.nfc.NfcAdapter;
@@ -565,6 +566,15 @@ public class WifiSettings extends RestrictedSettingsFragment
        showDialog(WIFI_DIALOG_ID);
    }

    private boolean isPasspointWifi(AccessPoint ap) {
        if (ap != null && ap.getConfig() != null) {
            WifiEnterpriseConfig entConfig = ap.getConfig().enterpriseConfig;
            return (entConfig != null)
                && (entConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE);
        }
        return false;
    }

    @Override
    public Dialog onCreateDialog(int dialogId) {
        switch (dialogId) {
@@ -581,8 +591,19 @@ public class WifiSettings extends RestrictedSettingsFragment
                }
                // If it's null, fine, it's for Add Network
                mSelectedAccessPoint = ap;
                if (getResources().getBoolean(
                        com.android.internal.R.bool.config_passpoint_setting_on)) {
                    //always hide the "forget" button for an passpoint hotspot
                    boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
                            ap.getConfig()));
                    hideForget = hideForget || isPasspointWifi(ap);
                    Log.d(TAG, "Passpoint hotspot ? " + (isPasspointWifi(ap) ? "yes":"no"));
                    mDialog = new WifiDialog(getActivity(), this, (hideForget ? null : ap),
                            mDialogMode,/* no hide submit/connect */ false);
                } else {
                    mDialog = new WifiDialog(getActivity(), this, ap, mDialogMode,
                            /* no hide submit/connect */ false);
                }
                return mDialog;
            case WPS_PBC_DIALOG_ID:
                return new WpsDialog(getActivity(), WpsInfo.PBC);