Android Open Source - Android-Wireless Client Scanner






From Project

Back to project page Android-Wireless.

License

The source code is released under:

MIT License

If you think the Android project Android-Wireless listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.Nimble.WifiAP;
/*from w  ww  .ja  v  a 2  s  . c  o m*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import android.util.Log;

import com.Nimble.WifiAP.scanActivity.FinishScanListener;

public class ClientScanner {

  /**
   * Gets a list of the clients connected to the Hotspot
   * @param finishListener, Interface to return client list to.
   */
  static public final void getClients(final FinishScanListener finishListener)
  {
    Log.e("Client Scan", "Starting");
    new Thread (new Runnable() {
      public void run() {
        try{
          BufferedReader reader = new BufferedReader(new FileReader("/proc/net/arp"));
          finishListener.onFinishScan(parseClients(reader));
        }
        catch(Exception e) {}
        Log.e("Client Scan", "Finished");
      }
    }).run();
  }
  
  /** 
   * Function to parse ARP response packet. Extracts ip, mac, and connection type.
   * @param reader
   * @return
   * @throws Exception
   */
  static public final ArrayList<ClientInfo> parseClients(BufferedReader reader) throws Exception
  {
    String temp;
    ArrayList<ClientInfo> list = new ArrayList<ClientInfo>();
    while( ( temp = reader.readLine() ) != null )
    {
      //Log.wtf("parseClients", temp);
      String[] splited = temp.split("\\s+"); //Split by whitespace
      
      if(splited != null && splited[3].matches("..:..:..:..:..:..") ) // Exists & has a mac address in this line.
        list.add( new ClientInfo(splited[0], splited[3], splited[5]) ); //use ping to test
    }
    return list;
  }
}




Java Source Code List

com.Nimble.Server.ServerActivity.java
com.Nimble.Server.Server.java
com.Nimble.Server.Sockets.java
com.Nimble.WifiAP.ClientInfo.java
com.Nimble.WifiAP.ClientScanner.java
com.Nimble.WifiAP.HardwareStateManager.java
com.Nimble.WifiAP.MainWiFiAPActivity.java
com.Nimble.WifiAP.WifiAP.java
com.Nimble.WifiAP.scanActivity.java
generics.Methods.java
generics.testingSuite.java