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

Commit fc1b00cf authored by Jason Monk's avatar Jason Monk
Browse files

Move some wifi tracking code to SettingsLib

Move tracking of which networks are available/saved and their state
over to SettingsLib to share it with Quick Settings.

Bug: 19180466
Change-Id: Iaeef06b26da8cb38e1ba09a7d105d04d499dc181
parent 544714d0
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
@@ -1317,8 +1317,6 @@

    <!-- Wifi Assistant title.  [CHAR LIMIT=40] -->
    <string name="wifi_assistant_title">Wi\u2011Fi Assistant</string>
    <!-- Status message of Wi-Fi when it is connected by a Wi-Fi assistant application. [CHAR LIMIT=NONE] -->
    <string name="connected_via_wfa">Connected via Wi\u2011Fi assistant</string>

    <!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
    <string name="wifi_display_settings_title">Cast screen</string>
@@ -1422,8 +1420,6 @@
    <string name="wifi_error">Error</string>
    <!-- Toast message when Wi-Fi or bluetooth is disallowed in airplane mode -->
    <string name="wifi_in_airplane_mode">In Airplane mode</string>
    <!-- Toast message when Wi-Fi cannot scan for networks -->
    <string name="wifi_fail_to_scan">Can\'t scan for networks</string>
    <!-- Checkbox title for option to notify user when open networks are nearby -->
    <string name="wifi_notify_open_networks">Network notification</string>
    <!-- Checkbox summary for option to notify user when open networks are nearby [CHAR LIMIT=60]-->
@@ -1578,21 +1574,6 @@
    <string name="wifi_unchanged">(unchanged)</string>
    <!-- Hint for unspecified fields -->
    <string name="wifi_unspecified">(unspecified)</string>
    <!-- Summary for the remembered network. -->
    <string name="wifi_remembered">Saved</string>
    <!-- Status for networks disabled for unknown reason -->
    <string name="wifi_disabled_generic">Disabled</string>
    <!-- Status for networked disabled from a DNS or DHCP failure -->
    <string name="wifi_disabled_network_failure">IP Configuration Failure</string>
    <!-- Status for networked disabled from a wifi association failure -->
    <string name="wifi_disabled_wifi_failure">WiFi Connection Failure</string>
    <!-- Status for networks disabled from authentication failure (wrong password
         or certificate). -->
    <string name="wifi_disabled_password_failure">Authentication problem</string>
    <!-- Summary for the remembered network but currently not in range. -->
    <string name="wifi_not_in_range">Not in range</string>
    <!-- Summary for the remembered network but no internet connection was detected. -->
    <string name="wifi_no_internet">No Internet Access Detected, won\'t automatically reconnect.</string>
    <!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
         string is listed first [CHAR LIMIT=20]-->
    <string name="wifi_wps_available_first_item">WPS available</string>
@@ -1602,35 +1583,6 @@
    <!-- Message in WriteWifiConfigToNfcDialog when prompted to enter network password [CHAR_LIMIT=40] -->
    <string name="wifi_wps_nfc_enter_password">Enter your network password</string>

    <!-- Do not translate.  Concise terminology for wifi with WEP security -->
    <string name="wifi_security_short_wep">WEP</string>
    <!-- Do not translate.  Concise terminology for wifi with WPA security -->
    <string name="wifi_security_short_wpa">WPA</string>
    <!-- Do not translate.  Concise terminology for wifi with WPA2 security -->
    <string name="wifi_security_short_wpa2">WPA2</string>
    <!-- Do not translate.  Concise terminology for wifi with both WPA/WPA2 security -->
    <string name="wifi_security_short_wpa_wpa2">WPA/WPA2</string>
    <!-- Do not translate.  Concise terminology for wifi with unknown PSK type -->
    <string name="wifi_security_short_psk_generic">@string/wifi_security_short_wpa_wpa2</string>
    <!-- Do not translate.  Concise terminology for wifi with 802.1x EAP security -->
    <string name="wifi_security_short_eap">802.1x</string>

    <!-- Used in Wi-Fi settings dialogs when Wi-Fi does not have any security. -->
    <string name="wifi_security_none">None</string>

    <!-- Do not translate.  Terminology for wifi with WEP security -->
    <string name="wifi_security_wep">WEP</string>
    <!-- Do not translate.  Terminology for wifi with WPA security -->
    <string name="wifi_security_wpa">WPA PSK</string>
    <!-- Do not translate.  Terminology for wifi with WPA2 security -->
    <string name="wifi_security_wpa2">WPA2 PSK</string>
    <!-- Do not translate.  Terminology for wifi with both WPA/WPA2 security, or unknown -->
    <string name="wifi_security_wpa_wpa2">WPA/WPA2 PSK</string>
    <!-- Do not translate.  Terminology for wifi with unknown PSK type -->
    <string name="wifi_security_psk_generic">@string/wifi_security_wpa_wpa2</string>
    <!-- Do not translate.  Concise terminology for wifi with 802.1x EAP security -->
    <string name="wifi_security_eap">802.1x EAP</string>

    <string name="wifi_scan_always_turnon_message">To improve location accuracy and for other purposes, <xliff:g id="app_name">%1$s</xliff:g> wants to turn on network scanning, even when Wi-Fi is off.\n\nAllow this for all apps that want to scan?</string>
    <!-- Message informing the user how to turn off  [CHAR LIMIT=200] -->
    <string name="wifi_scan_always_turnoff_message">To turn this off, go to Advanced in the overflow menu.</string>
