机器人:确定范围内的WiFi网络的安全型(无连接到它们) [英] android: Determine security type of wifi networks in range (without connecting to them)

查看:256
本文介绍了机器人:确定范围内的WiFi网络的安全型(无连接到它们)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以枚举所有的WiFi网络的范围(使用startScan + SCAN_RESULTS_AVAILABLE_ACTION + getScanResults),并得到他们的SSID和BSSID值,但我无法弄清楚如何确定每个网络的安全类型。

I can enumerate all wifi networks in range (using startScan + SCAN_RESULTS_AVAILABLE_ACTION + getScanResults) and get their SSID and BSSID values, but I can't figure out how to determine the security type of each network.

在我的主要目标:

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
    registerReceiver(scanReceiver, intentFilter);
    ((WifiManager)getSystemService(Context.WIFI_SERVICE)).startScan();

在我scanReceiver对象:

In my scanReceiver object:

public void onReceive(Context c, Intent intent) {
    if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(intent.getAction())){
        mainObject.scanComplete();
    }
}

和又在我的主要目标:

public void scanComplete()
{
    List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults();
    for (ScanResult network : networkList)
    {
        <do stuff>
    }
}

在code工作范围内的scanComplete最终被调用,我可以成功地枚举所有附近的WiFi网络,并得到他们的SSID和BSSID,但我无法弄清楚如何确定其安全性类型。

The code works insofar that scanComplete eventually gets called, and I can successfully enumerate all nearby wifi networks and get their SSID and BSSID, but I can't figure out how to determine their security type.

有没有办法做到这一点?

Is there a way to do this?

在此先感谢。

推荐答案

您需要解析ScanResult的能力字符串中的scanComplete方法。按照 Android开发者文档,:

You need to parse the ScanResult's capabilities string in the scanComplete method. According to the Android developer documentation, :

ScanResult.capabilities描述了认证,密钥管理,并且   加密方案支持的接入点

ScanResult.capabilities describes the authentication, key management, and encryption schemes supported by the access point.

您也许可以利用 - 或者至少是作为一个例子 - 在AccessPointState类可用静态辅助方法。

You might be able to make use of -- or at the very least use as an example -- the static helper methods available in the AccessPointState class.

  • <一个href="http://$c$c.google.com/p/pdn-slatedroid/source/browse/trunk/eclair/packages/apps/Settings/src/com/android/settings/wifi/AccessPointState.java?r=51#318">AccessPointState.getScanResultSecurity
  • <一个href="http://$c$c.google.com/p/pdn-slatedroid/source/browse/trunk/eclair/packages/apps/Settings/src/com/android/settings/wifi/AccessPointState.java?r=51#340">AccessPointState.isEnterprise
  • AccessPointState.getScanResultSecurity
  • AccessPointState.isEnterprise

这篇关于机器人:确定范围内的WiFi网络的安全型(无连接到它们)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