RemoteManager

public class RemoteManager
extends Object

java.lang.Object
   ↳ 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()

Attempts 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

public RemoteManager ()

RemoteManager

public 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

public void cancel ()

Request to cancel the remote manager.

cancelAndWait

public void cancelAndWait ()

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

connect

public 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

public boolean connectAnyPort ()

Attempts to connect to any free port.

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

getAutoHandover

public boolean getAutoHandover ()

Returns
boolean

getPort

public int getPort ()

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

ERROR(/#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

public int getRemoteManagerPort ()

Returns
int

getStartRemoteMgrOnBoot

public boolean getStartRemoteMgrOnBoot ()

Returns
boolean

isCanceled

public boolean isCanceled ()

Returns
boolean true if a cancel has been requested

run

public void run ()

The main thread body of the remote manager.

Creates a server socket, and waits for client connections.

setRemoteManagerPort

public void setRemoteManagerPort (int port)

Parameters
port int

setRemoteManagerTimeout

public void setRemoteManagerTimeout (int timeout)

Parameters
timeout int

Protected methods

connect

protected 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.