9087254e5d83a8bc37c6977ade133e55d020e1af
[AGL/documentation.git] / docs / 3_Developer_Guides / 1_Application_Framework / 1_Introduction.md
1 ---
2 title: Introduction
3 ---
4
5 # Foreword
6
7 The AGL Application Framework is nothing new. However, the implementation used up until
8 the `lamprey` release has been retired starting with the `marlin` release and replaced
9 by a redesigned Application Framework one. However, this new implementation isn't a 1:1
10 replacement, and as such it doesn't provide all of the features of the previous
11 Application Framework. Some of those will be added back over time, others have been
12 discarded in favor of more modern and/or widely-used alternatives.
13
14 # Introduction
15
16 As a provider of an integrated solution to build up on, AGL needs to define a reliable
17 and well-specified method for managing the deployment and integration of applications
18 and services, as well as the way they can interact with the rest of the system.
19
20 This is achieved by providing a common set of rules and components, known as the
21 Application Framework. By ensuring conformity to those rules, application developers
22 can have a good understanding of the requirements for creating and packaging
23 applications targeting AGL-based systems. Likewise, system developers and integrators
24 have a clear path for including such applications in AGL-based products.
25
26 The Application Framework's scope extends to the following areas:
27 - system services integration and lifecycle management
28 - user session management, including user-level applications and services lifecycle
29   management
30 - inter-process communication
31
32 In order to be as simple as possible and avoid any unneded custom implementation, the
33 Application Framework relies mainly on third-party technologies and/or software
34 components, most of those being maintained under the
35 [freedesktop.org](https://www.freedesktop.org) umbrella. Those include:
36 - [systemd](https://www.freedesktop.org/wiki/Software/systemd/): system and services
37   management
38 - [D-Bus](https://www.freedesktop.org/wiki/Software/dbus/): inter-process communication
39 - [Desktop Entry specification](https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/):
40   application enumeration and startup
41
42 AGL also provides reference implementations whenever possible and relevant, located in
43 the [meta-agl](../6_AGL_Layers/2_meta-agl/) layer under `meta-app-framework`. At the
44 moment, the Application Framework contains 2 such components:
45 - `agl-session`: `systemd` unit files for user sessions management
46 - `applaunchd`: application launcher service
47
48 # Services management
49
50 Both system and user services are managed by `systemd`, which provides a number of
51 important features, such as dependency management or service monitoring: when starting
52 a service, `systemd` will ensure any other units this service depends on are available,
53 and otherwise start those dependencies. Similarly, `systemd` can automatically restart
54 a crashed service, ensuring minimal downtime.
55
56 `systemd` also provides an efficient first layer of security through its
57 [sandboxing](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Sandboxing)
58 and other security-related options.
59
60 It is also well integrated with D-Bus and can be used for a more fine-grained control
61 over D-Bus activated services: by delegating the actual service startup to `systemd`,
62 developers can take advantage of some of its advanced features, allowing for improved
63 reliability and security.
64
65 Each service should be represented by a `systemd` unit file installed to the appropriate
66 location. More details can be obtained from the [Creating a New Service](../2_Creating_a_New_Service/)
67 document.
68
69 # User session management
70
71 Similarly, user sessions and the services they rely on are also managed by `systemd`.
72
73 AGL provides 2 `systemd` units:
74
75 1. `agl-session@.service` is a template system service for managing user sessions; it
76 takes a username or UID as a parameter, creating a session for the desired user.
77 Instanciating this service can be achieved by enabling `agl-session@USER.service`, for
78 example by executing the following command on a running system:
79
80 ```
81 $ systemctl enable agl-session@USER.service
82 ```
83
84 By default, AGL enables this service as `agl-session@agl-driver.service`, running as
85 user `agl-driver`.
86
87 *Note: while you can create sessions for as many users as needed, only one instance of
88 `agl-session@.service` is allowed per user.*
89
90 2. `agl-session.target` is a user target for managing user services and their
91 dependencies. It is started by `agl-session@.service`.
92
93 By default, `agl-compositor` is part of this target. It is therefore automatically
94 started for user `agl-driver`.
95
96 Any other service needed as part of the user session should similarly depend on this
97 target by appending the following lines to their unit file:
98
99 ```
100 [Install]
101 WantedBy=agl-session.target
102 ```
103
104 # Inter-process communication
105
106 In order to provide a "standard", language-independent IPC mechanism and avoid the need
107 for maintaining custom bindings for each programming language to be used on top of AGL,
108 the Application Framework promotes the use of [D-Bus](https://www.freedesktop.org/wiki/Software/dbus/)
109 as the preferred way for applications to interact with services.
110
111 Most services already included in AGL provide one or several D-Bus interfaces, and can
112 therefore interact with D-Bus capable applications and services without requiring any
113 additional component. Those services include, among others:
114 - [ConnMan](https://git.kernel.org/pub/scm/network/connman/connman.git/): network connectivity
115 - [BlueZ](http://www.bluez.org/): Bluetooth connectivity
116 - [oFono](https://git.kernel.org/pub/scm/network/ofono/ofono.git): telephony and modem
117   management
118 - [GeoClue](https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home): geolocation
119
120 # Application launcher service
121
122 As mentioned above, the Application Framework follows the guidelines of the
123 [Desktop Entry specification](https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/)
124 for application enumeration and startup.
125
126 As no simple reference implementation exists for this part of the specification, AGL
127 provides an application launcher service named `applaunchd`. This service is part of the
128 default user session, and as such is automatically started on session startup. It can
129 therefore be considered always available.
130
131 `applaunchd` enumerates applications installed on the system and provides a D-bus
132 interface for services and applications to:
133 - query the list of available applications
134 - request the startup and/or activation of a specific application
135 - be notified when applications are started or terminated
136
137 `applaunchd` is described with more details in [the following document](2_Application_Startup/).