Sl4aClient

public class Sl4aClient
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.sl4a.Sl4aClient


Sl4A client to interact via RPC with SL4A scripting layer.

Summary

Fields

public static final String IS_SL4A_RUNNING_CMD

public static final String IS_SL4A_RUNNING_CMD_OLD

public static final String SL4A_LAUNCH_CMD

public static final String STOP_SL4A_CMD

Public constructors

Sl4aClient(ITestDevice device, File sl4aApkFile)

Creates the Sl4A client.

Sl4aClient(ITestDevice device, int hostPort, int devicePort)

Creates the Sl4A client.

Public methods

void close()

Close the sl4a connection to device side and Kills any running instance of sl4a.

Sl4aEventDispatcher getEventDispatcher()

Return the event dispatcher to wait for events.

boolean isSl4ARunning()

Return true if the sl4a device side client is running.

void open()

Helper to actually starts the connection host to device for sl4a.

Object rpcCall(String methodName, Object... args)

Execute an RPC call on the sl4a layer.

static Sl4aClient startSL4A(ITestDevice device, File sl4aApkFile)

Convenience method to create and start a client ready to use.

void startSl4A()

Starts the sl4a client on the device side.

Protected methods

IRunUtil getRunUtil()

Return the default runutil instance.

void startEventDispatcher()

Starts the event dispatcher.

Fields

IS_SL4A_RUNNING_CMD

public static final String IS_SL4A_RUNNING_CMD

IS_SL4A_RUNNING_CMD_OLD

public static final String IS_SL4A_RUNNING_CMD_OLD

SL4A_LAUNCH_CMD

public static final String SL4A_LAUNCH_CMD

STOP_SL4A_CMD

public static final String STOP_SL4A_CMD

Public constructors

Sl4aClient

public Sl4aClient (ITestDevice device, 
                File sl4aApkFile)

Creates the Sl4A client.

Parameters
device ITestDevice: the {ITestDevice} that the client will be for.

sl4aApkFile File: file path to hte sl4a apk to install, or null if already installed.

Throws
DeviceNotAvailableException

Sl4aClient

public Sl4aClient (ITestDevice device, 
                int hostPort, 
                int devicePort)

Creates the Sl4A client.

Parameters
device ITestDevice: the {ITestDevice} that the client will be for.

hostPort int: the port on the host machine to connect to the sl4a client.

devicePort int: the device port used to communicate to.

Public methods

close

public void close ()

Close the sl4a connection to device side and Kills any running instance of sl4a. If no instance is running then nothing is done.

getEventDispatcher

public Sl4aEventDispatcher getEventDispatcher ()

Return the event dispatcher to wait for events.

Returns
Sl4aEventDispatcher

isSl4ARunning

public boolean isSl4ARunning ()

Return true if the sl4a device side client is running.

Returns
boolean

Throws
DeviceNotAvailableException

open

public void open ()

Helper to actually starts the connection host to device for sl4a.

rpcCall

public Object rpcCall (String methodName, 
                Object... args)

Execute an RPC call on the sl4a layer.

Parameters
methodName String: the name of the method to be called on device side.

args Object: the arg list to be used on the method.

Returns
Object the result of the request.

Throws
if the requested method does not exists.

startSL4A

public static Sl4aClient startSL4A (ITestDevice device, 
                File sl4aApkFile)

Convenience method to create and start a client ready to use.

Parameters
device ITestDevice: the {ITestDevice} that the client will be for.

sl4aApkFile File: file path to hte sl4a apk to install, or null if already installed.

Returns
Sl4aClient an Sl4aClient instance that has been started.

Throws
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

startSl4A

public void startSl4A ()

Starts the sl4a client on the device side. Assume the sl4a apk is installed.

Throws
DeviceNotAvailableException

Protected methods

getRunUtil

protected IRunUtil getRunUtil ()

Return the default runutil instance. Exposed for testing.

Returns
IRunUtil

startEventDispatcher

protected void startEventDispatcher ()

Starts the event dispatcher. Exposed for testing.

Throws
DeviceNotAvailableException