Application framework

From Tizen Wiki
Jump to: navigation, search

Application Framework

These pages should detail the correct usage of the application Framework.

This will be done in two parts: one concerning the installation/uninstallation of applications i.e. package management and the other one concerning the Life Cycle of an application.

Rules & Definitions

Please note that:

  • A package contains one or more applications, it can be seen as an applications container.
  • AppID = <pkgID>.<app_name>
  • "-" is an allowed character for the name of an application but it is not supported in AppID in the case where a name contains "-", they are removed from the AppID.

So a pkgID should not be used to identify an application, AppID != pkgID.
We do not install an application but we install a package.

Overview

AMD-MULTIUSER OVERVIEW.jpg


Package Management

On Tizen, the package management is managed by package manager server (process named pkgmgr-server). This daemon is launched as system daemon.

Its role is mainly focused on receiving requests & managing them by delegating the work to a backend corresponding to the type of an application.

Sending a request to the package manager server

On Tizen, calling a backend manually can lead to an inconsistent state of the system.

The only way to send request is to use package-manager CAPI (slp-pkgmgr package : client/include/package-manager.h )

A tool named pkgcmd implements the main CAPI calls. The available options are as follows:

 pkgcmd 
 
 Package Manager Tool Version: 0.1
 
 -i, --install		install the package
 -u, --uninstall		uninstall the package
 -r, --reinstall		reinstall the package
 -c, --clear		clear user data
 -m, --move		move package
 -g, --getsize		get size of given package
 -T, --getsize-type	get type [0 : total size /1: data size]
 -l, --list		display list of installed packages available for the current user [i.e. User's specific Apps and Global Apps] 
 -s, --show		show detail package info
 -a, --app-path		show app installation path
 -C, --check		check if applications belonging to a package are running or not
 -k, --kill		terminate applications belonging to a package
 -d, --descriptor	provide descriptor path
 -p, --package-path	provide package path
 -n, --package-name	provide package name
 -t, --package-type	provide package type
 -T, --move-type	provide move type [0 : move to internal /1: move to external]
 -q, --quiet		quiet mode operation
 -G, --global	Global Mode [Warning user should be privileged to use this mode] 
 -h, --help	.	print this help

Backend Registration

For registering a backend, one needs to:

  • Have a binary that manages installation/uninstallation/reinstallation operation on the package by handling dedicated parameters (backend options)
  • Use pkgmgr_parser CAPI to manage properly the application registration in pkgmgr-parser database and ail database
 For installation:   
                  Dedicated user                       /        Global 
    pkgmgr_parser_parse_usr_manifest_for_installation / pkgmgr_parser_parse_manifest_for_installation
 For uninstallation:
 pkgmgr_parser_parse_usr_manifest_for_uninstallation / pkgmgr_parser_parse_manifest_for_uninstallation
  • Manage the installation according to the user that calls the backend.
 if getuid() == %{TZ_SYS_GLOBALAPP_USER} 
 then we should manage the operations as Global, Common Applications database
      (for example, in case of installation we install the applications for all users)
 else we operate for the user only
      (for example, in case of installation we install the applications for only the current user)
  • Create a symbolic link to associate the backend to an specific extension package see section :"Associate to a application type"

Backend Options

The following backend options are available:

 -i <path to package>: Installation of the package 
 -u <path to package>: Uninstallation of the package
 -r <path to package>: Reinstallation of the package
 -k <Id of request> : permits to register request id to be able to notify package manager server of the processus status during the operation.
 -q : quiet mode (not mandatory)

For example, installation of package can be done as follows.

 backend_executable -i /path/to/package/ext -k <key> (-q)

Associating to an application type

For associating a backend to a type of application we need to simply create a symbolic link as below:

 ln -s /etc/package-manager/backend/<entension_of_app> /path/to/binary

For example,

 ls -l /etc/package-manager/backend/wgt 
 lrwxrwxrwx. 1 root root 39 oct.  21 00:46 /etc/package-manager/backend/wgt -> /usr/lib/xwalk/xwalk_backend_wrapper.sh

NOTE: After adding a backend, by creating a symbolic link, you need to restart the server ( i.e. pkgmgr-server)

Application Paths

Overview

They are defined in Tizen Platform config Multi-user_Tizen-platform-config.

There are five paths for managing Common Apps and five paths for the user-specific ones.

  • Applications files
  • Applications/Packages Database
  • Manifest Files
  • Desktop Files
  • Icons Files

Global Common App Paths

These start with TZ_SYS in tizen platform config.

TZ_SYS_RW_APP=/usr/apps is the directory used to store applications.

TZ_SYS_RW_PACKAGES=/usr/share/packages is the directory used to store manifest of common apps.

TZ_SYS_RW_DESKTOP_APP=/usr/share/applications is used to store desktop file.

TZ_SYS_DB=/usr/dbspace is used to stored databases (included applications databases).

TZ_SYS_RW_ICONS=/usr/share/icons is used for icons.

User App Paths

These start with TZ_USER in tizen platform config.

TZ_USER_DB=${TZ_USER_HOME}/.applications/dbspace is used to stored databases (included applications databases).

TZ_USER_PACKAGES=${TZ_USER_HOME}/.applications/manifest is the directory used to store manifest of user apps.

TZ_USER_DESKTOP=${TZ_USER_HOME}/.applications/desktop is used to store desktop file.

TZ_USER_ICONS=${TZ_USER_HOME}/.applications/icons is used to store icons.

TZ_USER_APP ( requires some adaptation in Crosswalk package) used to store applications.


File Applications Full Paths

For the applications files, the full paths should follow this logic:

<ROOT_APP>/<pkg_id>/<app_name>

ROOT_APP should equals to :

  • TZ_USER_APP in single user's installation
  • TZ_SYS_RW_APP in common/global installation

Application preinstallation

On Tizen, we can preinstall an application during image creation. At this time, only Global Common applications can be preinstalled.

Requirements

All files related to the application itself should be stored in $(TZ_SYS_RW_APP)/pkgId/AppName. The manifest of the application should be stored in $(TZ_SYS_RW_PACKAGES). The icon of the application should be stored in $(TZ_SYS_RW_ICONS). The desktop file of the application should be stored in $(TZ_SYS_RW_DESKTOP_APP).

To register them don't forget to call as Root at the end of image creation.

 pkg_initdb
 ail_initdb

Application Management (Application Life Cycle)

App lifecycle is mostly up to a daemon called AMD. This daemon communicates through a socket to all `amd_session_agent`s.

There is one `amd_session_agent` for each opened PAM session. This agent permits launching apps in a dedicated environment associated with a user.

Sending a request to Application Manager Daemon

On Tizen, calling an applications by executing the binary of the applications can lead to an inconsistent system state.
In this case, AMD will not be aware of the applications launching and is unable to interact with them.

The only way to send request is to use the AUL CAPI (aul-1 package : include/aul.h).

Without TC-1883:

There are dedicated tools such as `open_app` and `ail_list` which wrap the main CAPI calls. (deprecated)

 open_app
 [usage] open_app <appid> <-d>
 ail_list
 [usage] ail_list

With TC-1883:

The previous commands are available only if you install the `aul-test` package.

 app_launcher
 Usage : app_launcher [ ... ]
  -h                        --help              Display this usage information.
  -l                        --list              Display installed apps list
  -S                        --status            Display running apps list
  -s [tizen application ID] --start             Launch widget with tizen application ID
  -k [tizen application ID] --kill              Kill widget with tizen application ID
  -r [tizen application ID] --is-running        Check whether application is running by tizen application ID,
                                                If widget is running, 0(zero) will be returned.
  -d                        --debug             Activate debug mode

HOWTO

Caution

For calling platform binary (such as xwalkctl or xwalk-launcher can lead to inconsistent state), you need to use binary that use CAPI.

Package Management

The following operations can be performed only after logging in as dedicated user exclude the user guest. Users root and guest cannot install packages.

Remember for installing application for dedicated user no privileged requirement is needed but for installing packages common for all users (-G as Global packages) the user should be as part as group system ie a privilege user.

 Installation 
 pkgcmd -i -t <pkg type> -p <pkg path> (-G) (-q)
 Uninstallation 
 pkgcmd -u -n <pkgid> (-G) (-q)  // NOTE the pkgid should be used NOT the appid.
 List the installed packages 
 pkgcmd -l
 Kill all applications associated to a package ID (usefull in case of uninstallation)
 pkgcmd -k -n <pkgid>

at this time the non quiet mode doesn't work (https://bugs.tizen.org/jira/browse/TC-1687) you should add -q option systematically

Application Management

Each user cannot access to others users applications and can launch only its owns applications (installed by that user) and global applications.

The user guest can launch global applications as it is logged by default at the start of the system.

On IVI, only the user 'app' can launch applications until the 'multi-seat' feature is implemented. See https://bugs.tizen.org/jira/browse/TC-1884

Legacy HOWTO Tizen IVI 14.3 Release:

 list available application IDs
 ail_list
 launch an application
 open_app <app_id>
 launch an application with debug mode
 open_app <app_id> -d

There is a new app_launcher tool (Feature TC-1883) on Tizen Common.

 list available application IDs
 app_launcher -l
 launch an application
 app_launcher -s <app_id>
 launch an application with debug mode
 app_launcher -s <app_id> -d
 Get all running applications of the current user
 app_launcher -S
 kill an app
 app_launcher -k <app_id>
 Status of a specific app
 app_launcher -r <app_id>