Scripting Layer for Android, SL4A, is an
automation toolset for calling Android APIs in a platform-independent manner.
It supports both remote automation via
adb and execution of scripts
from on-device via a series of lightweight translation layers.
The project is located at platform/external/sl4a.
You can follow the SL4A README to build and install it manually. And when running through Tradefed, you can take advantage of some of the harness utilities to make use easier.
Download and install
You can start by reviewing
an example Tradefed configuration that uses two devices. The
available in most device builds within their
The Tradefed example above automatically fetches the builds, flashes both
devices and installs
SL4A.apk on both devices. You can run it like so:
source build/envsetup.sh lunch make sl4a tradefed.sh run google/example/BT-discovery-sl4a
Or once built:
./tradefed.sh run google/example/BT-discovery-sl4a
Write a test in Tradefed using SL4A
You can follow the test sample describe above: Sl4aBluetoothDiscovery.java. This gives a good example of the flow to use SL4A within a Tradefed test.
SL4A API Documentation
The complete list of callbacks available through SL4A can be generated. From the
SL4A source directory,
platform/external/sl4a/, run this command:
In the Docs directory there will be an
ApiReference.md file that contains
the RPC functions available in SL4A, as well as documentation for the RPC