Receive non-connected devices when my device is in pairing mode

I activate the binding mode with this code:

private void setWifiTetheringEnabled(boolean enable) { WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); Method[] methods = wifiManager.getClass().getDeclaredMethods(); for (Method method : methods) { Log.e("teste", method.getName()); if (method.getName().equals("setWifiApEnabled")) { try { method.invoke(wifiManager, null, enable); } catch (Exception ex) { } break; } } } 

and I get devices connected using this code (and reading information)

  br = new BufferedReader(new FileReader("/proc/net/arp")); 

but in this file (/ proc / net / arp) there are only connected devices, I want to get information (Mac address) about the device that just checked my phone in pairing mode.

ntcfg execution of my return:

  04-10 10:32:27.908: E/test(18908): dummy0 DOWN 0.0.0.0/0 0x00000082 xx:xx:b6:69:37:4e 04-10 10:32:27.908: E/test(18908): wlan0 UP 192.168.43.1/24 0x00001043 xx:xx:11:f9:a9:45 04-10 10:32:27.908: E/test(18908): rmnet_usb0 UP 100.107.189.66/30 0x00000041 00:00:00:00:00:00 04-10 10:32:27.908: E/test(18908): rmnet_usb1 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00 04-10 10:32:27.908: E/test(18908): rmnet_usb2 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00 04-10 10:32:27.908: E/test(18908): rmnet_usb3 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00 04-10 10:32:27.908: E/test(18908): lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00 04-10 10:32:27.908: E/test(18908): sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00 04-10 10:32:27.908: E/test(18908): rmnet_smux0 DOWN 0.0.0.0/0 0x00001002 xx:6f:06:64:e2:61 04-10 10:32:27.908: E/test(18908): rmnet0 DOWN 0.0.0.0/0 0x00001002 xx:xx:a4:fe:a4:e5 04-10 10:32:27.908: E/test(18908): rmnet1 DOWN 0.0.0.0/0 0x00001002 xx:x:68:34:70:29 04-10 10:32:27.908: E/test(18908): rmnet2 DOWN 0.0.0.0/0 0x00001002 xx:xx:ac:a5:b3:a1 04-10 10:32:27.908: E/test(18908): rmnet3 DOWN 0.0.0.0/0 0x00001002 xx:xx:1b:af:02:fe 04-10 10:32:27.908: E/test(18908): rmnet4 DOWN 0.0.0.0/0 0x00001002 xx:xx:32:79:22:e7 04-10 10:32:27.908: E/test(18908): rmnet5 DOWN 0.0.0.0/0 0x00001002 xx:xx:9b:4c:93:c5 04-10 10:32:27.908: E/test(18908): rmnet6 DOWN 0.0.0.0/0 0x00001002 xx:xx:1a:1e:86:e8 04-10 10:32:27.908: E/test(18908): rmnet7 DOWN 0.0.0.0/0 0x00001002 xx:xx:46:f0:c5:48 04-10 10:32:27.908: E/test(18908): rev_rmnet2 DOWN 0.0.0.0/0 0x00001002 xx:xx:98:22:6f:fb 04-10 10:32:27.908: E/test(18908): rev_rmnet3 DOWN 0.0.0.0/0 0x00001002 xx:xx:8d:bf:3e:50 04-10 10:32:27.908: E/test(18908): rev_rmnet4 DOWN 0.0.0.0/0 0x00001002 xx:xx:f4:c0:81:ae 04-10 10:32:27.908: E/test(18908): rev_rmnet5 DOWN 0.0.0.0/0 0x00001002 xx:xx:29:94:d5:e5 04-10 10:32:27.908: E/test(18908): rev_rmnet6 DOWN 0.0.0.0/0 0x00001002 xx:xx:41:39:44:db 04-10 10:32:27.908: E/test(18908): rev_rmnet7 DOWN 0.0.0.0/0 0x00001002 xx:xx:4b:0b:13:18 04-10 10:32:27.908: E/test(18908): rev_rmnet8 DOWN 0.0.0.0/0 0x00001002 xx:xx:64:4f:b4:f6 04-10 10:32:27.908: E/test(18908): rev_rmnet0 DOWN 0.0.0.0/0 0x00001002 xx:xx:f4:d2:ae:66 04-10 10:32:27.908: E/test(18908): rev_rmnet1 DOWN 0.0.0.0/0 0x00001002 xx:xx:8d:f0:64:2a 
+7
android android wifi tethering
source share
1 answer

Call exec("netcfg") ;


 /** * Execute a command in a shell * * @param command * command to execute * @return the return of the command */ public String exec(String command) { String retour = ""; try { Runtime runtime = Runtime.getRuntime(); Process p = runtime.exec(command); java.io.BufferedReader standardIn = new java.io.BufferedReader( new java.io.InputStreamReader(p.getInputStream())); java.io.BufferedReader errorIn = new java.io.BufferedReader( new java.io.InputStreamReader(p.getErrorStream())); String line = ""; while ((line = standardIn.readLine()) != null) { retour += line + "\n"; } while ((line = errorIn.readLine()) != null) { retour += line + "\n"; } } catch (java.io.IOException e) { e.printStackTrace(); } return retour; } 

It will execute the "netcfg" command in the shell and output as follows

 lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00 sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00 eth0 UP 0.0.0.0/0 0x00001003 78:c5:e5:a2:b2:d0 wlan0 DOWN 0.0.0.0/0 0x00001002 64:70:02:20:79:31 

Includes connected network interfaces , status , IP obtained & MAC address .

The last field is for the MAC address. You must parse the MAC address from this separate line.

-one
source share

All Articles