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

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

Move Settings wifi tracking to SettingsLib

Make SettingsLib capable of tracking which wifi networks are
available/saved and their state.

Also modify Quick Settings to use this code rather than having
its own logic.

Bug: 19180466
Change-Id: Iff9f9aed240d79323dba41496496e8076b9fa6f2
parent 1a81b83e
Loading
Loading
Loading
Loading
+81 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2015 The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <!-- Wi-Fi settings -->

    <!-- Match this with the order of NetworkInfo.DetailedState. --> <skip />
    <!-- Wi-Fi settings. The status messages when the network is unknown. -->
    <string-array name="wifi_status">
        <!-- Status message of Wi-Fi when it is idle. -->
        <item></item>
        <!-- Status message of Wi-Fi when it is scanning. -->
        <item>Scanning\u2026</item>
        <!-- Status message of Wi-Fi when it is connecting. -->
        <item>Connecting\u2026</item>
        <!-- Status message of Wi-Fi when it is authenticating. -->
        <item>Authenticating\u2026</item>
        <!-- Status message of Wi-Fi when it is obtaining IP address. -->
        <item>Obtaining IP address\u2026</item>
        <!-- Status message of Wi-Fi when it is connected. -->
        <item>Connected</item>
        <!-- Status message of Wi-Fi when it is suspended. -->
        <item>Suspended</item>
        <!-- Status message of Wi-Fi when it is disconnecting. -->
        <item>Disconnecting\u2026</item>
        <!-- Status message of Wi-Fi when it is disconnected. -->
        <item>Disconnected</item>
        <!-- Status message of Wi-Fi when it is a failure. -->
        <item>Unsuccessful</item>
        <!-- Status message of Wi-Fi when it is blocked. -->
        <item>Blocked</item>
        <!-- Status message of Wi-Fi when connectiong is being verified. -->
        <item>Temporarily avoiding poor connection</item>
    </string-array>

    <!-- Match this with the order of NetworkInfo.DetailedState. --> <skip />
    <!-- Wi-Fi settings. The status messages when the network is known. -->
    <string-array name="wifi_status_with_ssid">
        <!-- Status message of Wi-Fi when it is idle. -->
        <item></item>
        <!-- Status message of Wi-Fi when it is scanning. -->
        <item>Scanning\u2026</item>
        <!-- Status message of Wi-Fi when it is connecting to a network. -->
        <item>Connecting to <xliff:g id="network_name">%1$s</xliff:g>\u2026</item>
        <!-- Status message of Wi-Fi when it is authenticating with a network. -->
        <item>Authenticating with <xliff:g id="network_name">%1$s</xliff:g>\u2026</item>
        <!-- Status message of Wi-Fi when it is obtaining IP address from a network. -->
        <item>Obtaining IP address from <xliff:g id="network_name">%1$s</xliff:g>\u2026</item>
        <!-- Status message of Wi-Fi when it is connected to a network. -->
        <item>Connected to <xliff:g id="network_name">%1$s</xliff:g></item>
        <!-- Status message of Wi-Fi when it is suspended. -->
        <item>Suspended</item>
        <!-- Status message of Wi-Fi when it is disconnecting from a network. -->
        <item>Disconnecting from <xliff:g id="network_name">%1$s</xliff:g>\u2026</item>
        <!-- Status message of Wi-Fi when it is disconnected. -->
        <item>Disconnected</item>
        <!-- Status message of Wi-Fi when it is a failure. -->
        <item>Unsuccessful</item>
        <!-- Status message of Wi-Fi when it is blocked. -->
        <item>Blocked</item>
        <!-- Status message of Wi-Fi when connectiong is being verified. -->
        <item>Temporarily avoiding poor connection</item>
    </string-array>
</resources>
+49 −0
Original line number Diff line number Diff line
@@ -18,4 +18,53 @@
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Toast message when Wi-Fi cannot scan for networks -->
    <string name="wifi_fail_to_scan">Can\'t scan for networks</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>

    <!-- 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>

    <!-- 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>
</resources>
+0 −0

Empty file deleted.

+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.settingslib;

import android.content.Context;
import android.provider.Settings;

public class WirelessUtils {

    public static boolean isRadioAllowed(Context context, String type) {
        if (!isAirplaneModeOn(context)) {
            return true;
        }
        String toggleable = Settings.Global.getString(context.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
        return toggleable != null && toggleable.contains(type);
    }

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

}
+739 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading