Languages

Menu
Sites
Language
Native alarm API behavior after battery empties

Hi, 

I was wondering if anyone has had similar experiences with the alarm API. I currently have an app that is triggered by another alarm service app at specific times of the day (everyday) using the alarm_schedule_with_recurrence_week_flag function. What I've found is that if I turn off the watch before the battery empties and keep it charged properly before turning it on again, the alarm works throughout the week just fine and launches the app. 

However, if at any time during the day the battery dies and I recharge the following day and turn on the watch before the scheduled alarm time, the app never starts. So it seems that after the battery is empty, the registered alarm states are lost.

Any feedback/comments on this behavior would be much appreciated.

Thanks.

Responses

8 Replies
Armaan-Ul- Islam

If alarms are deleted from system in case of emergency shutdown every-time, then obviously that's not an acceptable behavior. You may report a bug on Tizen bug Tracker. Here’s a guideline on how to report bugs. Please share your progress and the 'Reported bug' link here on this post to help the developers keep track.

Sam Richardson

Thanks, will do that.

Sam Richardson

Bug is registered here.

Armaan-Ul- Islam

I've tested setting alarm using alarm_schedule_with_recurrence_week_flag() function and retrieving them. But In my Gear S3 running on Tizen 3.0.0.2 , Force/auto Shutdown due to zero battery didn't removed the alarms, I can still retrieve the alarms after starting the device.

 

I'm sharing my Code Snippet here:

void
set_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
    set_alarm();
    dlog_print(DLOG_INFO, TAG, "SET Button clicked\n");

}

void
get_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
    get_alarm();
	dlog_print(DLOG_INFO, TAG, "GET Button clicked\n");
}
void
set_alarm(){

    int ret;
    int hr[2]={14,14};
    int mn[12]={0,30};

    app_control_h app_control_tmp;
    ret = app_control_create(&app_control_tmp);
    ret = app_control_set_operation(app_control_tmp, APP_CONTROL_OPERATION_DEFAULT);
    ret = app_control_set_app_id(app_control_tmp, "org.tizen.heremaps-uc");
    
    int alarm_id;
    
    struct tm date;
    ret = alarm_get_current_time(&date);

    for(int i =0; i < 2; i++){
        date.tm_hour = hr[i];
        date.tm_min = mn[i];
        date.tm_sec = 0;
        time_t time_current = mktime(&date);
        dlog_print(DLOG_INFO, "123TAG", "tentative time: %s ", ctime(&time_current));
        ret = alarm_schedule_with_recurrence_week_flag(app_control_tmp, &date, ALARM_WEEK_FLAG_MONDAY | ALARM_WEEK_FLAG_TUESDAY | ALARM_WEEK_FLAG_WEDNESDAY | ALARM_WEEK_FLAG_THURSDAY | ALARM_WEEK_FLAG_FRIDAY | ALARM_WEEK_FLAG_SATURDAY | ALARM_WEEK_FLAG_SUNDAY, &alarm_id);
        
        if (ret == ALARM_ERROR_NONE)
        	 dlog_print(DLOG_ERROR, "123TAG", "No Error");
        
        else if (ret == ALARM_ERROR_INVALID_PARAMETER)
        	 dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_INVALID_PARAMETER");
        else if (ret == ALARM_ERROR_INVALID_TIME)
        	dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_INVALID_TIME");
        else if (ret == ALARM_ERROR_INVALID_DATE)
        	dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_INVALID_DATE");
        else if (ret == ALARM_ERROR_CONNECTION_FAIL)
        	dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_CONNECTION_FAIL");
        else if (ret == ALARM_ERROR_NOT_PERMITTED_APP)
        	dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_NOT_PERMITTED_APP");
        else if (ret ==ALARM_ERROR_OUT_OF_MEMORY)
        	dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_OUT_OF_MEMORY");
        else if (ret ==ALARM_ERROR_PERMISSION_DENIED )
        	 dlog_print(DLOG_ERROR, "123TAG", "ALARM_ERROR_PERMISSION_DENIED ");
    }
}
void get_alarm(){

    int ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, NULL);
	if (ret != ALARM_ERROR_NONE)
		dlog_print(DLOG_ERROR, TAG, "Listing Error: %d ", ret);
	else
		dlog_print(DLOG_ERROR, TAG, "No Error while listing: %d ", ret);
}

static bool
on_foreach_registered_alarm(int alarm_id, void *user_data)
{
    dlog_print(DLOG_INFO, TAG, "Callback called");
    int flag;
    int ret = 0;
    struct tm date;
    time_t time_current;

    ret = alarm_get_scheduled_date(alarm_id, &date);
    if (ret != ALARM_ERROR_NONE)
        dlog_print(DLOG_ERROR, TAG, "Get time Error: %d ", ret);

    time_current = mktime(&date);
    dlog_print(DLOG_INFO, TAG, "Registered alarm: %d on date: %s ", alarm_id, ctime(&time_current));

    ret = alarm_get_scheduled_recurrence_week_flag(alarm_id, &flag);
    if (ret == 0) {
        if (flag & ALARM_WEEK_FLAG_SUNDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on SUNDAY \n");
        if (flag & ALARM_WEEK_FLAG_MONDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on MONDAY \n");
        if (flag & ALARM_WEEK_FLAG_TUESDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on TUESDAY \n");
        if (flag & ALARM_WEEK_FLAG_WEDNESDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on WEDNESDAY \n");
        if (flag & ALARM_WEEK_FLAG_THURSDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on THURSDAY \n");
        if (flag & ALARM_WEEK_FLAG_FRIDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on FRIDAY \n");
        if (flag & ALARM_WEEK_FLAG_SATURDAY)
            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on SATURDAY \n");
    }
/*
    // Cancel scheduled alarms
    ret = alarm_cancel(alarm_id);
    if (ret != ALARM_ERROR_NONE)
        dlog_print(DLOG_ERROR, TAG, "Cancel Error: %d ", ret);
*/
    return true;
}

 

Did anything else get reset after zero battery shutdown on your device ? like 'settings restored to default', 'revert to default watchface', 'loss of personal data', etc? You might also try testing 'your code/this code' on a different device If possible.

Sam Richardson

Hi Armaan,

Thanks for the help and the supporting code. I'll give this a try and see what happens.

Kind regards,
Rich

Sam Richardson

Just to add, I didn't notice anything else like the watchface or other personalizations getting reset. Am also running Tizen 3.0.0.2 on the Gear S3. 

Armaan-Ul- Islam

Hello R Keanan,

Any Update on this?

Sam Richardson

Hi Armaan,

I've done some preliminary testing and actually my code was not that different from yours, but I had implemented in a service app. I've now implemented the alarm in a UI app and it seems to reliably trigger.

Thanks for the help.

Rich