- list current runnable or running applications
- - stop (aka pause), continue (aka resume), terminate
- a running instance of a given application
+ - pause, resume, terminate a running instance of a given application
- transfer requests for installation/uninstallation
of applications to the corresponding system daemon
When owning the right permissions, a client can get the list
of running instances and details about a specific
-running instance. It can also terminates, stops or
-continues a given application.
+running instance. It can also terminate, pause or
+resume a given application.
### Installing and uninstalling applications ###
***org.AGL.afm.user*** at object path ***/org/AGL/afm/user***
on interface ***org.AGL.afm.user*** for following members:
***runnables***, ***detail***, ***start***, ***terminate***,
-***stop***, ***continue***, ***runners***, ***state***,
+***pause***, ***resume***, ***runners***, ***state***,
***install*** and ***uninstall***.
D-Bus is mainly used for signaling and discovery. Its optimized
terminate the running instance rid
- - **afm-util stop rid **:
+ - **afm-util pause rid **:
- stop the running instance rid
+ pause the running instance rid
- - **afm-util continue rid **:
+ - **afm-util resume rid **:
- continue the previously rid
+ resume the previously paused rid
- **afm-util state rid **:
#### Method org.AGL.afm.user.stop
-**Description**: Stops the application attached to *runid* until terminate or continue.
+Obsolete since 8th November 2016 (2016/11/08).
+Kept for compatibility.
-**Input**: The *runid* (integer) of the running instance to stop.
+Use **org.AGL.afm.user.pause** instead.
+
+---
+
+#### Method org.AGL.afm.user.continue
+
+Obsolete since 8th November 2016 (2016/11/08).
+Kept for compatibility.
+
+Use **org.AGL.afm.user.resume** instead.
+
+---
+
+#### Method org.AGL.afm.user.pause
+
+**Description**: Pauses the application attached to *runid* until terminate or resume.
+
+**Input**: The *runid* (integer) of the running instance to pause.
**output**: the value 'true'.
---
-#### Method org.AGL.afm.user.continue
+#### Method org.AGL.afm.user.resume
-**Description**: Continues the application attached to *runid* previously stopped.
+**Description**: Resumes the application attached to *runid* previously paused.
-**Input**: The *runid* (integer) of the running instance to continue.
+**Input**: The *runid* (integer) of the running instance to resume.
**output**: the value 'true'.
**output**: An object describing instance state. It contains:
the runid (integer), the pids of the processes as an array starting
with the group leader, the id of the running application (string),
-the state of the application (string either: "starting", "running", "stopped").
+the state of the application (string either: "starting", "running", "paused").
Example of returned state:
These components are **afm-system-daemon** and **afm-user-daemon**.
They provides infrastructure for installing, uninstalling,
-launching, terminating, stopping and resuming applications in
+launching, terminating, pausing and resuming applications in
a multi user secure environment.
A third component exists in the framework, the binder **afb-daemon**.
* ***afm-system-daemon***: in charge of installing and uninstalling applications.
* ***afm-user-daemon***: in charge of listing applications, querying application details,
- starting, terminating, stopping, resuming applications and their instances
+ starting, terminating, pausing, resuming applications and their instances
for a given user context.
* ***afb-binder***: in charge of serving resources and features through an
using audit features and by managing logs and alerts.
The application framework manages the applications:
-installing, uninstalling, starting, stopping, listing ...
+installing, uninstalling, starting, pausing, listing ...
The application framework uses the security model/framework
to ensure the security and the privacy of the applications that
* **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 lifecycle 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, stop ... applications.
+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:
start id start an instance of the widget of id
kill rid
- terminate rid terminate the running instance rid
+ terminate rid terminate the running instance rid
stop rid
- pause rid stop the running instance rid
+ pause rid pause the running instance rid
resume rid
- continue rid continue the previously rid
+ continue rid resume the previously rid
status rid
- state rid get status of the running instance rid
+ state rid get status of the running instance rid
### Install an application
root@porter:~# afm-util ps
[ { "runid": 1, "state": "running", "id": "webapps-annex@0.0" } ]
-The 'runid' is the application instance ID and is used as an argument for the subcommands controlling the application runtime state (kill/stop/resume/status)
+The 'runid' is the application instance ID and is used as an argument for the subcommands controlling the application runtime state (kill/pause/resume/status)
-### Stop application
-To stop the application that was just started (the one with RUNID 1), just run the stop command:
+### Pause application
+To pause the application that was just started (the one with RUNID 1), just run the pause command:
root@porter:~# afm-util terminate 1
true
-The application is now stopped, as confirmed by a list of running apps:
+The application is now paused, as confirmed by a list of running apps:
root@porter:~# afm-util ps
[ ]
afm-client: a sample HTML5 'Homescreen'
---------------------------------------
-**afm-client** is a HTML5 UI that allows to install/uninstall applications as well as starting/stopping them as already demonstrated with afm-util.
+**afm-client** is a HTML5 UI that allows to install/uninstall applications as well as starting/pausing them as already demonstrated with afm-util.
The HTML5 UI is accessible remotely through this URL:
http://[board_ip]:1234/opa?token=132456789
Click on the 'start' item: the application starts and should be visible as a webview on the target board display. Note that at this point, we could also run the application remotely, that is in the same browser as the Homescreen app. By default, the application framework is configured to run applications 'locally' on the board display.
-### Stopping an application
+### Pausing an application
-In the Homescreen application, click again on the Rabbit application button, then select 'stop': the application then stops.
+In the Homescreen application, click again on the Rabbit application button, then select 'pause': the application then pauses.
### Uninstalling an application
stop|pause)
i=$2
- send stop "$i"
+ send pause "$i"
;;
resume|continue)
i=$2
- send continue "$i"
+ send resume "$i"
;;
state|status)
start id start an instance of the widget of id
kill rid
- terminate rid terminate the running instance rid
+ terminate rid terminate the running instance rid
stop rid
- pause rid stop the running instance rid
+ pause rid pause the running instance rid
resume rid
- continue rid continue the previously rid
+ continue rid continue the previously paused rid
status rid
- state rid get status of the running instance rid
+ state rid get status of the running instance rid
EOC
;;
static const char _install_[] = "install";
static const char _local_[] = "local";
static const char _mode_[] = "mode";
+static const char _pause_[] = "pause";
static const char _remote_[] = "remote";
+static const char _resume_[] = "resume";
static const char _runid_[] = "runid";
static const char _runnables_[] = "runnables";
static const char _runners_[] = "runners";
call_runid(request, _terminate_);
}
-static void stop(struct afb_req request)
+static void pause(struct afb_req request)
{
- call_runid(request, _stop_);
+ call_runid(request, _pause_);
}
-static void continue_(struct afb_req request)
+static void resume(struct afb_req request)
{
- call_runid(request, _continue_);
+ call_runid(request, _resume_);
}
static void runners(struct afb_req request)
{_detail_ , AFB_SESSION_CHECK, detail, "Get the details for one application"},
{_start_ , AFB_SESSION_CHECK, start, "Start an application"},
{_terminate_, AFB_SESSION_CHECK, terminate, "Terminate a running application"},
- {_stop_ , AFB_SESSION_CHECK, stop, "Stop (pause) a running application"},
- {_continue_ , AFB_SESSION_CHECK, continue_, "Continue (resume) a stopped application"},
+ {_pause_ , AFB_SESSION_CHECK, pause, "Pause a running application"},
+ {_resume_ , AFB_SESSION_CHECK, resume, "Resume a paused application"},
+ {_stop_ , AFB_SESSION_CHECK, pause, "Obsolete since 2016/11/08, use 'pause' instead"},
+ {_continue_ , AFB_SESSION_CHECK, resume, "Obsolete since 2016/11/08, use 'resume' instead"},
{_runners_ , AFB_SESSION_CHECK, runners, "Get the list of running applications"},
{_state_ , AFB_SESSION_CHECK, state, "Get the state of a running application"},
{_install_ , AFB_SESSION_CHECK, install, "Install an application using a widget file"},
enum appstate {
as_starting, /* start in progress */
as_running, /* started and running */
- as_stopped, /* stopped */
+ as_paused, /* paused */
as_terminating, /* termination in progress */
as_terminated /* terminated */
};
{
}
-static void stopped(int runid)
+static void paused(int runid)
{
}
-static void continued(int runid)
+static void resumed(int runid)
{
}
* for 'runid' and put the runner's state to 'tostate'
* in case of success.
*
- * Only processes in the state 'as_running' or 'as_stopped'
+ * Only processes in the state 'as_running' or 'as_paused'
* can be signalled.
*
* Returns 0 in case of success or -1 in case of error.
errno = ENOENT;
rc = -1;
}
- else if (runner->state != as_running && runner->state != as_stopped) {
+ else if (runner->state != as_running && runner->state != as_paused) {
errno = EINVAL;
rc = -1;
}
pgid_remove(runner);
runner->next_by_pgid = terminated_runners;
terminated_runners = runner;
- /* ensures that all the group stops */
+ /* ensures that all the group terminates */
killpg(runner->pids[0], SIGKILL);
break;
case CLD_STOPPED:
/* update the state */
- runner->state = as_stopped;
+ runner->state = as_paused;
break;
case CLD_CONTINUED:
switch(runner->state) {
case as_starting:
case as_running:
- case as_stopped:
+ case as_paused:
pids = j_add_new_array(result, "pids");
if (!pids)
goto error2;
case as_running:
state = "running";
break;
- case as_stopped:
- state = "stopped";
+ case as_paused:
+ state = "paused";
break;
default:
state = "terminated";
*
* Returns 0 in case of success or -1 in case of error
*/
-int afm_run_stop(int runid)
+int afm_run_pause(int runid)
{
- return killrunner(runid, SIGSTOP, as_stopped);
+ return killrunner(runid, SIGSTOP, as_paused);
}
/*
*
* Returns 0 in case of success or -1 in case of error
*/
-int afm_run_continue(int runid)
+int afm_run_resume(int runid)
{
return killrunner(runid, SIGCONT, as_running);
}
extern int afm_run_start(struct json_object *appli, enum afm_launch_mode mode, char **uri);
extern int afm_run_terminate(int runid);
-extern int afm_run_stop(int runid);
-extern int afm_run_continue(int runid);
+extern int afm_run_pause(int runid);
+extern int afm_run_resume(int runid);
extern struct json_object *afm_run_list();
extern struct json_object *afm_run_state(int runid);
&& j_add_string(resp, "uri", uri))
jbus_reply_j(smsg, resp);
else {
- afm_run_stop(runid);
+ afm_run_terminate(runid);
jbus_reply_error_s(smsg, error_system);
}
json_object_put(resp);
}
/*
- * On query "stop" from 'smsg' with parameters of 'obj'.
+ * On query "pause" from 'smsg' with parameters of 'obj'.
*/
-static void on_stop(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
+static void on_pause(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
{
int runid, status;
- if (onrunid(smsg, obj, "stop", &runid)) {
- status = afm_run_stop(runid);
+ if (onrunid(smsg, obj, "pause", &runid)) {
+ status = afm_run_pause(runid);
reply_status(smsg, status, error_not_found);
}
}
/*
- * On query "continue" from 'smsg' with parameters of 'obj'.
+ * On query "resume" from 'smsg' with parameters of 'obj'.
*/
-static void on_continue(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
+static void on_resume(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
{
int runid, status;
- if (onrunid(smsg, obj, "continue", &runid)) {
- status = afm_run_continue(runid);
+ if (onrunid(smsg, obj, "resume", &runid)) {
+ status = afm_run_resume(runid);
reply_status(smsg, status, error_not_found);
}
}
+/*
+ * On query "stop" from 'smsg' with parameters of 'obj'.
+ */
+static void on_stop(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
+{
+ NOTICE("call to obsolete 'stop'");
+ on_pause(smsg, obj, unused);
+}
+
+/*
+ * On query "continue" from 'smsg' with parameters of 'obj'.
+ */
+static void on_continue(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
+{
+ NOTICE("call to obsolete 'continue'");
+ on_resume(smsg, obj, unused);
+}
+
/*
* On query "terminate" from 'smsg' with parameters of 'obj'.
*/
|| jbus_add_service_j(user_bus, "detail", on_detail, NULL)
|| jbus_add_service_j(user_bus, "start", on_start, NULL)
|| jbus_add_service_j(user_bus, "terminate", on_terminate, NULL)
+ || jbus_add_service_j(user_bus, "pause", on_pause, NULL)
+ || jbus_add_service_j(user_bus, "resume", on_resume, NULL)
|| jbus_add_service_j(user_bus, "stop", on_stop, NULL)
|| jbus_add_service_j(user_bus, "continue", on_continue, NULL)
|| jbus_add_service_j(user_bus, "runners", on_runners, NULL)
|| jbus_add_service_j(user_bus, "state", on_state, NULL)
#if defined(EXPLICIT_CALL)
|| jbus_add_service_s(user_bus, "install", on_install, NULL)
- || jbus_add_service_s(user_bus, "uninstall", on_uninstall, NULL)) {
+ || jbus_add_service_s(user_bus, "uninstall", on_uninstall, NULL)
#else
|| jbus_add_service_s(user_bus, "install", (void (*)(struct sd_bus_message *, const char *, void *))propagate, "install")
- || jbus_add_service_s(user_bus, "uninstall", (void (*)(struct sd_bus_message *, const char *, void *))propagate, "uninstall")) {
+ || jbus_add_service_s(user_bus, "uninstall", (void (*)(struct sd_bus_message *, const char *, void *))propagate, "uninstall")
#endif
+ ) {
ERROR("adding services failed");
return 1;
}