Search in sources :

Example 86 with WifiInfo

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

the class WifiTrackerTest method generateTestNetworks.

private String[] generateTestNetworks(List<WifiConfiguration> wifiConfigs, List<ScanResult> scanResults, boolean connectedIsEphemeral) {
    String[] expectedSsids = new String[NUM_NETWORKS];
    // First is just saved;
    addConfig(wifiConfigs, TEST_SSIDS[0]);
    // This should come last since its not available.
    expectedSsids[4] = TEST_SSIDS[0];
    // Second is saved and available.
    addConfig(wifiConfigs, TEST_SSIDS[1]);
    addResult(scanResults, TEST_SSIDS[1], 0);
    // This one is going to have a couple extra results, to verify de-duplication.
    addResult(scanResults, TEST_SSIDS[1], 2);
    addResult(scanResults, TEST_SSIDS[1], 1);
    // This should come second since it is available and saved but not connected.
    expectedSsids[1] = TEST_SSIDS[1];
    // Third is just available, but higher rssi.
    addResult(scanResults, TEST_SSIDS[2], 3);
    // This comes after the next one since it has a lower rssi.
    expectedSsids[3] = TEST_SSIDS[2];
    // Fourth also just available but with even higher rssi.
    addResult(scanResults, TEST_SSIDS[3], 4);
    // This is the highest rssi but not saved so it should be after the saved+availables.
    expectedSsids[2] = TEST_SSIDS[3];
    // Last is going to be connected.
    int netId = WifiConfiguration.INVALID_NETWORK_ID;
    if (!connectedIsEphemeral) {
        netId = addConfig(wifiConfigs, TEST_SSIDS[4]);
    }
    addResult(scanResults, TEST_SSIDS[4], 2);
    // Setup wifi connection to be this one.
    WifiInfo wifiInfo = Mockito.mock(WifiInfo.class);
    Mockito.when(wifiInfo.getSSID()).thenReturn(TEST_SSIDS[4]);
    Mockito.when(wifiInfo.getNetworkId()).thenReturn(netId);
    Mockito.when(mWifiManager.getConnectionInfo()).thenReturn(wifiInfo);
    // This should come first since it is connected.
    expectedSsids[0] = TEST_SSIDS[4];
    return expectedSsids;
}
Also used : WifiInfo(android.net.wifi.WifiInfo)

Example 87 with WifiInfo

use of android.net.wifi.WifiInfo in project weex-example by KalicyZhou.

the class BXLoginFragment method setLoginInfo.

