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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations