Search in sources :

Example 51 with WifiInfo

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

the class PieHelper method getWifiSsid.

public String getWifiSsid() {
    String ssid = mContext.getString(R.string.quick_settings_wifi_not_connected);
    ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (networkInfo.isConnected()) {
        final WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
        final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        ssid = connectionInfo.getSSID();
    }
    return ssid.toUpperCase();
}
Also used : WifiManager(android.net.wifi.WifiManager) NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) WifiInfo(android.net.wifi.WifiInfo)

Example 52 with WifiInfo

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

the class WifiAssociationTest method testWifiAssociation.

/**
     * Test that the wifi can associate with a given access point.
     */
@LargeTest
public void testWifiAssociation() {
    WifiAssociationTestRunner runner = (WifiAssociationTestRunner) getInstrumentation();
    Bundle arguments = runner.getArguments();
    String ssid = arguments.getString("ssid");
    assertNotNull("ssid is empty", ssid);
    String securityTypeStr = arguments.getString("security-type");
    assertNotNull("security-type is empty", securityTypeStr);
    SecurityType securityType = SecurityType.valueOf(securityTypeStr);
    String password = arguments.getString("password");
    String freqStr = arguments.getString("frequency-band");
    if (freqStr != null) {
        setFrequencyBand(freqStr);
    }
    assertTrue("enable Wifi failed", enableWifi());
    WifiInfo wi = mWifiManager.getConnectionInfo();
    logv("%s", wi);
    assertNotNull("no active wifi info", wi);
    WifiConfiguration config = getConfig(ssid, securityType, password);
    logv("Network config: %s", config.toString());
    connectToWifi(config);
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) Bundle(android.os.Bundle) WifiAssociationTestRunner(com.android.connectivitymanagertest.WifiAssociationTestRunner) WifiInfo(android.net.wifi.WifiInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 53 with WifiInfo

use of android.net.wifi.WifiInfo in project JustAndroid by chinaltz.

the class AbAppUtil method getMac.

/**
     * 获取mac地址.
     *
     * @param context
     * @return
     */
public static String getMac(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    if (info.getMacAddress() == null) {
        return null;
    } else {
        return info.getMacAddress();
    }
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 54 with WifiInfo

use of android.net.wifi.WifiInfo in project SmartAndroidSource by jaychou2012.

the class SystemInfo method getWifiInfo.

/**
	 * ��ȡWifiInfo���󣬽�����ȡwifi�����Ϣ
	 * 
	 * @param wifiOpen
	 *            WIFI�Ƿ�����������
	 * @return WifiInfo����ͨ������WifiInfo���������ط�����ȡ��Ӧ��Ϣ</br> wifiInfo.getBSSID();//
	 *         ��ȡBSSID��ַ</br> wifiInfo.getSSID();// ��ȡSSID��ַ, ��Ҫ���������ID</br>
	 *         wifiInfo.getIpAddress();// ��ȡIP��ַ,4�ֽ�Int,XXX.XXX.XXX.XXX
	 *         ÿ��XXXΪһ���ֽ�</br> wifiInfo.getMacAddress();//��ȡMAC��ַ </br>
	 *         wifiInfo.getNetworkId();//��ȡ����ID</br>
	 *         wifiInfo.getLinkSpeed();//��ȡ�����ٶȣ��������û���֪��һ��Ϣ</br>
	 *         wifiInfo.getRssi();//��ȡRSSI��RSSI���ǽ����ź�ǿ��ָʾ</br>
	 */
public WifiInfo getWifiInfo(boolean wifiOpen) {
    if (wifiOpen) {
        WifiManager wifi_service = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifi_service.getConnectionInfo();
        StringBuilder sb = new StringBuilder();
        // ��ȡBSSID��ַ
        sb.append(wifiInfo.getBSSID());
        // ��ȡSSID��ַ, ��Ҫ���������ID
        sb.append(wifiInfo.getSSID());
        // ��ȡIP��ַ,4�ֽ�Int, XXX.XXX.XXX.XXX
        sb.append(wifiInfo.getIpAddress());
        // ÿ��XXXΪһ���ֽ�
        // ��ȡMAC��ַ
        sb.append(wifiInfo.getMacAddress());
        // ��ȡ����ID
        sb.append(wifiInfo.getNetworkId());
        // ��ȡ�����ٶȣ��������û���֪��һ��Ϣ
        sb.append(wifiInfo.getLinkSpeed());
        // ��ȡRSSI��RSSI���ǽ����ź�ǿ��ָʾ
        sb.append(wifiInfo.getRssi());
        // Log.i("info", sb+"");
        return wifiInfo;
    }
    return null;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 55 with WifiInfo

use of android.net.wifi.WifiInfo in project SmartAndroidSource by jaychou2012.

the class SystemInfo method getWifiRssi.

/**
	 * getWifiRssi (Signal strength:0 to -100)
	 * 
	 * @return the wifi's Rssi(Signal strength:0 to -100)
	 */
public int getWifiRssi() {
    WifiManager wifi_service = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifi_service.getConnectionInfo();
    return wifiInfo.getRssi();
}
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