Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Tizen Application Inside Out
2016-01-23 Tizen Talks
Semun Lee
Software R&D Center
Samsung Electronics
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 2
Tizen Architecture
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 3
Tizen Native API
https://developer.tizen.org/develo...
Tizen Native Application Model
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 5
Tizen Native Application
• Written in C / C++
– Can...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 6
Application Lifecycle
int
main(int argc, char *argv...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 7
Application Lifecycle
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 8
Application Lifecycle
• app_create
– called when th...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 9
App Control
• Provides functions for launching othe...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 10
App Control
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 11
App Control – Explicit Launch
#include <app.h>
#in...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 12
App Control – Implicit Launch
#include <app.h>
#in...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 13
Exporting App Control Functionality
• An applicati...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 14
Handling Launch Options From App Control
• An appl...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 15
Handling System Events
int
main(int argc, char *ar...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 16
Application Manifest XML
<?xml version="1.0" encod...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 17
Application Privilege
• Some APIs need certain pri...
Life of Tizen Application Process
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 19
Launching Application
• App-control API
– API for ...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 20
Launching Application
homescreen app
amd
launchpad...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 21
launchpad and launchpad-loader
• Application launc...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 22
Creating UI
• app-core
– library for control appli...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 23
Creating UI
static bool
app_create(void *data)
{
a...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 24
Pause / Resume
• app-core revisited
– app-core lib...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 25
App Control
• app-core again
– app-core handles ap...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 26
App Control
application
amd
launchpad
launchpad-lo...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 27
Terminate
• Application can be terminated
– by its...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 28
Cast
• Applications
• app-core: platform/core/appf...
Thank You!
Appendix:
Tizen Application Framework Native APIs
Tizen Event System
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 32
Tizen Event System
• Event Publication/Subscriptio...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 33
For Typical Tizen Application
• Application can ad...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 34
Predefined System Events
• SYSTEM_EVENT_BATTERY_CH...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 35
• SYSTEM_EVENT_INCOMMING_MSG
• SYSTEM_EVENT_TIME_C...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 36
For Internal-Use (for daemon or special app)
• Use...
App Group Launching Management
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 38
App Group Launching Management
• App 실행시 sub-view ...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 39
App Group API
• APIs provide methods to set and ge...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 40
Launch Mode Attribute
• The new attribute in tizen...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 41
Note on App Group Launching
• Group launch된 callee...
Message Port API
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 43
Message Port
• Applications can send and receive m...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 44
Message Port - Example
void message_port_cb(int lo...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 45
Message Port - Example
void send_message(void)
{
i...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 46
Trusted Communication
• Applications that are deve...
Data Control API
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 48
Data Control
• Data control is a mechanism for exc...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 49
Providing Data Control
• Service applications can ...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 50
Data Control Provider - Example
data_control_provi...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 51
Data Control Provider - Example
static GHashTable ...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 52
Data Control Consumer - Example
data_control_map_r...
Package Manager API
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 54
Package Manager API
• Used to retrieve detailed in...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 55
Getting Specific Package Information
char *version...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 56
Listening to Package Events
void
event_cb(const ch...
Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 57
References
• Tizen 2.4 API reference
– https://dev...
Upcoming SlideShare
Loading in …5
×

Tizen application inside out

2,041 views

Published on

Tizen application inside out by Semun Lee

Published in: Software
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Tizen application inside out

  1. 1. Tizen Application Inside Out 2016-01-23 Tizen Talks Semun Lee Software R&D Center Samsung Electronics
  2. 2. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 2 Tizen Architecture
  3. 3. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 3 Tizen Native API https://developer.tizen.org/development
  4. 4. Tizen Native Application Model
  5. 5. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 5 Tizen Native Application • Written in C / C++ – Can use Tizen Native APIs • Usually, use EFL as the UIFW • Follows Tizen application lifecycle – app-core library controls application’s lifecycle • Two types of application – UI Application • An application that has UI – Service Application • An application that doesn’t have UI. • Supports UI application in background
  6. 6. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 6 Application Lifecycle int main(int argc, char *argv[]) { appdata_s ad = {0,}; int ret = 0; ui_app_lifecycle_callback_s event_callback = {0,}; event_callback.create = app_create; event_callback.terminate = app_terminate; event_callback.pause = app_pause; event_callback.resume = app_resume; event_callback.app_control = app_control; ret = ui_app_main(argc, argv, &event_callback, &ad); if (ret != APP_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret); } return ret; } Example:
  7. 7. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 7 Application Lifecycle
  8. 8. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 8 Application Lifecycle • app_create – called when the process starts – recommend to create UI components • app_control – called after the app_create when the process starts or called when a launch request is received while the process is running – can receive app_control data (parameters for launching the application) – recommend to implement parameter specific actions of the application • app_resume (UI application only) – called when the window of the application is shown • app_pause (UI application only) – called when the window of the application is totally hidden • app_terminate – called while the process of the application is terminating – called after the main loop quits
  9. 9. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 9 App Control • Provides functions for launching other applications • Explicit launch – Launch the application with the application ID • Implicit launch – Launch the application with an operation, URI, or MIME type
  10. 10. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 10 App Control
  11. 11. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 11 App Control – Explicit Launch #include <app.h> #include <dlog.h> #define TAG "MY_TAG" app_control_h app_control; app_control_create(&app_control); app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT); app_control_set_app_id(app_control, "org.tizen.calculator"); if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE) { dlog_print(DLOG_INFO, TAG, "Succeeded to launch a calculator app."); } else { dlog_print(DLOG_ERROR, TAG, "Failed to launch a calculator app."); } app_control_destroy(app_control);
  12. 12. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 12 App Control – Implicit Launch #include <app.h> #include <dlog.h> #define TAG "MY_TAG" app_control_h app_control; app_control_create(&app_control); app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW); app_control_set_uri(app_control, "file:///home/myhome/Photos/1_photo.jpg"); app_control_set_mime(app_control, "image/*"); app_control_add_extra_data(app_control, “show_mode”, “auto”); if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE) { dlog_print(DLOG_INFO, TAG, "Succeeded to launch a viewer app."); } else { dlog_print(DLOG_ERROR, TAG, "Failed to launch a viewer app."); } app_control_destroy(app_control);
  13. 13. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 13 Exporting App Control Functionality • An application exn export app control functionality by adding <app- control> tag to the manifest xml file <app-control> <mime name="application/xhtml+xml"/> <operation name="http://tizen.org/appcontrol/operation/view"/> <uri name="http://test.com"/> </app-control>
  14. 14. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 14 Handling Launch Options From App Control • An application can receive extra data in the app control callback static void app_control(app_control_h app_control, void *user_data) { struct appdata *ad = (struct appdata *)user_data; char *operation; char *uri; char *mime_type; char *show_mode; app_control_get_operation(app_control, operation); if (!strcmp(operation, APP_CONTROL_OPERATION_VIEW)) { app_control_get_uri(app_control, &uri); app_control_get_mime(app_control, &mime_type); app_control_get_extra_data(app_control, “show_mode”, &show_mode); if (uri && !strcmp(mime_type, "image/jpg")) { display_image_file(ad, uri, show_mode); // Display a specific image file } } if (ad->win) elm_win_activate(ad->win); }
  15. 15. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 15 Handling System Events int main(int argc, char *argv[]) { …… app_event_handler_h handlers[5] = {NULL, }; ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad); ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad); ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad); ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad); ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad); …… } Example:
  16. 16. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 16 Application Manifest XML <?xml version="1.0" encoding="UTF-8" standalone="no"?> <manifest xmlns="http://tizen.org/ns/packages" api-version="2.4“ package="org.example.appcontrol1" version="1.0.0"> <ui-application appid="org.example.appcontrol1“ exec="appcontrol1" multiple="false“ nodisplay="false" taskmanage="true" type="capp"> <label>appcontrol1</label> <icon>appcontrol1.png</icon> <metadata key="http://developer.samsung.com/tizen/metadata/legacylifecycle"/> </ui-application> <privileges> <privilege>http://tizen.org/privilege/appmanager.launch</privilege> <privilege>http://tizen.org/privilege/alarm.set</privilege> </privileges> </manifest> • manifest xml (e.g. org.tizen.tv-viewer.xml) contains information about the application • package id, app id, executable path, etc • can declare metadata or privileges
  17. 17. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 17 Application Privilege • Some APIs need certain privileges for calling the API – app_control_send_launch_request() API needs http://tizen.org/privilege/appmanager.launch privilege • So, applications should declare proper privileges to use some APIs
  18. 18. Life of Tizen Application Process
  19. 19. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 19 Launching Application • App-control API – API for launching application – homescreen uses app-control API to launch an application • AMD – Application management daemon – Manages information about installed applications – Manages status of application processes • launchpad – Parent process of all applications – Handles launch request from amd – Manages launchpad-loaders • launchpad-loader – Pre-initialized process for applications – launchpad-loader is changed to real application
  20. 20. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 20 Launching Application homescreen app amd launchpad launchpad-loader 0 launchpad-loader 1 wrt-oader *wrt: web runtime org.tizen.calcualtor 1. request launching an application 2. amd validates the request and find information about the app 3. amd passes the request to the launchpad 4. launchpad find proper launchpad-loader for the request type 5. launchpad requests launchpad-loader to run the application 6. launchpad-loader loades application’s executable file and calls main() same process
  21. 21. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 21 launchpad and launchpad-loader • Application launching should be fast!! – launchpad and launchpad-loader was introduced for it. • launchpad forks launchpad-loaders for each application type – EFL native application – EFL native application with pre-initialized basic window – Web application • launchpad-loader pre-initialize the parts all applications share – preloads shared libraries all application share – calls basic init function (e.g. elm_init) – creates basic type window for most applications – dlopen() application’s executable file and call main directly to run the application • application can use pre-initialized parts because it starts from pre-initialized launchpad-loader process
  22. 22. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 22 Creating UI • app-core – library for control application lifecycle – works in ui_app_main() application process app-core ui_app_main() before_loop() - initialize app common things - create app_create() callback elm_run() - starts main event loop
  23. 23. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 23 Creating UI static bool app_create(void *data) { appdata_s *ad = data; /* Window */ /* Create and initialize elm_win. elm_win is mandatory to manipulate window. */ ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); … /* Label */ /* Create an actual view of the base gui. Modify this part to change the view. */ ad->label = elm_label_add(ad->conform); elm_object_text_set(ad->label, "<align=center>Hello Tizen</align>"); evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_content_set(ad->conform, ad->label); /* Show window after base gui is set up */ evas_object_show(ad->win); return true; }
  24. 24. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 24 Pause / Resume • app-core revisited – app-core library listens window event and changes application’s state from running and paused • Window manager (enlightenment) – Manages windows – Sends events for window visibility changes application process app-core enlightenment 1. request to show app’s window 2. window manager changes window stack 3. send events for window visibility changes 4. listen window visibility event. - change app’s state to running if the window is shown - change app’s state to running if the window is hidden
  25. 25. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 25 App Control • app-core again – app-core handles app-control request – applications can send app-control to request an operation to another application • amd – amd checks if the operation can be handled by running application or needs to launch a new application process – If the operation can be handled by running application the request is relayed to the application’s process
  26. 26. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 26 App Control application amd launchpad launchpad-loader 1. request launching an application (send app-control) 2. amd validates the request and find information about the app 3. if the request can be handled running application, the request is relayed to the running application application process app-core 4. app-core calls app_control_cb
  27. 27. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 27 Terminate • Application can be terminated – by itself calling ui_app_exit() – by request from the platform application process app-core ui_app_exit() elm_exit() after_loop() - release resources - call app_pause_cb() if its state is ‘running’ - call app_terminate_cb() termination request from the platform
  28. 28. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 28 Cast • Applications • app-core: platform/core/appfw/app-core, platform/core/api/application • amd: platform/core/appfw/amd, platform/core/appfw/aul-1 • launchpad: projects/platform/core/appfw/launchpad • launchpad-loader: projects/platform/core/appfw/launchpad • guest appearance – EFL – Enlightenment Window Manager
  29. 29. Thank You!
  30. 30. Appendix: Tizen Application Framework Native APIs
  31. 31. Tizen Event System
  32. 32. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 32 Tizen Event System • Event Publication/Subscription – Application can broadcast own event to all the listeners. – Application can receive pre-defined events from the platform. (system- event) • “Launch On Event” (Service-application only) – Applications can be launched when the interested event occurs. • Event Type – System-Event • System-wide event from the platform. • Only platform modules can broadcast the system-event. – User-Event • User-defined event. • Applications(UI and Service) can broadcast own event.
  33. 33. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 33 For Typical Tizen Application • Application can add/remove event-handler using API. • Application can add multiple event-handler per one Event. • Service-application can be launched by the event triggering. – The APP_CONTROL_OPERATION_LAUNCH_ON_EVENT must be defined in the manifest file. – This operation can not be requested via app_control_send_launch_request(). – Only service-application can define this operation. – The uri name represents event name for “Launch On Event”. (format: “event://{Event_Name}”) – For more information, refer to ‘Launch_On_Event’ slide. • Application can send user-event only. (not system-event) • Application can receive both user-event and system-event. • Application can send trusted user-event. – Only applications which have same signature with sender application can receive sender’s event. • Event System Daemon (ESD) – ESD manages the event list for “Launch On Event”. – ESD launch the requested applications when the interested event occurs. <app-control> <operation name="http://tizen.org/appcontrol/operation/launch_on_event"/> <uri name=“event://tizen.system.event.battery_level_status"/> </app-control> <app-control> <operation name="http://tizen.org/appcontrol/operation/launch_on_event"/> <uri name=“event://event.org.tizen.senderapp.user_event"/> </app-control
  34. 34. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 34 Predefined System Events • SYSTEM_EVENT_BATTERY_CHARGER_STATUS • SYSTEM_EVENT_BATTERY_LEVEL_STATUS • SYSTEM_EVENT_USB_STATUS • SYSTEM_EVENT_EARJACK_STATUS • SYSTEM_EVENT_DISPLAY_STATE • SYSTEM_EVENT_BOOT_COMPLETED • SYSTEM_EVENT_SYSTEM_SHUTDOWN • SYSTEM_EVENT_LOW_MEMORY • SYSTEM_EVENT_WIFI_STATE • SYSTEM_EVENT_BT_STATE • SYSTEM_EVENT_LOCATION_ENABLE_STATE • SYSTEM_EVENT_GPS_ENABLE_STATE • SYSTEM_EVENT_NPS_ENABLE_STATE
  35. 35. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 35 • SYSTEM_EVENT_INCOMMING_MSG • SYSTEM_EVENT_TIME_CHANGED • SYSTEM_EVENT_TIME_ZONE • SYSTEM_EVENT_HOUR_FORMAT • SYSTEM_EVENT_LANGUAGE_SET • SYSTEM_EVENT_REGION_FORMAT • SYSTEM_EVENT_SILENT_MODE • SYSTEM_EVENT_VIBRATION_STATE • SYSTEM_EVENT_SCREEN_AUTOROTATE_STATE • SYSTEM_EVENT_MOBILE_DATA_STATE • SYSTEM_EVENT_DATA_ROAMING_STATE • SYSTEM_EVENT_FONT_SET
  36. 36. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 36 For Internal-Use (for daemon or special app) • Use low-level API directly . – eventsystem_send_system_event() – eventsystem_request_sending_system_event() • This is only for privileged application which can not use evensystem_send_system_event() API because of d-bus policy. (e.g. setting, quick panel) – eventsystem_register_event() – eventsystem_unregister_event()
  37. 37. App Group Launching Management
  38. 38. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 38 App Group Launching Management • App 실행시 sub-view 개념으로 실행하고 싶은 경우 group launch feature 제공 App 1 App 2 group launch home App 1 App 2 Home launch app 1 App 1 App 2 Home
  39. 39. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 39 App Group API • APIs provide methods to set and get launching mode – The new APIs • enum app_control_launch_mode_e { APP_CONTROL_LAUNCH_MODE_SINGLE, APP_CONTROL_LAUNCH_MODE_GROUP } 1 App_control.c int app_control_set_launch_mode(app_control_h app_control, app_control_launch_mode_e mode) int app_control_get_launch_mode(app_control_h app_control, app_control_launch_mode_e *mode)
  40. 40. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 40 Launch Mode Attribute • The new attribute in tizen-manifest.xml is available – ‘launch_mode’ in ‘ui-application’ tag • single – This app will not be attached on caller app – Default 'launch_mode' is ‘single’. • group – This app will be attached on caller app • caller – Caller app can set the launch mode. – Example <ui-application appid="org.tizen.test“ launch_mode=“caller”/>
  41. 41. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 41 Note on App Group Launching • Group launch된 callee app은 각각 별도 process로 실행 됨. • Group launch된 app은 App 상태 관리에 나타나지 않음 – app running 상태에 표시되지 않음 – RUA history 에 추가되지 않음 -> task manager에 표시되지 않음 – app 상태 관리는 항상 group leader 단위로 이루어짐 App 1 App 2 group launch App 3 App 2 group launch different process
  42. 42. Message Port API
  43. 43. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 43 Message Port • Applications can send and receive messages through message port communication • Local port is used to register your message port and prepare to receive messages from another application • Remote port is used to send messages to other applications
  44. 44. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 44 Message Port - Example void message_port_cb(int local_port_id, const char *remote_app_id, bundle *message) { char *command = NULL; char *data = NULL; bundle_get_str(message, "command", &command); bundle_get_str(message, "data", &data); dlog_print(DLOG_INFO, TAG, "Message from %s, command: %s data: %s", remote_app_id, command, data); } …… int port_id = message_port_register_local_port(“mytestport”, message_port_cb, NULL); if (port_id < 0) { dlog_print(DLOG_ERROR, LOG_TAG, "Port register error : %d", port_id); } else { dlog_print(DLOG_INFO, LOG_TAG, "port_id : %d", port_id); } …… Registering local port (in org.tizen.mytestapp)
  45. 45. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 45 Message Port - Example void send_message(void) { int ret; bundle *b = bundle_create (); bundle_add_str (b, "command", "begin"); bundle_add_str (b, "data", "dummy"); ret = message_port_send_message (“org.tizen.mytestapp”, “mytestport”, b); if (ret != MESSAGE_PORT_ERROR_NONE) { dlog_print(DLOG_ERROR, TAG, "message_port_check_remote_port error : %d", ret); } else { dlog_print(DLOG_INFO, TAG, "Send message done"); } bundle_free (b); } Sending message (in org.tizen.anotherapp)
  46. 46. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 46 Trusted Communication • Applications that are developed by the same developer can send and receive messages using trusted message port
  47. 47. Data Control API
  48. 48. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 48 Data Control • Data control is a mechanism for exchanging specific data between applications • Provider provides data to the consumer • Provider is identified by the provider ID • Two types of data – Map : <key, value> data access – SQL : SQL query type data access
  49. 49. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 49 Providing Data Control • Service applications can provide data control with <datacontrol> tag in the manifest xml file • When a consumer app request data control to the provider id, the provider app is launched and can response for the data control request <?xml version="1.0" encoding="UTF-8" standalone="no"?> <manifest xmlns="http://tizen.org/ns/packages" api-version="2.4“ package="org.example.service" version="1.0.0"> <profile name="wearable"/> <service-application appid="org.example.service“ exec="service" multiple="false" nodisplay="true" taskmanage="false" type="capp"> <label>service</label> <icon>service.png</icon> <datacontrol access="ReadWrite“ providerid="http://samsung.com/datacontrol/provider/service" type="Map"/> </service-application> </manifest>
  50. 50. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 50 Data Control Provider - Example data_control_provider_map_cb map_callback; void initialize_datacontrol_provider() { map_repository_test = g_hash_table_new_full(g_str_hash, g_str_equal, __free_key, __free_data); map_callback.get_cb = get_value_request_cb; map_callback.add_cb = add_value_request_cb; map_callback.remove_cb = remove_value_request_cb; map_callback.set_cb = set_value_request_cb; int result = data_control_provider_map_register_cb(&map_callback); if(result != DATA_CONTROL_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "data_control_provider_map_register_cb failed with error: %d", result); } else { dlog_print(DLOG_INFO, LOG_TAG, "Provider map register success"); } }
  51. 51. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 51 Data Control Provider - Example static GHashTable *map_repository_test; void get_value_request_cb(int request_id, data_control_h provider, const char *key, void *user_data) { map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key); int ret_value_count = 0; char **val_arr = NULL; if (map_data != NULL) { val_arr = map_data->str_arr; ret_value_count = map_data->arr_size; } int ret = data_control_provider_send_map_get_value_result(request_id, val_arr, ret_value_count); if (ret != DATA_CONTROL_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "send_map_get_result failed with error: %d", ret); } else { dlog_print(DLOG_INFO, LOG_TAG, "Get value success request_id : %d", request_id); } }
  52. 52. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 52 Data Control Consumer - Example data_control_map_response_cb map_callback; void initialize_datacontrol_consumer(appdata_s *ad) { const char *provider_id = “http://samsung.com/datacontrol/provider/service”; const char *data_id = "table"; int req_id; // Create data control handler data_control_map_create(&(ad->provider_h)); data_control_map_set_provider_id(ad->provider_h, provider_id); data_control_map_set_data_id(ad->provider_h, data_id); // Set response callback map_callback.get_cb = map_get_response_cb; map_callback.set_cb = map_set_response_cb; map_callback.add_cb = map_add_response_cb; map_callback.remove_cb = map_remove_response_cb; // Register response callback data_control_map_register_response_cb(ad->provider_h, &map_callback, NULL); // Get value data_control_map_get(ad->provider_h, “mytestkey”, &req_id); }
  53. 53. Package Manager API
  54. 54. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 54 Package Manager API • Used to retrieve detailed information of the installed packages on the device • Can receive event for monitoring package status – install / uninstall / upgrade
  55. 55. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 55 Getting Specific Package Information char *version = NULL; char *label = NULL; char *type = NULL; package_info_h package_info = NULL; package_manager_get_package_info(“org.tizen.mytestapp", &package_info); package_info_get_version(package_info, &version); package_info_get_label(package_info, &label); package_info_get_type(package_info, &type); dlog_print(DLOG_INFO, TAG, "label t= [%s]n", label); dlog_print(DLOG_INFO, TAG, "icon t= [%s]n", icon); dlog_print(DLOG_INFO, TAG, "version t= [%s]n", version); free(label); free(icon); free(version);
  56. 56. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 56 Listening to Package Events void event_cb(const char *type, const char *package, package_manager_event_type_e event_type, package_manager_event_state_e event_state, int progress, package_manager_error_e error, void *user_data) { if (event_state == PACKAGE_MANAGER_EVENT_STATE_STARTED) { dlog_print(DLOG_INFO, LOG_TAG, "Started"); } else if (event_state == PACKAGE_MANAGER_EVENT_STATE_PROCESSING) { dlog_print(DLOG_INFO, LOG_TAG, "Progress : %d", progress); } else if (event_state == PACKAGE_MANAGER_EVENT_STATE_COMPLETED) { dlog_print(DLOG_INFO, LOG_TAG, "Completed"); } else { dlog_print(DLOG_INFO, LOG_TAG, "Failed"); } } ……… package_manager_h manager; package_manager_create(&manager) package_manager_set_event_status(manager, PACKAGE_MANAGER_STATUS_TYPE_ALL); package_manager_set_event_cb(manager, event_cb, NULL);
  57. 57. Copyright © 2016 Samsung Electronics, Co., Ltd. All rights reserved. 57 References • Tizen 2.4 API reference – https://developer.tizen.org/development/api-references/api-reference- 2.4.0 • Tizen Native Application Programming Guide – https://developer.tizen.org/development/guides/native-application • Tizen Native Application API Tutorials – https://developer.tizen.org/development/tutorials/native-application

×