A downloadable native service is a 3rd party native service that can be installed on the webOS target device.
Downloadable vs. Built-In
In webOS OSE, apps and services are divided into two categories: downloadable and built-in.
Downloadable apps/services are installed by appinstalld service. This service automatically generates several configurations for the apps/services. (such as trust level)
Built-in apps/services are built and installed by developers. Developers can customize configurations to suit their needs.
This tutorial shows a step-by-step guide for creating a downloadable native service from scratch.
After installing the CLI, you must register your target device. Enter the ares-setup-device command to start an interactive mode:
Note In the interactive mode, pressing the Enter key means to use the default value.
document@document:~$ ares-setup-device
name deviceinfo connection profile
------------------ ------------------------ ---------- -------
emulator (default) developer@127.0.0.1:6622 ssh ose
** You can modify the device info in the above list, or add new device.
? Select add # Select 'add'.? Enter Device Name: webos # The nickname of your target device. Use the short name.? Enter Device IP address: 127.0.0.1 # The IP address of your target device? Enter Device Port: 22# Just press the Enter key. Do not change this value.? Enter ssh user: root # Just press the Enter key. Do not change this value.? Enter description: new device # Descriptions about your target device? Select authentication password # Select 'password'? Enter password: [hidden]# Leave it blank (Press the Enter key).? Set default ? No # Enter 'y' if you want to set this device as the default device.? Save ? Yes # Enter 'Yes'.name deviceinfo connection profile
------------------ ------------------------ ---------- -------
webos root@127.0.0.1:22 ssh ose
emulator (default) developer@127.0.0.1:6622 ssh ose
Native Development Kit
Native Development Kit (NDK) is a set of tools that include toolchains, libraries, and header files. NDK enables you to build a native app on your computer.
Go to your app directory. (samples/native-services/downloadable/com.sample.echo.service/))
Create a build directory and go into the directory.
$ mkdir BUILD
$ cd BUILD
Execute the build commands.
$ cmake ..
$ make
If the commands succeed, a pkg_<YOUR_ARCHITECTURE> directory will be generated in your app directory. <YOUR_ARCHITECTURE> depends on your build machine’s architecture.
In the following example, the pkg_aarch64 directory is generated.
pkg_aarch64/
├── echo_service
└── services.json
Step 02. Packaging the Service
To install the service, you have to package the service with an app first.
Line (2): Includes lunaservice.h header file to use luna service. For detailed information about luna service, see Introduction to LS2 API.
Line (4-8): Declares the echo method.
Line (11-14): Implements echo method. This method will return the input as you entered.
Line (16): Returns a handle to the connection-to-bus through which the message was sent.
Line (18): Appends a method to the category.
Line (20): Attaches a service to a glib mainloop.
services.json
services.json stores the metadata of the service.
{
"id": "com.sample.echo.service", // An ID of the "services" array. Typically, this value is the "name" of the first object of the "services" array.
"description": "Native echo service",
"engine":"native",
"services": [
{
"name": "com.sample.echo.service", // A unique identifier of the service.
// This value MUST START with the app ID, which is packaged with the service.
// For example, if the app ID is com.domain.app, the service ID must start with com.domain.app.xxx. (e.g., com.domain.app.service)
"description": "Native echo service" }
]
}
CMakeLists.txt file is used by CMake to generate the Makefile to build the project. This file specifies the source, header, and UI files included in the project.