Search in sources :

Example 51 with WifiManager

use of android.net.wifi.WifiManager in project android_frameworks_base by AOSPA.

the class WifiNetworkAdapter method addSP.

public HomeSP addSP(MOTree instanceTree) throws IOException, SAXException {
    WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    String xml = instanceTree.toXml();
    wifiManager.addPasspointManagementObject(xml);
    return MOManager.buildSP(xml);
}
Also used : WifiManager(android.net.wifi.WifiManager)

Example 52 with WifiManager

use of android.net.wifi.WifiManager in project android_frameworks_base by AOSPA.

the class WifiNetworkAdapter method matchProviderWithCurrentNetwork.

public PasspointMatch matchProviderWithCurrentNetwork(String fqdn) {
    WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    int ordinal = wifiManager.matchProviderWithCurrentNetwork(fqdn);
    return ordinal >= 0 && ordinal < PasspointMatch.values().length ? PasspointMatch.values()[ordinal] : null;
}
Also used : WifiManager(android.net.wifi.WifiManager)

Example 53 with WifiManager

use of android.net.wifi.WifiManager in project android_frameworks_base by AOSPA.

the class WifiNetworkAdapter method loadAllSps.

private void loadAllSps() {
    Log.d(OSUManager.TAG, "Loading all SPs");
    WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    for (WifiConfiguration config : wifiManager.getPrivilegedConfiguredNetworks()) {
        String moTree = config.getMoTree();
        if (moTree != null) {
            try {
                mPasspointConfigs.put(config.FQDN, new PasspointConfig(config));
            } catch (IOException | SAXException e) {
                Log.w(OSUManager.TAG, "Failed to parse MO: " + e);
            }
        }
    }
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 54 with WifiManager

use of android.net.wifi.WifiManager in project qksms by moezbhatti.

the class NetworkIdentity method buildNetworkIdentity.

/**
 * Build a {@link android.net.NetworkIdentity} from the given {@link NetworkState},
 * assuming that any mobile networks are using the current IMSI.
 */
public static NetworkIdentity buildNetworkIdentity(Context context, NetworkState state) {
    final int type = state.networkInfo.getType();
    final int subType = state.networkInfo.getSubtype();
    // TODO: consider moving subscriberId over to LinkCapabilities, so it
    // comes from an authoritative source.
    String subscriberId = null;
    String networkId = null;
    boolean roaming = false;
    if (isNetworkTypeMobile(type)) {
        final TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        roaming = telephony.isNetworkRoaming();
        if (state.subscriberId != null) {
            subscriberId = state.subscriberId;
        } else {
            subscriberId = telephony.getSubscriberId();
        }
    } else if (type == TYPE_WIFI) {
        if (state.networkId != null) {
            networkId = state.networkId;
        } else {
            final WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
            final WifiInfo info = wifi.getConnectionInfo();
            networkId = info != null ? info.getSSID() : null;
        }
    }
    return new NetworkIdentity(type, subType, subscriberId, networkId, roaming);
}
Also used : WifiManager(android.net.wifi.WifiManager) TelephonyManager(android.telephony.TelephonyManager) WifiInfo(android.net.wifi.WifiInfo)

Example 55 with WifiManager

use of android.net.wifi.WifiManager in project qksms by moezbhatti.

the class Transaction method revokeWifi.

/**
 * @deprecated
 */
private void revokeWifi(boolean saveState) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (saveState) {
        settings.currentWifi = wifi.getConnectionInfo();
        settings.currentWifiState = wifi.isWifiEnabled();
        wifi.disconnect();
        settings.discon = new DisconnectWifi();
        context.registerReceiver(settings.discon, new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
        settings.currentDataState = Utils.isMobileDataEnabled(context);
        Utils.setMobileDataEnabled(context, true);
    } else {
        wifi.disconnect();
        wifi.disconnect();
        settings.discon = new DisconnectWifi();
        context.registerReceiver(settings.discon, new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
        Utils.setMobileDataEnabled(context, true);
    }
}
Also used : WifiManager(android.net.wifi.WifiManager) IntentFilter(android.content.IntentFilter)

Aggregations

WifiManager (android.net.wifi.WifiManager)329 WifiInfo (android.net.wifi.WifiInfo)80 WifiConfiguration (android.net.wifi.WifiConfiguration)76 IOException (java.io.IOException)38 Intent (android.content.Intent)27 SuppressLint (android.annotation.SuppressLint)26 ConnectivityManager (android.net.ConnectivityManager)23 Context (android.content.Context)22 NetworkInfo (android.net.NetworkInfo)21 Test (org.junit.Test)20 AccessPoint (com.android.settingslib.wifi.AccessPoint)17 IntentFilter (android.content.IntentFilter)16 Bundle (android.os.Bundle)16 ArrayList (java.util.ArrayList)16 NetworkPolicyEditor (com.android.settingslib.NetworkPolicyEditor)12 PowerManager (android.os.PowerManager)11 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)10 SocketException (java.net.SocketException)10 SharedPreferences (android.content.SharedPreferences)9 Method (java.lang.reflect.Method)9