summaryrefslogtreecommitdiffstats
path: root/doc/ApplicationGuide.md
blob: 85216dfae356a734dd15210ce8409ba90ccf97c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
**HomeScreen GUI Application / HomeScreen Service Guide**
====
<div align="right">Revision: 0.1</div>
<div align="right">TOYOTA MOTOR CORPORATION</div>
<div align="right">Advanced Driver Information Technology</div>
<div align="right">26th/Sep/2017</div>

* * *

## **<div id="Table\ of\ content">Table of content</div>**
- [Target reader of this document](#Target\ reader\ of\ this\ document)
- [Overview](#Overview)
- [Getting Start](#Getting\ Start)
	- [Supported environment](#Supported\ environment)
	- [Build](#Build)
	- [Configuring](#Configuring)
	- [How to call HomeScreen APIs from your Application?](#How\ to\ call\ HomeScreen\ APIs\ from\ your\ Application?)
- [Supported usecase](#Supported\ usecase)
- [Software Architecture](#Software\ Architecture)
- [API reference](#API\ reference)
- [Sequence](#Sequence)
	- [Initialize](#InitializeSequence)
	- [Tap Shortcut](#TapShortcutSequence)
	- [On Screen Message](#OnScreenMessageSequence)
- [Sample code](#Sample\ code)
- [Limitation](#Limitation)
- [Next Plan](#Next\ Plan)

* * *

## **<div id="Target\ reader\ of\ this\ document">Target reader of this document</div>**
Application developer whose software uses HomeScreen.

* * *

## **<div id="Overview">Overview</div>**
HomeScreenはQtで作成されたGUIアプリケーション(以下、HomeScreenGUI)と、afb-daemonで動作するサービス(以下HomeScreenBinder)で構築されます。HomeScreeはAGLにて動作するアプリケーションの起動、切り替え、およびオンスクリーンメッセージなどの情報表示を行います。

HomeScreenGUIはWindowManagerが提供するAPIを使用しています。

## **<div id="Getting\ Start">Getting Start</div>**

### **<div id="Supported\ environment">Supported environment</div>**
| Item        | Description                       |
|:------------|:----------------------------------|
| AGL version | Daring Dab                        |
| Hardware    | Renesas R-Car Starter Kit Pro(M3) |


### **<div id="Build">Build</div>**

You can make HomeScreen object files by the following two stage operations.

**Download recipe**

If repo is already done, please start with git clone

```
$ mkdir WORK
$ cd WORK
$ repo init -b dab -m dab_4.0.0_xml -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo
$ repo sync
$ git clone git clone https://gerrit.automotivelinux.org/gerrit/staging/meta-hmi-framework

```

Then you can get the following recipe.

* `meta-hmi-framework/homescreen-2017`


**Bitbake**

```
$ source meta-agl/scripts/aglsetup.sh -m m3ulcb agl-demo agl-devel agl-appfw-smack
$ bitbake homescreen-2017
```


* * *

### **<div id="Configuring">Configuring</div>**
To use HomeScreen API, an application shall paste the following configuration definition into "config.xml" of application.

```
<feature name="urn:AGL:widget:required-api">
	<param name="homescreen" value="ws" />
</feature>
```

*) HomeScreenBindingはWindowManagerと同じport、tokenでのアクセスとなります。

* * *

### **<div id="How\ to\ call\ HomeScreen\ APIs\ from\ your\ Application?">How to call HomeScreen APIs from your Application?</div>**
HomeScreen provides a library which is called "libhomescreen".  
This library treats "json format" as API calling.  
For example, if an application wants to call "tap_shortcut()" API, the you should implement as below.  

At first the application should create the instance of libhomescreen.

```
LibHomeScreen* libhs;
libhs = new LibHomeScreen();
libhs->init(port, token);
```

The port and token is provided by Application Framework

Then assign the argument to JSON object

```
struct json_object* jobj = json_object_new_object();

json_object_object_add(jobj, "application_name", json_object_new_string("MediaPlayer"));

```


And finally execute the "cal()" function.

```
libhs->call("tap_shortcut", jobj);
```

Regarding the detail of tap_shortcut() API, please refer [this](#HomeScreen\ API) section.  
The first parameter is the name of API, so in this case "tap_shortcut" is proper string.  
And the second parameter corresponds to arguments of "connect()" API.  


See also our [Sample code](#Sample\ code).


<br />

* * *

## **<div id="Supported\ usecase">Supported usecase</div>**
1. HomeScreenGUIでショートカットアイコンがタップされたときに発行されるイベントを取得する
	- 各アプリケーションは自身がアイコンタップにより起動(または表示)されたことを知るために、HomeScreenBinderに対してイベント登録を行い、そのイベントを取得することができます。
2. オンスクリーンにメッセージを表示する
	- T.B.D

* * *

## **<div id="Software\ Architecture">Software Architecture</div>**
The architecture of HomeScreen is shown below.  
HomeScreen is the service designed to be used by multiple applications.  
Therefore HomeScreen framework consists on two binder layers. Please refer the following figure.  
The upper binder is for application side security context for applications. The lower binder is for servide side security context.  
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.  
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).

The communication protocols between libhomescreen and upper binder, upper binder and lower binder, lower binder (homescreen-binding) are WebSocket.

![software-stack.png](parts/software-stack.png)

* * *

## **<div id="API%20reference">API reference</div>**
"libhomescreen" and "HomeScreenBinding" provides several kinds of APIs.

### **<div id="Home\ Screen\ Specific\ API">HomeScreen Specific API</div>**

- [LibHomeScreen ()](api-ref/html/de/dd0/class_lib_home_screen.html#a724bd949c4154fad041f96a15ef0f5dc)
- [init (const int port, const std::string &token)](api-ref/html/de/dd0/class_lib_home_screen.html#a6a57b573cc767725762ba9beab032220)
- [tapShortcut(const char *application_name)](api-ref/html/de/dd0/class_lib_home_screen.html#afb571c9577087b47065eb23e7fdbc903)
- [onScreenMessage(const char *display_message)](api-ref/html/de/dd0/class_lib_home_screen.html#ac336482036a72b51a822725f1929523c)
- [set\_event\_handler(enum EventType et, handler_func f)](api-ref/html/de/dd0/class_lib_home_screen.html#ab1b0e08bf35415de9064afed899e9f85)
- [call (const string& verb, struct json_object* arg)](api-ref/html/de/dd0/class_lib_home_screen.html#a527b49dcfe581be6275d0eb2236ba37f)
- [call (const char* verb, struct json_object* arg)](api-ref/html/de/dd0/class_lib_home_screen.html#ab5e8e8ab7d53e0f114e9e907fcbb7643)
- [subscribe (const string& event_name)](api-ref/html/de/dd0/class_lib_home_screen.html#aa4c189807b75d070f567967f0d690738)
- [unsubscribe (const string& event_name)](api-ref/html/de/dd0/class_lib_home_screen.html#aac03a45cbd453ba69ddb00c1016930a6)

* * *

## **<div id="Sequence">Sequence</div>**

### **<div id="InitializeSequence">Initialize</div>**
![initialize.svg](parts/initialize.svg)

### **<div id="TapShortcutSequence">Tap Shortcut</div>**
![tap_shortcut.svg](parts/tap_shortcut.svg)

### **<div id="OnScreenMessageSequence">On Screen Message</div>**
![on_screen_message.svg](parts/on_screen_message.svg)


# **<div id="Sample\ code">Sample code</div>**
You can find sample implementation of HomeScreen as below.

* `HomeScreenBinding/libhomescreen/test.cpp`

### Appendix

```
@startuml
title Application initialization phase
entity App
entity HomeScreenBinder
entity HomeScreenGUI
App->HomeScreenBinder: init(port, token)
App->HomeScreenBinder: subscribe()

note over HomeScreenBinder
    Appが受信したいイベントを登録する
    ・tap_shortcut
end note

App->HomeScreenBinder: registerCallback()
App->HomeScreenBinder: set_event_handler()

note over HomeScreenBinder
    イベント受信のコールバック登録
    registerCallbackによる登録または
    set_event_handlerによる登録どちらかでOK
end note

@enduml
```

```
@startuml
title Application Callback Event TapShortcut phase
entity App
entity HomeScreenBinder
entity HomeScreenGUI
note over App
    Appは初期化時に
    TapShortcutのイベントを受け取る設定をしていること
end note
HomeScreenGUI->HomeScreenBinder: tapShortcut(application_name)
HomeScreenBinder->App: eventCallback(application_name)
@enduml

```

```
@startuml
title Application Callback Event TapShortcut phase
entity App
entity HomeScreenBinder
entity HomeScreenGUI
App->HomeScreenBinder: onScreenMessage(display_message)
HomeScreenBinder->HomeScreenGUI: eventCallback(display_message)
@enduml

```