# AGL Application Framework: A Quick Tutorial ## Introduction This document proposes a quick tutorial to demonstrate the major functionalities of the AGL Application Framework. For more complete information, please refer to the inline documentation available in the main git repository: [https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/app-framework-main] [https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/app-framework-binder] For more information on AGL, please visit: [https://www.automotivelinux.org/] ---------- ## Sample applications 4 sample applications (.wgt files) are prebuilt and available at the following address: [https://github.com/iotbzh/afm-widget-examples] You can get them by cloning this git repository on your desktop (will be useful later in this tutorial): ```bash git clone https://github.com/iotbzh/afm-widget-examples ``` ## Using the CLI tool ### Setup Environment Connect your AGL target board to the network and copy some sample widgets on it through SSH (set BOARDIP with your board IP address) : ```bash cd afm-widget-examples BOARDIP=1.2.3.4 scp *.wgt root@$BOARDIP:~/ ``` Connect through SSH on the target board and check for Application Framework daemons: ```bash $ ssh root@$BOARDIP root@porter:~# ps -ef|grep bin/afm afm 409 1 0 13:00 ? 00:00:00 /usr/bin/afm-system-daemon root 505 499 0 13:01 ? 00:00:00 /usr/bin/afm-user-daemon root 596 550 0 13:22 pts/0 00:00:00 grep afm ``` We can see that there are two daemons running: * **afm-system-daemon** runs with a system user 'afm' and is responsible for installing/uninstalling packages * **afm-user-daemon** runs as a user daemon (currently as root because it's the only real user on the target board) and is responsible for the whole life cycle of the applications running inside the user session. The application framework has a tool running on the Command Line Interface (CLI). Using the **afm-util** command, you can install, uninstall, list, run, pause ... applications. To begin, run '**afm-util help**' to get a quick help on commands: ```bash root@porter:~# afm-util help usage: afm-util command [arg] ``` The commands are: ```bash list runnables list the runnable widgets installed add wgt install wgt install the wgt file remove id uninstall id remove the installed widget of id info id detail id print detail about the installed widget of id ps runners list the running instance run id start id start an instance of the widget of id kill rid terminate rid terminate the running instance rid status rid state rid get status of the running instance rid ``` ### Install an application You can then install your first application: ```bash root@porter:~# afm-util install /home/root/annex.wgt { "added": "webapps-annex@0.0" } ``` Let's install a second application: ```bash root@porter:~# afm-util install /home/root/memory-match.wgt { "added": "webapps-memory-match@1.1" } ``` Note that usually, **afm-util** will return a **JSON result**, which is the common format for messages returned by the Application Framework daemons. ### List installed applications You can then list all installed applications: ```bash root@porter:~# afm-util list [ { "id": "webapps-annex@0.0", "version": "0.0.10", "width": 0, "height": 0, "name": "Annex", "description": "Reversi\/Othello", "shortname": "", "author": "Todd Brandt " }, { "id": "webapps-memory-match@1.1", "version": "1.1.7", "width": 0, "height": 0, "name": "MemoryMatch", "description": "Memory match", "shortname": "", "author": "Todd Brandt " } ] ``` Here, we can see the two previously installed applications. ### Get information about an application Let's get some details about the first application: ```bash root@porter:~# afm-util info webapps-annex@0.0 { "id": "webapps-annex@0.0", "version": "0.0.10", "width": 0, "height": 0, "name": "Annex", "description": "Reversi\/Othello", "shortname": "", "author": "Todd Brandt " } ``` Note: that AGL applications are mostly handled by afm-util through their IDs. In our example, the application ID is 'webapps-annex@0.0'. ### Start application Let's start the first application Annex: ```bash root@porter:~# afm-util start webapps-annex@0.0 1 ``` As the application is a HTML5 game, you should then get a webview running with QML on the board display. ### Security Context The application has been started in the user session, with a dedicated security context, enforced by SMACK. To illustrate this, we can take a look at the running processes and their respective SMACK labels: ```bash roo
#
# Copyright (c) 2017 TOYOTA MOTOR CORPORATION
#
# Licensed under the Apache L