Class AdbWrapperFactory

java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapperFactory

public class AdbWrapperFactory extends Object
A factory for ADB controllers. This object is also used to issue general (device independent) adb commands, such as adb start-server, adb devices, etc. Most methods in this class return null on error.

If an adb server exists, it is used as-is. If one needs to be created, it will be spawned the first time a real adb command is issued (the client can explicitly request it using initialize()). Default listening settings are used, that is: tcp:localhost:5037.

Thread-safe.

See Also:
  • Field Details

    • STANDARD_TIMEOUT

      public static final long STANDARD_TIMEOUT
      Standard command execution timeout is 5 seconds.
      See Also:
  • Constructor Details

    • AdbWrapperFactory

      public AdbWrapperFactory() throws IOException
      Create a wrapper with a standard execution timeout. The constructor will do its best to determine the path to the ADB program.
      Throws:
      IOException
    • AdbWrapperFactory

      public AdbWrapperFactory(String path) throws IOException
      Create a wrapper with a standard execution timeout.
      Parameters:
      path - ADB path, set to null for auto-determination
      Throws:
      IOException
    • AdbWrapperFactory

      public AdbWrapperFactory(String path, long defaultTimeout) throws IOException
      Create a wrapper.
      Parameters:
      path - ADB path, set to null for auto-determination
      defaultTimeout - default command execution timeout in milliseconds (0 means infinite); do not use negative values
      Throws:
      IOException
  • Method Details

    • createStandardWrapper

      public static AdbWrapper createStandardWrapper() throws IOException
      Throws:
      IOException
    • initialize

      public boolean initialize()
    • getPath

      public String getPath()
      Get the path to the ADB binary wrapped by this object.
      Returns:
    • setDefaultTimeout

      public void setDefaultTimeout(long millis)
    • getDefaultTimeout

      public long getDefaultTimeout()
    • getVersion

      public String getVersion()
      Retrieve the ADB version string.
      Returns:
    • startServer

      public boolean startServer()
      Start the ADB server (on the local machine).
      Returns:
    • stopServer

      public void stopServer()
      Stop the ADB server.
    • listDevices

      public List<AdbDevice> listDevices()
    • createWrapper

      public AdbWrapper createWrapper(String deviceSerial)
      Create an ADB wrapper to issue command to a specific device, using a default timeout.
      Parameters:
      deviceSerial - optional device serial
      Returns:
    • createWrapper

      public AdbWrapper createWrapper(String deviceSerial, long standardTimeout)
      Create an ADB wrapper to issue command to a specific device.
      Parameters:
      deviceSerial -
      standardTimeout -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object