Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Wi-Fi Scan: Filter printers from ScanResult

I am working on a project, that needs to scan for public Wi-Fi access points.

Currently, I am filtering the ScanResult like this:

for (ScanResult scanResult : wifiList) {
  if (!(scanResult.capabilities.contains("WEP") || 
        scanResult.capabilities.contains("WPA") || 
        scanResult.capabilities.contains("WPA2"))) {

              openWifiList.add(scanResult);    

  }
}

It works fine, except that I also get printers that are nearby.

While scanning, the phone is not connected to any network.

I would have assumed that I get a list that is identically with the list of Wi-Fi connections that is shown in the Wi-Fi Settings on Android. But in the Wi-Fi Setting there is no printer shown ever.

So for 1) I think it is strange that printers show up in the ScanResult list at all, should printers really be visible that way?


UPDATE: not all Wi-Fi printers are visible, I got some hints on that, and it seems like the printers that are showing up, do have a special functionality, e.g. HP printers support the HP Wireless Direct functionality (see e.g. https://h30434.www3.hp.com/t5/Inkjet-Printing/Printer-SSID-appearing-on-my-wi-fi-list/td-p/1705073 and https://support.hp.com/rs-en/document/c04577030).


And 2) is there any way that I could check whether the ScanResult belongs to a printer?

So far I could only think of filtering for common SSID names, but that will not be very efficient or reliable.

Thanks for any suggestions.

like image 250
soey Avatar asked Jul 12 '17 10:07

soey


People also ask

How often does Android scan Wi-Fi?

Android 9: Each foreground app can scan four times in a 2-minute period. This allows for a burst of scans in a short time. All background apps combined can scan one time in a 30-minute period.


1 Answers

1) Not all printers support the WiFi Direct protocol, HP supports this and also their proprietary protocol you've mentioned (HP Wireless Direct), though your device probably doesn't support it without HP software.

Learn more about connecting to WiFi Direct protocol from Android here.

2) WiFi direct discovery returns String fullDomain, if it contains _ipp - that's most likely a printer.

like image 121
Amir Uval Avatar answered Sep 23 '22 16:09

Amir Uval