1 **HomeScreen GUI Application / HomeScreen Service Guide**
4 TOYOTA MOTOR CORPORATION
5 Advanced Driver Information Technology
11 - [Target reader of this document](#target-reader-of-this-document)
12 - [Overview](#overview)
13 - [Getting Start](#getting-start)
14 - [Supported environment](#supported-environment)
16 - [Configuring](#configuring)
17 - [How to call HomeScreen APIs from your Application?](#how-to-call-homescreen-apis-from-your-application)
18 - [Supported usecase](#supported-usecase)
19 - [Software Architecture](#software-architecture)
20 - [API reference](#api-reference)
21 - [Sequence](#sequence)
22 - [Initialize](#initialize-sequence)
23 - [Tap Shortcut(deprecated)](#tap-shortcut-sequence)
24 - [ShowWindow](#showwindow-sequence)
25 - [On Screen Message / Reply Sequence(deprecated)](#on-screen-message-reply-sequence)
26 - [ShowOnscreen](#showonscreen-sequence)
27 - [ShowNotification](#shownotification-sequence)
28 - [ShowInformation](#showinformation-sequence)
29 - [Sample code](#sample-code)
30 - [Limitation](#limitation)
31 - [Next Plan](#next-plan)
32 - [Appendix](#appendix)
36 ## Target reader of this document
37 Application developer whose software uses HomeScreen.
42 HomeScreen is built with a GUI application created with Qt(referred as HomeScreenGUI), and a service running on afb-daemon (referred as HomeScreenBinder).
43 HomeScreen can start/switch applications run in AGL, also displays information such as onscreen messages.
45 You can find these projects in AGL gerrit.
47 - [homescreen(HomeScreenGUI)](https://gerrit.automotivelinux.org/gerrit/#/admin/projects/apps/homescreen)
48 - [launcher(LauncherGUI)](https://gerrit.automotivelinux.org/gerrit/#/admin/projects/apps/launcher)
49 - [gl-service-homescreen(HomeScreenBinder's binding library)](https://gerrit.automotivelinux.org/gerrit/#/admin/projects/apps/agl-service-homescreen)
50 - [libhomescreen(library for application to communication with HomeScreenBinder]( https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/libhomescreen)
51 - [libqthomescreen(library for qt application to communication with HomeScreenBinder based on libhomescreen)](https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/libqthomescreen)
53 Also HomeScreenGUI is using libwindowmanager.
59 ### Supported environment
61 | Item | Description |
62 |:------------|:----------------------------------|
63 | AGL version | Grumpy Guppy |
64 | Hardware | Renesas R-Car Starter Kit Pro(M3) |
74 $ repo init -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo
79 Then you can find the following recipes.
81 * `meta-agl-demo/recipes-demo-hmi/homescreen`
83 * `meta-agl-devel/meta-hmi-framework/recipes-demo-hmi/launcher`
85 * `meta-agl-demo/recipes-demo-hmi/agl-service-homescreen`
87 * `meta-agl-demo/recipes-demo-hmi/libhomescreen`
89 * `meta-agl-devel/meta-hmi-framework/recipes-demo-hmi/qlibhomescreen`
95 $ source meta-agl/scripts/aglsetup.sh -m m3ulcb agl-demo agl-devel agl-appfw-smack agl-hmi-framework
96 $ bitbake agl-demo-platform
100 To use HomeScreen API, an application shall paste the following configuration definition into "config.xml" of application.
103 <feature name="urn:AGL:widget:required-api">
104 <param name="homescreen" value="ws" />
105 <param name="windowmanager" value="ws" />
109 ### How to call HomeScreen APIs from your Application?
110 HomeScreen provides a library which is called "libhomescreen".
111 This library treats "json format" as API calling.
112 For example, if an application wants to call "showWIndow()" API, the you should implement as below.
114 At first the application should create the instance of libhomescreen.
117 LibHomeScreen* libhs;
118 libhs = new LibHomeScreen();
119 libhs->init(port, token);
122 The port and token is provided by Application Framework
124 Execute the "showWindow()" function.
127 libhs->showWindow("application_id", "display_area");
130 Regarding the detail of showWindow() API, please refer [this](#homescreen-specific-api) section.
131 The first parameter is the appid of application which want to display,liked "dashboard".
132 And the second parameter corresponds to display_area which defined by windowmanager,usually "normal",
133 so in this case "showWindow" the two parameters are proper string.
135 See also our [Sample code](#sample-code).
140 1. HomeScreenGUI sending showWindow event to applications
141 - Applications using libhomescreen to subscribe the showWindow event,
142 HomeScreenGUI will send showWindow event to applications.
143 2. Display OnScreen messages(deprecated)
144 - Applications sending OnScreen messages to homescreen-service, and OnScreenAPP
145 will get these message and display.
146 3. Get OnSreen Reply event(deprecated)
147 - When OnScreen messages is displaying, OnScreenAPP will send a reply event to applications.
148 4. Display OnScreen by showWindow
149 - When application who want to show OnScreen,it can call "showWindow",then OnScreenApp will
150 display request OnScreen.
151 5. Hide OnScreen by hideWindow
152 - When application who want to hide OnScreen which is displaying,it can call "hideWindow",then OnScreenApp
154 6. Send OnScreen Reply by replyShowWindow
155 - When user touch the button of OnScreen, OnScreenApp can call "relplyShowWindow" to send reply information
157 7. Show Notification on HomeScreenGUI
158 - When application who want to display a notification,it can call "showNotification",then HomeScreenGUI will
159 display the notification contents on the screen top area.
160 8. Show Information on HomeScreenGUI
161 - When application who want to display a information,it can call "showInformation",then HomeScreenGUI will
162 display the information contents on the screen bottom area.
166 ## Software Architecture
167 The architecture of HomeScreen is shown below.
168 HomeScreen is the service designed to be used by multiple applications.
169 Therefore HomeScreen framework consists on two binder layers. Please refer the following figure.
170 The upper binder is for application side security context for applications. The lower binder is for servide side security context.
171 Usually application side binder has some business logic for each application, so the number of binders depend on the number of applications which use HomeScreen.
172 On the other hand, regarding lower binder there is only one module in the system. This binder receives all messages from multiple applications (in detail, it comes from upper layer binder).
174 The communication protocols between libhomescreen and upper binder, upper binder and lower binder, lower binder (homescreen-binding) are WebSocket.
176 ![software-stack.png](parts/software-stack.png)
181 "libhomescreen" and "agl-service-homescreen" provides several kinds of APIs.
183 ### HomeScreen Specific API
185 - [LibHomeScreen ()](api-ref/html/de/dd0/class_lib_home_screen.html#a724bd949c4154fad041f96a15ef0f5dc)
186 - [init (const int port, const std::string &token)](api-ref/html/de/dd0/class_lib_home_screen.html#a6a57b573cc767725762ba9beab032220)
187 - [tapShortcut(const char *application_id)](api-ref/html/de/dd0/class_lib_home_screen.html#a6ca8ff4a2aa019a735afaff713e0ef44)
188 - [onScreenMessage(const char *display_message)](api-ref/html/de/dd0/class_lib_home_screen.html#ac336482036a72b51a822725f1929523c)
189 - [onScreenReply(const char *reply_message)](api-ref/html/de/dd0/class_lib_home_screen.html#a6c065f41f2c5d1f58d2763bfb4da9c37)
190 - [registerCallback (void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)](api-ref/html/de/dd0/class_lib_home_screen.html#a2789e8a5372202cc36f48e71dbb9b7cf)
191 - [set\_event\_handler(enum EventType et, handler_func f)](api-ref/html/de/dd0/class_lib_home_screen.html#ab1b0e08bf35415de9064afed899e9f85)
192 - [call (const string& verb, struct json_object* arg)](api-ref/html/de/dd0/class_lib_home_screen.html#a527b49dcfe581be6275d0eb2236ba37f)
193 - [call (const char* verb, struct json_object* arg)](api-ref/html/de/dd0/class_lib_home_screen.html#ab5e8e8ab7d53e0f114e9e907fcbb7643)
194 - [subscribe (const string& event_name)](api-ref/html/de/dd0/class_lib_home_screen.html#aa4c189807b75d070f567967f0d690738)
195 - [unsubscribe (const string& event_name)](api-ref/html/de/dd0/class_lib_home_screen.html#aac03a45cbd453ba69ddb00c1016930a6)
196 - [showWindow (const char* application_id, json_object* json)](api-ref/html/de/dd0/class_lib_home_screen.html#a69fc770cb3f94d30a10c2c8c81eb892f)
197 - [hideWindow (const char* application_id)](api-ref/html/de/dd0/class_lib_home_screen.html#a4dbaea6c7b310e8ce7207155ff11b32a)
198 - [replyShowWindow (const char* application_id, json_object* json)](api-ref/html/de/dd0/class_lib_home_screen.html#a6310b129fc85ef0623e2e2063950cc4b)
199 - [showNotification (json_object* json)](api-ref/html/de/dd0/class_lib_home_screen.html#a93ad567ed597a80a344ba82457c2bd7f)
200 - [showInformation (json_object* json)](api-ref/html/de/dd0/class_lib_home_screen.html#ada999aeb0444c964428bdf1ee236727f)
206 ### Initialize Sequence
207 ![initialize-set-event-handler](parts/initialize-set-event-handler.svg)
209 ### Tap Shortcut Sequence
210 ![tap_shortcut.svg](parts/tap_shortcut.svg)
212 ### ShowWindow Sequence
213 ![showWindow.svg](parts/showWindow.svg)
215 ### On Screen Message / Reply Sequence
216 ![on_screen_message.svg](parts/on_screen_message.svg)
218 ### ShowOnScreen Sequence
219 ![showOnScreen.svg](parts/showOnScreen.svg)
221 ### ShowNotification Sequence
222 ![showNotification.svg](parts/showNotification.svg)
224 ### ShowInformation Sequence
225 ![showInformation.svg](parts/showInformation.svg)
230 You can find sample implementation of HomeScreen as below.
232 * `libhomescreen/sample/simple-egl`
234 * `libhomescreen/sample/template`
239 Now OnScreenApp is developing,approximately it will finished at GG.
253 title Application initialization phase
256 entity HomeScreenBinder
259 App->HomeScreenBinder: init(port, token)
260 App->HomeScreenBinder: set_event_handler()
262 note over HomeScreenBinder
263 setup event handler the App wishes to receive
264 ・LibHomeScreen::Event_ShowWindow
265 ・LibHomeScreen::Event_HideWindow
266 ・LibHomeScreen::Event_ReplyShowWindow
274 title Application Callback Event TapShortcut phase
276 entity HomeScreenBinder
278 App->HomeScreenBinder: set_event_handler()
281 LibHomeScreen::Event_TapShortcut
284 HomeScreenGUI->HomeScreenBinder: tapShortcut(application_id)
285 HomeScreenBinder->App: event_handler(application_id)
292 title Application callback event showWindow phase
295 entity "homescreen-service" as hss
298 entity windowmanager as wm
300 user-->launcher: tap app's icon
301 launcher->hss: showWindow()
303 {"application_id":"tapped application id", "parameter":{"area":"display area", ...}}
305 hss->App: push showWindow event
306 App->wm: activateWindow("application_name","display area")
307 wm-->App: push syncDraw event
315 title Application Callback Event On Screen Message / Reply phase
317 entity HomeScreenBinder
320 HomeScreenGUI->HomeScreenBinder: set_event_handler()
322 note over HomeScreenGUI
323 LibHomeScreen::Event_OnScreenMessage
327 App->HomeScreenBinder: set_event_handler()
330 LibHomeScreen::Event_OnScreenReply
333 App->HomeScreenBinder: onScreenMessage(display_message)
334 HomeScreenBinder->HomeScreenGUI: event_handler(display_message)
335 HomeScreenGUI->HomeScreenBinder: onScreenReply(reply_message)
336 HomeScreenBinder->App: event_handler(reply_message)
343 title show/hide onscreen phase
346 entity "homescreen-service" as hss
349 entity windowmanager as wm
352 user->App: the operation request onscreen
353 App->hss: showWindow()
355 {"application_id":"onscreenapp",
356 "parameter":{"area":"display area", "file":"qml file path",
357 "data":{"the datas to onscreen qml"}}}
360 hss->onscreenapp: push showWindow event
361 note over hss,onscreenapp
362 {"application_id":"onscreenapp",
363 "parameter":{"area":"display area", "file":"qml file path",
364 "data":{"the datas to onscreen qml"},
365 <font color=red >"replyto":"caller application id"
369 onscreenapp->onscreenapp: get and save parameters
370 onscreenapp->wm: activateWindow("onscreeapp", "display area")
372 wm-->onscreenapp: push syncDraw event
373 onscreenapp->wm: endDraw("onscreeapp")
374 onscreenapp->onscreenapp: load and display qml file
376 note over onscreenapp,wm
383 user->onscreenapp: tap onscreen's button
384 onscreenapp->hss: replyShowWindow()
385 note over onscreenapp,hss
386 {"application_id":"the application id who called onscreenapp",
387 "parameter": {"buttonName": "VOLUME_UP", "buttonPressMode": "shortPress", "buttonPressState": "release"}}
389 hss->App: push replyShowWindow event
390 App->App: call reply function
391 App->hss: hideWindow("onscreenapp")
392 hss->onscreenapp: push hideWindow event
393 note over hss,onscreenapp
394 {"application_id":"request hideWindow application id"}
396 onscreenapp->wm: deactivateWindow("onscreenapp");
397 onscreenapp->onscreenapp: hide window
405 title show notification on HomeScreen top area
407 entity "homescreen-service" as hss
411 App->hss: showNotification()
413 {"icon":"display icon", "text":"display text"}
415 hss-> homescreen: push showNotification event
416 note over hss,homescreen
417 {"application_id":"request application id",
418 "parameter":{"icon":"display icon", "text":"display text"}}
421 homescreen->homescreen: display notification message 3s
429 title show information on HomeScreen bottom area
431 entity "homescreen-service" as hss
435 App->hss: showInformation()
437 {"info":"display information"}
439 hss-> homescreen: push showInformation event
441 homescreen->homescreen: display information message 3s