语言

Menu
Sites
Language
Auto-restart and on-boot for service applications on Wearable

I want to have a service (without UI) that starts after boot and restarts if it was killed. The service has background-category specified.

 

According to https://developer.tizen.org/development/guides/native-application/application-management/applications/service-application the 'on-boot' and 'auto-restart' properties are not available for Wearable. 

 

In the forum it was suggested  to use a workaround with the Alarm API. See https://developer.tizen.org/forums/native-application-development/wearable-start-service-application-restart and https://developer.tizen.org/forums/native-application-development/on-boottrue-not-work-tizen-2.3.2 However, the Alarm API does not allow to trigger service applications, just UI applications. This is documented here: https://developer.tizen.org/development/api-references/native-application?redirect=/dev-guide/3.0/org.tizen.native.mobile.apireference/group__CAPI__ALARM__MODULE.html (search for ALARM_ERROR_NOT_PERMITTED_APP

 

So far as I can see, this makes an always-on pure service application impossible. It always requires a companion UI application. Does anybody have an idea to workaround the missing 'on-boot' and 'auto-restart' behaviour for pure service applications?

编辑者为: Condor 21 2月, 2018

响应

7 回复
Yasin Ali

Hi,

As far as I know this is not currently possible  for Wearable.

Sam Richardson

Hi, I've actually tried almost every work around for this problem which I could concieve of, but the guys at Tizen have really blocked this possibility. 

The closest I got was packaging a native service app with a native watch application. The service launched nicely with the watchface upon installation to a Samsung Gear S3 device running Tizen 3.0.0.2, but crashed as soon as I relaunched the watchface or restarted the watch.

Guess we'll just have to wait patiently...

GEUNSOO KIM

have you ever tried 'alarm_schedule_after_delay()'?

the description of the API is little bit different with other APIs.

it sounds like it is possible if you give 'background category' to your service app.

 

Sam Richardson

Thank you for your reply. I was not aware of this API, which could indeed help. 

Sam Richardson

So I've tried using the alarm API but without luck. Could be my limited understanding of how app controls work, but I've tried various incarnations with the same error:  

CAPI_APPFW_APPLICATION_ALARM       alarm.c: convert_error_code_to_alarm(95) > [alarm_schedule_once_at_date] NOT_PERMITTED_APP(0xfef00...)

I've tried various incarnations:
- making a service-app where the alarm is initialized and triggers my app

- packaging a uiApp where the alarm is initialized together with my app (using same prefix as per documentation)

 

I've used the sampled code I found on the Tizen forums:

 

bool init_alarm()
{
   int ret;
   int alarm_id;

   struct tm date;

   app_control_h app_control = NULL;
   ret = app_control_create(&app_control);
   ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_MAIN);
   ret = app_control_set_app_id (app_control, APP_NAME);

   ret = alarm_get_current_time(&date);

   date.tm_sec+=4;
   ret = alarm_schedule_once_at_date(app_control, &date, &alarm_id);

   return true;

}

where init_alarm is called in the app_create() function. I've also added the alarm.set and alarm.get privilidges to the application, but not luck. Anything I'm missing? I find that the Tizen wearable API documentation sometimes glosses over important details so maybe I"m missing one of those..

Sam Richardson

So I did some more searching and found that according to the alarm api:

"If the application is uninstalled after setting an alarm, the alarm is cancelled automatically. If the operation of app_control is not specified, APP_CONTROL_OPERATION_DEFAULT is used for the launch request. If the operation of app_control is APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application. If the appid of app_control is not specified, this api is not allowed. In other words, the explicit app_control is only allowed. The app_control only supports UI application with this api. If app_control is not UI application, ALARM_ERROR_NOT_PERMITTED_APP returned. When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs." (source: https://developer.tizen.org/dev-guide/tizen-iot-headed/group__CAPI__ALARM__MODULE.html#gga805fb50b1be73ecdf9c8d4b3e957dadba685989d047f41df4bfbd02e565b25902)

So it seems that there are very tight restrictions on service apps in Tizen.

Sam Richardson

I have found  a work around using an intermediate native UI app. I create an alarm service app that launches the native UI app at a specific time. The native UI app in turn is packaged together with the main service app that I'm interested in running. The native UI app also automatically launches the service app once it starts.

If anyone has any alternatives I would love to hear it, but at the moment this has been the only way I could get a service app launched using an alarm.