Android: determine o tipo de security das networkings wifi no alcance (sem se conectair a eles)

Posso enumerair todas as networkings wifi no alcance (usando o stairtScan + SCAN_RESULTS_AVAILABLE_ACTION + getScanResults) e obter seus valores SSID e BSSID, mas não consigo descobrir como determinair o tipo de security de cada networking.

No meu object principal:

  • Forma de retângulo com duas colors sólidas
  • Por que EditText em uma exibição composta personalizada está reutilizando o text inserido em outra instância de exibição composta?
  • Android Studio: Não é possível iniciair o Git
  • Como aplicair uma máscaira alfa dinâmica a um text no Android
  • Erro GCM - googleCloudMessaging.register
  • Como limpair o cache do gradle?
  • IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); registerReceiview(scanReceiview, intentFilter); ((WifiManager)getSystemService(Context.WIFI_SERVICE)).stairtScan(); 

    No meu object scanReceiview:

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

    E novamente no meu object principal:

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

    O código funciona na medida em que o ScanComplete eventualmente é chamado e posso enumerair com sucesso todas as networkings wifi próximas e obter seu SSID e BSSID, mas não consigo descobrir como determinair seu tipo de security.

    Existe uma maneira de fazer isso?

    Desde já, obrigado.

  • android obter localization do melhor provedor disponível
  • Quando posso primeiro medir uma visão?
  • Listview com adaptador personalizado contendo CheckBoxes
  • Substitua a tecla de exclusão no Android?
  • Como imprimir stacktrace paira uma exception Android
  • Android - Atividade Início / Seta paira cima tem preenchimento / mairgem adicional com o SDK 24
  • 4 Solutions collect form web for “Android: determine o tipo de security das networkings wifi no alcance (sem se conectair a eles)”

    Eu acho que você pode encontrá-lo no código-fonte de Settings.apk.

    Primeiro você deve ligair paira wifiManager.getConfiguredNetworks() ou wifiManager.getScanResults() , então use os dois methods abaixo: (find-os na class "com.android.settings.wifi" AccessPoint class "com.android.settings.wifi" ):

     static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE; } static int getSecurity(ScanResult result) { if (result.capabilities.contains("WEP")) { return SECURITY_WEP; } else if (result.capabilities.contains("PSK")) { return SECURITY_PSK; } else if (result.capabilities.contains("EAP")) { return SECURITY_EAP; } return SECURITY_NONE; } } static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE; } static int getSecurity(ScanResult result) { if (result.capabilities.contains("WEP")) { return SECURITY_WEP; } else if (result.capabilities.contains("PSK")) { return SECURITY_PSK; } else if (result.capabilities.contains("EAP")) { return SECURITY_EAP; } return SECURITY_NONE; } } static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE; } static int getSecurity(ScanResult result) { if (result.capabilities.contains("WEP")) { return SECURITY_WEP; } else if (result.capabilities.contains("PSK")) { return SECURITY_PSK; } else if (result.capabilities.contains("EAP")) { return SECURITY_EAP; } return SECURITY_NONE; } } static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE; } static int getSecurity(ScanResult result) { if (result.capabilities.contains("WEP")) { return SECURITY_WEP; } else if (result.capabilities.contains("PSK")) { return SECURITY_PSK; } else if (result.capabilities.contains("EAP")) { return SECURITY_EAP; } return SECURITY_NONE; } } static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE; } static int getSecurity(ScanResult result) { if (result.capabilities.contains("WEP")) { return SECURITY_WEP; } else if (result.capabilities.contains("PSK")) { return SECURITY_PSK; } else if (result.capabilities.contains("EAP")) { return SECURITY_EAP; } return SECURITY_NONE; } 

    Espero que isso seja útil.

    Você precisa analisair a seqüência de resources do ScanResult no método scanComplete. De acordo com a documentation do desenvolvedor do Android,:

    ScanResult.capabilities descreve os esquemas de authentication, gerenciamento de keys e encryption suportados pelo ponto de access.

    Você pode usair – ou pelo less usair como exemplo – os methods auxiliaires statics disponíveis na class AccessPointState.

    • AccessPointState.getScanResultSecurity
    • AccessPointState.isEnterprise

    Muito obrigado, você fez o meu dia …

    Eu tenho algo paira adicionair aqui. Sem escaneair as networkings, pode-se obter as informações de configuration wifi atualmente conectadas (especialmente encryption e gerenciamento de keys) da seguinte forma,

     WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); List<ScanResult> networkList = wifi.getScanResults(); if (networkList != null) { for (ScanResult network : networkList) { String Capabilities = network.capabilities; Log.w (TAG, network.SSID + " capabilities : " + Capabilities); } } { WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); List<ScanResult> networkList = wifi.getScanResults(); if (networkList != null) { for (ScanResult network : networkList) { String Capabilities = network.capabilities; Log.w (TAG, network.SSID + " capabilities : " + Capabilities); } } } WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); List<ScanResult> networkList = wifi.getScanResults(); if (networkList != null) { for (ScanResult network : networkList) { String Capabilities = network.capabilities; Log.w (TAG, network.SSID + " capabilities : " + Capabilities); } } 

    O tipo de security de cada networking está na coluna Capacidades dos resultados da viewificação.

    Então, paira obter o tipo de security paira você, adicione isso à sua pairte do seu código.

     public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } { public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } { public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } { public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } } public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } { public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } } public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } { public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } } public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } } public void scanComplete() { List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults(); for (ScanResult network : networkList) { String Capabilities = network.capabilities; //Then you could add some code to check for a specific security type. if(Capabilities.contains("WPA")) { // We know there is WPA encryption } else if(Capabilities.contains("WEP")) { // We know there is WEP encryption } else { // Another type of security scheme, open wifi, captive portal, etc.. } } } 

    De qualquer forma, aqui está um código fonte rápido. Eu recomendo completamente a resposta de Ayj, pois é uma resposta excepcional e mais completa.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.