RemoteManager

public class RemoteManager
extends Thread

java.lang.Object
   ↳ java.lang.Thread
     ↳ com.android.tradefed.command.remote.RemoteManager


Class that receives RemoteOperations via a socket.

Currently accepts only one remote connection at one time, and processes incoming commands serially.

Usage:

 RemoteManager r = new RemoteManager(deviceMgr, scheduler);
 r.connect();
 r.start();
 int port = r.getPort();
 ... inform client of port to use. Shuts down when instructed by client or on #cancel()
 

Summary

Public constructors

RemoteManager()
RemoteManager(IDeviceManager manager, ICommandScheduler scheduler)

Creates a RemoteManager.

Public methods

void cancel()

Request to cancel the remote manager.

void cancelAndWait()

Convenience method to request a remote manager shutdown and wait for it to complete.

boolean connect()

Attempts to init server and connect it to a port.

boolean connectAnyPort()

Attemps to connect to any free port.

boolean getAutoHandover()
int getPort()

Gets the socket port the remote manager is listening on, blocking for a short time if necessary.

int getRemoteManagerPort()
boolean getStartRemoteMgrOnBoot()
boolean isCanceled()
void run()

The main thread body of the remote manager.

void setRemoteManagerPort(int port)
void setRemoteManagerTimeout(int timeout)

Protected methods

boolean connect(int port)

Attempts to connect server to a given port.

Public constructors

RemoteManager

RemoteManager ()

RemoteManager

RemoteManager (IDeviceManager manager, 
                ICommandScheduler scheduler)

Creates a RemoteManager.

Parameters
manager IDeviceManager: the IDeviceManager to use to allocate and free devices.
scheduler ICommandScheduler: the ICommandScheduler to use to schedule commands.

Public methods

cancel

void cancel ()

Request to cancel the remote manager.

cancelAndWait

void cancelAndWait ()

Convenience method to request a remote manager shutdown and wait for it to complete.

connect

boolean connect ()

Attempts to init server and connect it to a port.

Returns
boolean true if we successfully connect the server to the default port.

connectAnyPort

boolean connectAnyPort ()

Attemps to connect to any free port.

Returns
boolean true if we successfully connected to the port, false otherwise.

getAutoHandover

boolean getAutoHandover ()

Returns
boolean

getPort

int getPort ()

Gets the socket port the remote manager is listening on, blocking for a short time if necessary.

start() should be called before this method.

Returns
int the port the remote manager is listening on, or -1 if no port is setup.

getRemoteManagerPort

int getRemoteManagerPort ()

Returns
int

getStartRemoteMgrOnBoot

boolean getStartRemoteMgrOnBoot ()

Returns
boolean

isCanceled

boolean isCanceled ()

Returns
boolean true if a cancel has been requested

run

void run ()

The main thread body of the remote manager.

Creates a server socket, and waits for client connections.

setRemoteManagerPort

void setRemoteManagerPort (int port)

Parameters
port int

setRemoteManagerTimeout

void setRemoteManagerTimeout (int timeout)

Parameters
timeout int

Protected methods

connect

boolean connect (int port)

Attempts to connect server to a given port.

Parameters
port int
Returns
boolean true if we successfully connect to the port, false otherwise.