Class AdbWrapperFactory
java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapperFactory
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final longStandard command execution timeout is 5 seconds. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a wrapper with astandard execution timeout.AdbWrapperFactory(String path) Create a wrapper with astandard execution timeout.AdbWrapperFactory(String path, long defaultTimeout) Create a wrapper. -
Method Summary
Modifier and TypeMethodDescriptionstatic AdbWrapperCreate a standard ADB wrapper using an auto-detected ADB path.createWrapper(String deviceSerial) Create an ADB wrapper to issue command to a specific device, using a default timeout.createWrapper(String deviceSerial, long standardTimeout) Create an ADB wrapper to issue command to a specific device.Find the first available real device or first available emulator.longRetrieve the default command timeout.getPath()Get the path to the ADB binary wrapped by this object.Retrieve the ADB version string.booleanInitialize the factory and start the ADB server if needed.List devices known to ADB.voidsetDefaultTimeout(long millis) Set the default command timeout.booleanStart the ADB server (on the local machine).voidStop the ADB server.toString()
-
Field Details
-
STANDARD_TIMEOUT
public static final long STANDARD_TIMEOUTStandard command execution timeout is 5 seconds.- See Also:
-
-
Constructor Details
-
AdbWrapperFactory
Create a wrapper with astandard execution timeout. The constructor will do its best to determine the path to the ADB program.- Throws:
IOException- if ADB cannot be located
-
AdbWrapperFactory
Create a wrapper with astandard execution timeout.- Parameters:
path- ADB path, set to null for auto-determination- Throws:
IOException- if ADB cannot be located
-
AdbWrapperFactory
Create a wrapper.- Parameters:
path- ADB path, set to null for auto-determinationdefaultTimeout- default command execution timeout in milliseconds (0 means infinite); do not use negative values- Throws:
IOException- if ADB cannot be located
-
-
Method Details
-
createStandardWrapper
Create a standard ADB wrapper using an auto-detected ADB path.- Returns:
- ADB wrapper
- Throws:
IOException- if ADB cannot be located
-
initialize
public boolean initialize()Initialize the factory and start the ADB server if needed.- Returns:
- true if the factory was initialized
-
getPath
Get the path to the ADB binary wrapped by this object.- Returns:
- ADB binary path
-
setDefaultTimeout
public void setDefaultTimeout(long millis) Set the default command timeout.- Parameters:
millis- timeout in milliseconds; 0 means infinite
-
getDefaultTimeout
public long getDefaultTimeout()Retrieve the default command timeout.- Returns:
- timeout in milliseconds; 0 means infinite
-
getVersion
Retrieve the ADB version string.- Returns:
- version string, or null on error
-
startServer
public boolean startServer()Start the ADB server (on the local machine).- Returns:
- true on success
-
stopServer
public void stopServer()Stop the ADB server. -
listDevices
List devices known to ADB.- Returns:
- device list, or null on error
-
findDevice
Find the first available real device or first available emulator.- Returns:
-
createWrapper
Create an ADB wrapper to issue command to a specific device, using a default timeout.- Parameters:
deviceSerial- optional device serial- Returns:
- ADB wrapper
-
createWrapper
Create an ADB wrapper to issue command to a specific device.- Parameters:
deviceSerial- optional device serialstandardTimeout- default command execution timeout in milliseconds- Returns:
- ADB wrapper
-
toString
-