Android Open Source - Android-Wireless testing Suite






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 generics;
/*w w  w . j  a  v  a2  s  .c  o m*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;

import android.util.Log;

/**
 * A Class for testing basic network functionality
 * @author Michael Leith
 */
public class testingSuite {
  /**
   * Pings the provided address.
   * Put in a thread!!
   * @param pingAddr
   */
  static public final void runPing(final String pingAddr, final int time)
  {
      //String pingResult = "";
    new Thread(new Runnable(){
      public void run()
      {
        String pingCmd = "ping " + pingAddr;
        try {
          Runtime r = Runtime.getRuntime();
          //Process p = r.exec(pingCmd);
          
          BufferedReader in = new BufferedReader(new InputStreamReader( r.exec(pingCmd).getInputStream()) );//p.getInputStream()));
          String inputLine;
          int i = 0;
          while ((inputLine = in.readLine()) != null && i < time) 
          {
            Log.d("ping", inputLine);
            i++;
                 // pingResult += inputLine;
          }
          in.close();

        } catch (IOException e) 
        {
          Log.e("runPing", e.toString());
        }
      }
    }).start();
    }
  
  /**
   * Gets the current Ip Address, printing it to logcat with the tage "Ip Address"
   */
  static public final void getIpAddress() {
      try {
          for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
                  .hasMoreElements();) {
              NetworkInterface intf = en.nextElement();
              if (intf.getName().contains("wlan")) {
                  for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr
                          .hasMoreElements();) {
                      InetAddress inetAddress = enumIpAddr.nextElement();
                      if (!inetAddress.isLoopbackAddress()
                              && (inetAddress.getAddress().length == 4)) {
                          Log.d("Ip Address", inetAddress.getHostAddress());
                      }
                  }
              }
          }
      } catch (Exception e) {
          Log.e("Ip Address", e.toString());
      }
  }
}




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