Nathan Harold | d15c7dd | 2016-02-17 16:42:16 -0800 | [diff] [blame] | 1 | Scripting Layer For Android |
| 2 | ============================= |
| 3 | |
| 4 | ### Introduction |
| 5 | Originally authored by Damon Kohler, Scripting Layer for Android, SL4A, is an automation toolset |
| 6 | for calling Android APIs in a platform-independent manner. It supports both remote automation via |
| 7 | ADB as well as execution of scripts from on-device via a series of lightweight translation layers. |
| 8 | |
| 9 | ### Build Instructions |
| 10 | Due to its inclusion in AOSP as a privileged app, building SL4A requires a system build. |
| 11 | |
| 12 | For the initial build of Android: |
| 13 | |
| 14 | cd <ANDROID_SOURCE_ROOT> |
| 15 | source build/envsetup.sh |
| 16 | lunch aosp_<TARGET> |
| 17 | make [-j15] |
| 18 | |
Nathan Harold | 358fd41 | 2016-04-12 17:48:15 -0700 | [diff] [blame] | 19 | *where `<ANDROID_SOURCE_ROOT>` is the root directory of the android tree and `<TARGET>` is the lunch |
Nathan Harold | d15c7dd | 2016-02-17 16:42:16 -0800 | [diff] [blame] | 20 | target name* |
| 21 | |
| 22 | Then Build SL4A: |
| 23 | |
tturney | 2d949f9 | 2016-02-24 10:26:48 -0800 | [diff] [blame] | 24 | cd <ANDROID_SOURCE_ROOT>/external/sl4a |
Nathan Harold | d15c7dd | 2016-02-17 16:42:16 -0800 | [diff] [blame] | 25 | mm [-j15] |
| 26 | |
| 27 | ### Adding SL4A Builds to Android Builds by Default |
| 28 | 1) If you are not using a custom buildspec, create one as follows: |
| 29 | |
| 30 | cp <ANDROID_SOURCE_ROOT>/build/buildspec.mk.default <ANDROID_SOURCE_ROOT>/buildspec.mk |
| 31 | |
| 32 | 2) Modify the buildspec to build SL4A as a custom module by editing |
| 33 | the line '#CUSTOM_MODULES:=' to 'CUSTOM_MODULES:=sl4a': |
| 34 | |
| 35 | sed -i 's/#CUSTOM_MODULES:=/CUSTOM_MODULES:=sl4a/' <ANDROID_SOURCE_ROOT>/buildspec.mk |
| 36 | |
| 37 | ### Install Instructions |
| 38 | Run the following command: |
| 39 | |
| 40 | adb install -r <ANDROID_SOURCE_ROOT>/out/target/product/<TARGET>/data/app/sl4a/sl4a.apk |
| 41 | |
| 42 | ### Run Instructions |
| 43 | a) SL4A may be launched from Android as a normal App; or |
| 44 | b) To enable RPC access from the command prompt: |
| 45 | |
| 46 | adb forward tcp:<HOST_PORT_NUM> tcp:<DEVICE_PORT_NUM> |
| 47 | adb shell "am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER \ |
| 48 | --ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT <DEVICE_PORT_NUM> \ |
| 49 | com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher" |
Nathan Harold | 358fd41 | 2016-04-12 17:48:15 -0700 | [diff] [blame] | 50 | *where `<HOST_PORT_NUM>` and `<DEVICE_PORT_NUM>` are the tcp ports on the host computer and device.* |
Nathan Harold | d15c7dd | 2016-02-17 16:42:16 -0800 | [diff] [blame] | 51 | |
| 52 | ### Generate the API Documentation |
| 53 | From SL4A source directory run this command: |
| 54 | |
Randolph Chung | d1dd75d | 2016-03-27 07:35:32 -0700 | [diff] [blame] | 55 | python Docs/generate_api_reference_md.py |
Nathan Harold | d15c7dd | 2016-02-17 16:42:16 -0800 | [diff] [blame] | 56 | |
| 57 | In the Docs directory there should now be an ApiReference.md file that |
| 58 | contains which RPC functions are available in SL4A as well as documentation |
| 59 | for the RPC functions. |
| 60 | |