+3 −7
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.provider.Settings;

import com.android.internal.telephony.PhoneStateIntentReceiver;
import com.android.internal.telephony.TelephonyProperties;
import com.android.settingslib.WirelessUtils;

public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListener {

@@ -71,7 +72,7 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene

    public void resume() {
        
        mSwitchPref.setChecked(isAirplaneModeOn(mContext));
        mSwitchPref.setChecked(WirelessUtils.isAirplaneModeOn(mContext));

        mPhoneStateReceiver.registerIntent();
        mSwitchPref.setOnPreferenceChangeListener(this);
@@ -86,11 +87,6 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
        mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
    }

    public static boolean isAirplaneModeOn(Context context) {
        return Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
    }

    private void setAirplaneModeOn(boolean enabling) {
        // Change the system setting
        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 
@@ -113,7 +109,7 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
     * - mobile does not send failure notification, fail on timeout.
     */
    private void onAirplaneModeChanged() {
        mSwitchPref.setChecked(isAirplaneModeOn(mContext));
        mSwitchPref.setChecked(WirelessUtils.isAirplaneModeOn(mContext));
    }
    
    /**
+0 −10
Original line number Diff line number Diff line
@@ -230,16 +230,6 @@ public class WirelessSettings extends SettingsPreferenceFragment
        Log.d(TAG, s);
    }

    public static boolean isRadioAllowed(Context context, String type) {
        if (!AirplaneModeEnabler.isAirplaneModeOn(context)) {
            return true;
        }
        // Here we use the same logic in onCreate().
        String toggleable = Settings.Global.getString(context.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
        return toggleable != null && toggleable.contains(type);
    }

    private boolean isSmsSupported() {
        // Some tablet has sim card but could not do telephony operations. Skip those.
        return mTm.isSmsCapable();
+2 −3
Original line number Diff line number Diff line
@@ -24,14 +24,13 @@ import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Toast;

import com.android.settings.R;
import com.android.settings.WirelessSettings;
import com.android.settings.search.Index;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.WirelessUtils;

/**
 * BluetoothEnabler is a helper to manage the Bluetooth on/off checkbox
@@ -177,7 +176,7 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
    public void onSwitchChanged(Switch switchView, boolean isChecked) {
        // Show toast message if Bluetooth is not allowed in airplane mode
        if (isChecked &&
                !WirelessSettings.isRadioAllowed(mContext, Settings.Global.RADIO_BLUETOOTH)) {
                !WirelessUtils.isRadioAllowed(mContext, Settings.Global.RADIO_BLUETOOTH)) {
            Toast.makeText(mContext, R.string.wifi_in_airplane_mode, Toast.LENGTH_SHORT).show();
            // Reset switch to off
            switchView.setChecked(false);
+0 −741

File deleted.

Preview size limit exceeded, changes collapsed.

Loading