-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public abstract class AbsAdbConnectionManager implements Closeable
-
-
Method Summary
Modifier and Type Method Description voidsetHostAddress(@NonNull() String hostAddress)Set host address for this connection. StringgetHostAddress()Get host address for this connection. voidsetApi(int api)Set Android API (i.e. intgetApi()Get Android API (i.e. voidsetTimeout(long timeout, TimeUnit unit)Set time to wait for the connection to be made. longgetTimeout()Get time to wait for the connection to be made. TimeUnitgetTimeoutUnit()Get the unit for the timeout. voidsetThrowOnUnauthorised(boolean throwOnUnauthorised)Set whether to throw AdbAuthenticationFailedException if the daemon rejects the first authenticationattempt. booleanisThrowOnUnauthorised()Get whether to throw AdbAuthenticationFailedException if the daemon rejects the first authenticationattempt. AdbConnectiongetAdbConnection()Get the AdbConnection backed by this object. booleanisConnected()Check if it is connected to an ADB daemon. booleanconnectTls(@NonNull() Context context, long timeoutMillis)Attempt to connect to ADB by performing an automatic network discovery of TLS host and port. booleanconnectTcp(@NonNull() Context context, long timeoutMillis)Attempt to connect to ADB by performing an automatic network discovery of TCP host and port. booleanautoConnect(@NonNull() Context context, long timeoutMillis)Attempt to connect to ADB by performing an automatic network discovery of host and port. booleanconnect(int port)Attempt to connect to ADB given a port number. booleanconnect(@NonNull() String host, int port)Attempt to connect to ADB via a host address and a port number. voiddisconnect()Disconnect the underlying AdbConnection. AdbStreamopenStream(String destination)Opens an AdbStream object corresponding to the specified destination.This routine will block until the connection completes. AdbStreamopenStream(int service, @NonNull() Array<String> args)Opens an AdbStream object corresponding to the specified destination.This routine will block until the connection completes. booleanpair(int port, @NonNull() String pairingCode)Pair with an ADB daemon given port number and pairing code. booleanpair(@NonNull() String host, int port, @NonNull() String pairingCode)Pair with an ADB daemon given host address, port number and pairing code. voidclose()Close the underlying AdbConnection and destroy the private key. -
-
Method Detail
-
setHostAddress
@CallSuper() void setHostAddress(@NonNull() String hostAddress)
Set host address for this connection. On the same device, this should be
{@code 127.0.0.1}.
-
getHostAddress
@NonNull() String getHostAddress()
Get host address for this connection. Default value is
{@code 127.0.0.1}.
-
setApi
void setApi(int api)
Set Android API (i.e. SDK) version for this connection. If the daemon and the client are located in the samedirectory, the value should be SDK_INT in order to improve performance as well as security.
- Parameters:
api- The API version, default is BASE.
-
setTimeout
@CallSuper() void setTimeout(long timeout, TimeUnit unit)
Set time to wait for the connection to be made.
- Parameters:
timeout- Timeout valueunit- Timeout unit
-
getTimeout
long getTimeout()
Get time to wait for the connection to be made. If not set using setTimeout, the defaulttimeout is MAX_VALUE milliseconds.
-
getTimeoutUnit
@NonNull() TimeUnit getTimeoutUnit()
Get the unit for the timeout. If not set using setTimeout, the default timeout unit is MILLISECONDS.
-
setThrowOnUnauthorised
@CallSuper() void setThrowOnUnauthorised(boolean throwOnUnauthorised)
Set whether to throw AdbAuthenticationFailedException if the daemon rejects the first authenticationattempt.
- Parameters:
throwOnUnauthorised-{@code true}to throw AdbAuthenticationFailedException or{@code false}otherwise.
-
isThrowOnUnauthorised
boolean isThrowOnUnauthorised()
Get whether to throw AdbAuthenticationFailedException if the daemon rejects the first authenticationattempt.
-
getAdbConnection
@CallSuper()@Nullable() AdbConnection getAdbConnection()
Get the AdbConnection backed by this object.
-
isConnected
boolean isConnected()
Check if it is connected to an ADB daemon.
-
connectTls
@WorkerThread()@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN) boolean connectTls(@NonNull() Context context, long timeoutMillis)
Attempt to connect to ADB by performing an automatic network discovery of TLS host and port. Host address set by setHostAddress is ignored.
- Parameters:
context- Application contexttimeoutMillis- Amount of time spent in searching for a host and a port.
-
connectTcp
@WorkerThread()@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN) boolean connectTcp(@NonNull() Context context, long timeoutMillis)
Attempt to connect to ADB by performing an automatic network discovery of TCP host and port. Host address set by setHostAddress is ignored.
- Parameters:
context- Application contexttimeoutMillis- Amount of time spent in searching for a host and a port.
-
autoConnect
@WorkerThread()@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN) boolean autoConnect(@NonNull() Context context, long timeoutMillis)
Attempt to connect to ADB by performing an automatic network discovery of host and port. Host address set by setHostAddress is ignored.
- Parameters:
context- Application contexttimeoutMillis- Amount of time spent in searching for a host and a port.
-
connect
@WorkerThread() boolean connect(int port)
Attempt to connect to ADB given a port number. Host address is set via setHostAddress.
- Parameters:
port- Port number
-
connect
@WorkerThread() boolean connect(@NonNull() String host, int port)
Attempt to connect to ADB via a host address and a port number.
- Parameters:
host- Host address to use instead of taking it from the getHostAddressport- Port number
-
disconnect
void disconnect()
Disconnect the underlying AdbConnection.
-
openStream
@WorkerThread()@NonNull() AdbStream openStream(String destination)
Opens an AdbStream object corresponding to the specified destination.This routine will block until the connection completes.
- Parameters:
destination- The destination to open on the target
-
openStream
@NonNull() AdbStream openStream(int service, @NonNull() Array<String> args)
Opens an AdbStream object corresponding to the specified destination.This routine will block until the connection completes.
- Parameters:
service- The service to open.args- Additional arguments supported by the service (see the corresponding constant to learn more).
-
pair
@WorkerThread()@RequiresApi(value = Build.VERSION_CODES.GINGERBREAD) boolean pair(int port, @NonNull() String pairingCode)
Pair with an ADB daemon given port number and pairing code.
- Parameters:
port- Port numberpairingCode- The six-digit pairing code as string
-
pair
@WorkerThread()@RequiresApi(value = Build.VERSION_CODES.GINGERBREAD) boolean pair(@NonNull() String host, int port, @NonNull() String pairingCode)
Pair with an ADB daemon given host address, port number and pairing code.
- Parameters:
host- Host address to use instead of taking it from the getHostAddressport- Port numberpairingCode- The six-digit pairing code as string
-
close
void close()
Close the underlying AdbConnection and destroy the private key.
-
-
-
-