Search in sources :

Example 46 with WifiInfo

use of android.net.wifi.WifiInfo in project android_frameworks_base by crdroidandroid.

the class OSUManager method wnmRemediate.

// !!! Consistently check passpoint match.
// !!! Convert to a one-thread thread-pool
public void wnmRemediate(long bssid, String url, PasspointMatch match) throws IOException, SAXException {
    WifiConfiguration config = mWifiNetworkAdapter.getActiveWifiConfig();
    HomeSP homeSP = MOManager.buildSP(config.getMoTree());
    if (homeSP == null) {
        throw new IOException("Remediation request for unidentified Passpoint network " + config.networkId);
    }
    Network network = mWifiNetworkAdapter.getCurrentNetwork();
    if (network == null) {
        throw new IOException("Failed to determine current network");
    }
    WifiInfo wifiInfo = mWifiNetworkAdapter.getConnectionInfo();
    if (wifiInfo == null || Utils.parseMac(wifiInfo.getBSSID()) != bssid) {
        throw new IOException("Mismatching BSSID");
    }
    Log.d(TAG, "WNM Remediation on " + network.netId + " FQDN " + homeSP.getFQDN());
    doRemediate(url, network, homeSP, false);
}
Also used : HomeSP(com.android.hotspot2.pps.HomeSP) WifiConfiguration(android.net.wifi.WifiConfiguration) Network(android.net.Network) IOException(java.io.IOException) WifiInfo(android.net.wifi.WifiInfo)

Example 47 with WifiInfo

use of android.net.wifi.WifiInfo in project BookReader by JustWayward.

the class NetworkUtils method getConnectWifiIp.

/**
     * 获取当前连接wifi的名称
     *
     * @return
     */
public static String getConnectWifiIp(Context context) {
    if (isWifiConnected(context)) {
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        int ipAddress = wifiInfo.getIpAddress();
        if (ipAddress == 0) {
            return null;
        }
        return ((ipAddress & 0xff) + "." + (ipAddress >> 8 & 0xff) + "." + (ipAddress >> 16 & 0xff) + "." + (ipAddress >> 24 & 0xff));
    }
    return null;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 48 with WifiInfo

use of android.net.wifi.WifiInfo in project zype-android by zype.

the class Utils method getWifiSsid.

/**
 * Returns the SSID of the wifi connection, or <code>null</code> if there is no wifi.
 */
public static String getWifiSsid(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo != null) {
        return wifiInfo.getSSID();
    }
    return null;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 49 with WifiInfo

use of android.net.wifi.WifiInfo 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 50 with WifiInfo

use of android.net.wifi.WifiInfo in project bdcodehelper by boredream.

the class AppUtils method getIP.

public static String getIP(Context context) {
    //获取wifi服务
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    //判断wifi是否开启
    if (!wifiManager.isWifiEnabled()) {
        wifiManager.setWifiEnabled(true);
    }
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    int ipAddress = wifiInfo.getIpAddress();
    String ip = intToIp(ipAddress);
    return ip;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Aggregations

WifiInfo (android.net.wifi.WifiInfo)99 WifiManager (android.net.wifi.WifiManager)53 WifiConfiguration (android.net.wifi.WifiConfiguration)16 NetworkInfo (android.net.NetworkInfo)13 Intent (android.content.Intent)11 IOException (java.io.IOException)8 Test (org.junit.Test)8 Bundle (android.os.Bundle)7 ScanResult (android.net.wifi.ScanResult)6 WifiAssociationTestRunner (com.android.connectivitymanagertest.WifiAssociationTestRunner)6 PendingIntent (android.app.PendingIntent)5 ConnectivityManager (android.net.ConnectivityManager)5 Network (android.net.Network)5 CellIdentityCdma (android.telephony.CellIdentityCdma)5 CellIdentityGsm (android.telephony.CellIdentityGsm)5 CellIdentityLte (android.telephony.CellIdentityLte)5 CellIdentityWcdma (android.telephony.CellIdentityWcdma)5 CellInfo (android.telephony.CellInfo)5 CellInfoCdma (android.telephony.CellInfoCdma)5 CellInfoGsm (android.telephony.CellInfoGsm)5