public EiInfo setLoginInfo() {
    String mUserName = this.accountText.getText().toString();
    String mPassword = this.pwdText.getText().toString();
    String deviceId = TeleUtils.getDeviceId(this.getActivity());
    Constants.DEVICE_ID = deviceId;
    UserSession userSession = UserSession.getUserSession();
    userSession.setUserName(mUserName);
    userSession.setPassWord(mPassword);
    userSession.setUserId(mUserName);
    EiInfo info = new EiInfo();
    info.set("parameter_userid", mUserName);
    info.set("parameter_password", mPassword);
    info.set("parameter_deviceid", deviceId);
    info.set("parameter_globaldeviceid", deviceId);
    info.set("os", "android");
    Log.i("操作系统", "android");
    info.set("osVersion", Build.VERSION.RELEASE);
    Log.i("系统版本", Build.VERSION.RELEASE);
    info.set("network", NetWorkUtil.getNetworkType(this.getActivity()));
    Log.i("网络类型", NetWorkUtil.getNetworkType(this.getActivity()));
    info.set("cpu", Build.CPU_ABI);
    Log.i("CPU型号", Build.CPU_ABI);
    info.set("memery", Long.toString(BXDataManager.getTotalMemery()));
    Log.i("内存容量", Long.toString(BXDataManager.getTotalMemery()));
    info.set("deviceBrand", Build.BRAND);
    Log.i("设备品牌", Build.BRAND);
    WifiManager wifi = (WifiManager) this.getActivity().getSystemService("wifi");
    WifiInfo mWifiInfo = wifi.getConnectionInfo();
    if (mWifiInfo.getMacAddress() == null) {
        info.set("mac", "");
        Log.i("MAC地址", "MAC地址为空");
    } else {
        info.set("mac", mWifiInfo.getMacAddress());
        Log.i("MAC地址", mWifiInfo.getMacAddress());
    }
    DisplayMetrics displaymetrics = new DisplayMetrics();
    this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    float density = displaymetrics.density;
    Log.i("显示密度", density + "");
    info.set("resolution1", (float) displaymetrics.widthPixels * density + "");
    info.set("resolution2", (float) displaymetrics.heightPixels * density + "");
    Log.i("设备的宽", (float) displaymetrics.widthPixels * density + "");
    Log.i("设备的高", (float) displaymetrics.heightPixels * density + "");
    info.set("parameter_clienttypeid", "android");
    info.set("parameter_clienidtversion", Build.MODEL);
    Log.i("设备名称", Build.MODEL);
    return info;
}
Also used : WifiManager(android.net.wifi.WifiManager) UserSession(com.baosight.iplat4mandroid.login.UserSession) EiInfo(com.baosight.iplat4mandroid.core.ei.eiinfo.EiInfo) DisplayMetrics(android.util.DisplayMetrics) WifiInfo(android.net.wifi.WifiInfo)

Example 88 with WifiInfo

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

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 89 with WifiInfo

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

the class WifiTrackerTest method generateTestNetworks.

private String[] generateTestNetworks(List<WifiConfiguration> wifiConfigs, List<ScanResult> scanResults, boolean connectedIsEphemeral) {
    String[] expectedSsids = new String[NUM_NETWORKS];
    // First is just saved;
    addConfig(wifiConfigs, TEST_SSIDS[0]);
    // This should come last since its not available.
    expectedSsids[4] = TEST_SSIDS[0];
    // Second is saved and available.
    addConfig(wifiConfigs, TEST_SSIDS[1]);
    addResult(scanResults, TEST_SSIDS[1], 0);
    // This one is going to have a couple extra results, to verify de-duplication.
    addResult(scanResults, TEST_SSIDS[1], 2);
    addResult(scanResults, TEST_SSIDS[1], 1);
    // This should come second since it is available and saved but not connected.
    expectedSsids[1] = TEST_SSIDS[1];
    // Third is just available, but higher rssi.
    addResult(scanResults, TEST_SSIDS[2], 3);
    // This comes after the next one since it has a lower rssi.
    expectedSsids[3] = TEST_SSIDS[2];
    // Fourth also just available but with even higher rssi.
    addResult(scanResults, TEST_SSIDS[3], 4);
    // This is the highest rssi but not saved so it should be after the saved+availables.
    expectedSsids[2] = TEST_SSIDS[3];
    // Last is going to be connected.
    int netId = WifiConfiguration.INVALID_NETWORK_ID;
    if (!connectedIsEphemeral) {
        netId = addConfig(wifiConfigs, TEST_SSIDS[4]);
    }
    addResult(scanResults, TEST_SSIDS[4], 2);
    // Setup wifi connection to be this one.
    WifiInfo wifiInfo = Mockito.mock(WifiInfo.class);
    Mockito.when(wifiInfo.getSSID()).thenReturn(TEST_SSIDS[4]);
    Mockito.when(wifiInfo.getNetworkId()).thenReturn(netId);
    Mockito.when(mWifiManager.getConnectionInfo()).thenReturn(wifiInfo);
    // This should come first since it is connected.
    expectedSsids[0] = TEST_SSIDS[4];
    return expectedSsids;
}
Also used : WifiInfo(android.net.wifi.WifiInfo)

Example 90 with WifiInfo

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

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)

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