When creating or updating an addon, the directory containing your addon files must contain:
- A file named
- A directory named
hooks. This directory must contain at least one executable file with a valid hook name (see Hooks below).
Other files in the addon directory are bundled with the addon. They can be accessed in a hook by using the
$ADDON_DIR environment variable). For example:
cat "$ADDON_DIR"/public_key.pem >> ~/.ssh/authorized_keys
To create the addon, you must provide
amc with either the directory or a tarball containing the same file structure.
The following table lists the valid keys in an addon manifest:
|name||string||Name of the addon. Can be used to reference the addon.||All characters except for the following:
|description||string||Description of the addon.|
|provides||object||Additional capabilities that this addon provides to the container. See individual items for details.|
|provides.abi-support||string array||Tells AMS that this addon adds support for the given architecture even if the application doesn’t support it natively. Use this when your addon brings instruction translation or provides libraries for other architectures.||
When addon hooks are invoked, several environment variables are set to provide context to the addon.
The following variables are available:
|ADDON_DIR||Directory of the addon whose hook is currently running.|
|ANBOX_DIR||Path to the Anbox directory.||
|ANDROID_ROOTFS||Path to the Android RootFS.||
|BOOT_PACKAGE||Boot package of the APK.|
|CONTAINER_TYPE||Type of container being run.||
An addon is a collection of hooks that are invoked at different points in time in the life cycle of a container. A hook can be any executable file as long as its name is one of the following:
|pre-start||Executed before Android is started. If the hook crashes, the container fails to start.|
|post-start||Executed after Android is started. If the hook crashes, the container stops.|
|post-stop||Executed after Android is stopped. If the container crashes, this hook might not be invoked.|
|install (deprecated)||DEPRECATED: Use
|prepare (deprecated)||DEPRECATED: Use
|restore (deprecated)||DEPRECATED: Use
|backup (deprecated)||DEPRECATED: Use
The following figure shows when the different hooks are executed in the life cycle of a container (base container or regular container).
All hooks are subject to a 5 minute timeout to avoid blocking a container for too long.
A hook that runs into a timeout exits with an error.