use of android.net.wifi.WifiInfo in project android_frameworks_base by AOSPA.
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 NewXmPluginSDK by MiEcosystem.
the class XmPluginHostApi method getSubDevice.
/**
* ApiLevel:1 获取子设备
*
* @param didList
* @param callback
*/
public void getSubDevice(String model, String[] didList, final Callback<List<DeviceStat>> callback) {
JSONObject dataObj = new JSONObject();
try {
if (didList != null) {
JSONArray array = new JSONArray();
for (String did : didList) {
array.put(did);
}
dataObj.put("dids", array);
}
WifiManager wifi = (WifiManager) context().getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
String bssid = info != null ? info.getBSSID() : null;
if (!TextUtils.isEmpty(bssid)) {
dataObj.put("uid", bssid.toUpperCase());
}
} catch (JSONException e) {
if (callback != null) {
callback.onFailure(-1, e.toString());
return;
}
}
// [{"uid":103434651,"did":"lumi.158d00005e90f8","mac":"","pd_id":42,"city_id":101010200,"bssid":"","token":"","access_type":3,"localip":"","name":"门窗传感器","ssid":"","longitude":116.330283,"latitude":40.028534,"parent_id":"88292"},{"uid":103434651,"did":"lumi.158d00005e9267","mac":"","pd_id":41,"city_id":0,"bssid":"","token":"","access_type":3,"localip":"","name":"无线开关","ssid":"","longitude":0,"latitude":0,"parent_id":"88292"}]
callSmartHomeApi(model, "/home/sub_device_list", dataObj, callback, new Parser<List<DeviceStat>>() {
@Override
public List<DeviceStat> parse(String resp) throws JSONException {
List<DeviceStat> subDeviceList = new ArrayList<DeviceStat>();
JSONObject response = new JSONObject(resp);
JSONArray array = response.optJSONArray("list");
if (array == null)
return subDeviceList;
for (int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
DeviceStat result = new DeviceStat();
result.did = object.optString("did");
result.model = object.optString("model");
result.name = object.optString("name");
result.bindFlag = object.optInt("adminFlag");
result.authFlag = object.optInt("shareFlag");
// result.resetFlag = object.optInt("resetFlag");
// result.rssi = object.optInt("rssi", 0);
// if ((result.bindFlag ==
// MiioDBConst.BIND_FLAG_UNSET
// && result.authFlag ==
// MiioDBConst.AUTH_FLAG_UNSET)) {
// result.token = "";
// } else {
// result.token = object.optString("token");
// }
result.ip = object.optString("localip");
// result.latitude = object.optDouble("latitude");
// result.longitude = object.optDouble("longitude");
// result.propInfo = object.optJSONObject("prop");
result.mac = object.optString("mac");
result.parentModel = object.optString("parent_model");
result.parentId = object.optString("parent_id");
// // 对于子设备,一律认为在线
// if (!TextUtils.isEmpty(result.parentId)) {
// result.isOnline = true;
// } else {
// result.isOnline = object.optBoolean("isOnline");
// }
result.isOnline = object.optBoolean("isOnline");
subDeviceList.add(result);
}
return subDeviceList;
}
});
}
use of android.net.wifi.WifiInfo in project JustAndroid by chinaltz.
the class AbAppUtil method getSSID.
/**
* 获取SSID地址.
*
* @param context
* @return
*/
public static String getSSID(Context context) {
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
if (info.getSSID() == null) {
return null;
} else {
return info.getSSID();
}
}
use of android.net.wifi.WifiInfo in project smartmodule by carozhu.
the class DeviceInfoUtil method getMacWifi.
/**
* 1)硬件限制:并不是所有的设备都有Wifi和蓝牙硬件,硬件不存在自然也就得不到这一信息。
* 2)获取的限制:如果Wifi没有打开过,是无法获取其Mac地址的;而蓝牙是只有在打开的时候才能获取到其Mac地址。
*
* @param context
* @return
*/
public static String getMacWifi(Context context) {
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
String s = info.getMacAddress();
if (s != null) {
return s;
}
return "";
}
use of android.net.wifi.WifiInfo in project dobby-android by InceptAi.
the class WifiAnalyzer method initializeWifiState.
private void initializeWifiState() {
Preconditions.checkNotNull(wifiManager);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
//Switch thread and do this.
wifiState.updateWifiStats(new DobbyWifiInfo(wifiInfo), null);
registerWifiStateReceiver();
//Publish detailed connection state and wifi state on the bus
updateWifiStatsDetailedState(WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState()));
processWifiStateChanged(wifiManager.getWifiState());
}
Aggregations