Tizen 3.0 native service - Fail to add Ecore timer

I have a Tizen 3.0 hybrid app (web + native service), in which the service is expected to turn on the screen and bring the packaged web app to the foreground periodically (every 60 seconds, for example).

In order to schedule this event, the native service calls ecore_timer_add() (from within the service's _on_create_cb) as follows:

app->myTimer = ecore_timer_add(60, ShowApp, NULL);

The ShowApp callback is supposed to bring the packaged web app to the foreground, as follows:

static Eina_Bool ShowApp(void *data) {
    KeepScreenOn(2000); // function which requests the display lock for 2 seconds
    EnsureAppRunning(); // function which resumes the app (if it is already running) or starts the app (if it is not running)
   return ECORE_CALLBACK_RENEW;  // Repeat timer
However, when ecore_timer_add is called, the following is logged (in the Log view):

"ecore<2646> lib/ecore/ecore_timer.c:116 _ecore_timer_add() You are calling _ecore_timer_add from outside of the main loop threads. Program cannot run normally"

As a result, the ShowApp function is never called.

I even tried wrapping the ecore_timer_add call inside a function called by ecore_main_loop_thread_safe_call_async, but I got the same error as above.

How can I ensure that ecore_timer_add successfully adds the timer in this service (and calls ShowApp when expected)?


PS. As the end goal is simply to repeatedly turn on the screen and bring the web app to the foreground, I also tried using an Alarm API to accomplish this, but that did not work either:

    app_control_h app_control = NULL;
    ret = app_control_create(&app_control);
    et = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
    ret = app_control_set_app_id(app_control, CLIENT_APP_ID);
    ret = alarm_schedule_after_delay(app_control, 10, 10, &alarm_id);   <== Did not wake up the device/screen to show the app (after 10 seconds)


1 Replies
K Johnson

Please try below code in your app. It works for me in Tizen Wearable version 3.0.

bool service_app_create(void *data)
    // Todo: add your code here.
	ecore_timer_add(5, printLog, NULL);
	return true;

write callback function as below:

printLog(void *data EINA_UNUSED)
    dlog_print(DLOG_INFO, "TimerTest", "Test Log");
	return EINA_TRUE;

Please check attached screenshot below. It's giving me log within every 5 seconds interval.