Tizen Native API
5.5
|
The Job scheduler API contains the job scheduler library.
#include <job_scheduler.h>
It provides functions to define job-execution conditions. It improves the applications' performance and system health.
Some job trigger events and some functions are related with the following features:
It is recommended to use features in your application for reliability. You can check if the device supports the related features for this API by using System Information, and control your application's actions accordingly. To ensure your application is only running on devices with specific features, please define the features in your manifest file using the manifest editor in the SDK. More details on using features in your application can be found in Feature Element.
Functions | |
int | job_info_create (job_info_h *job_info) |
Creates the job info handle. | |
int | job_info_destroy (job_info_h job_info) |
Destroys the job info handle and releases all its resources. | |
int | job_info_set_periodic (job_info_h job_info, unsigned int interval) |
Sets the periodic interval of the job. | |
int | job_info_set_persistent (job_info_h job_info, bool persistent) |
Sets the job to be automatically scheduled after the device reboots. | |
int | job_info_set_once (job_info_h job_info, bool once) |
Sets the job not to be repeated. | |
int | job_info_set_requirement_timeout (job_info_h job_info, unsigned int timeout) |
Sets the timeout interval of the requirements. | |
int | job_info_set_requires_battery_not_low (job_info_h job_info, bool battery_not_low) |
Sets that the battery level must not be low to run the job. | |
int | job_info_set_requires_charging (job_info_h job_info, bool charging) |
Sets that the battery must be charging to run the job. | |
int | job_info_set_requires_wifi_connection (job_info_h job_info, bool wifi_connection) |
Sets that the WiFi must be connected to run the job. | |
int | job_info_add_trigger_event (job_info_h job_info, job_trigger_event_e event) |
Adds the trigger event to the job info handle. | |
int | job_info_remove_trigger_event (job_info_h job_info, job_trigger_event_e event) |
Removes the trigger event from the job info handle. | |
int | job_info_get_job_id (job_info_h job_info, char **job_id) |
Gets the ID of the job. | |
int | job_info_clone (job_info_h job_info, job_info_h *clone) |
Clones the given job_info handle. | |
int | job_scheduler_init (void) |
Initializes the job scheduler. | |
int | job_scheduler_finish (void) |
Finalizes the job scheduler. | |
int | job_scheduler_schedule (job_info_h job_info, const char *job_id) |
Schedules the job. | |
int | job_scheduler_cancel (const char *job_id) |
Cancels the scheduled job. | |
int | job_scheduler_cancel_all (void) |
Cancels all scheduled jobs. | |
int | job_scheduler_notify_job_finished (const char *job_id) |
Notifies that the job is finished. | |
int | job_scheduler_foreach_job (job_scheduler_foreach_job_cb callback, void *user_data) |
Retrieves all scheduled jobs. | |
int | job_scheduler_service_add (const char *job_id, job_service_callback_s *callback, void *user_data, job_service_h *job_service) |
Adds job service handler for receiving the information of the scheduled job. | |
int | job_scheduler_service_remove (job_service_h job_service) |
Removes registered job service handler. | |
Typedefs | |
typedef struct job_info_s * | job_info_h |
The job info handle. | |
typedef struct job_service_s * | job_service_h |
The job service handle. | |
typedef void(* | job_service_start_cb )(job_info_h job_info, void *user_data) |
Called when the job starts. | |
typedef void(* | job_service_stop_cb )(job_info_h job_info, void *user_data) |
Called when the job stops. | |
typedef bool(* | job_scheduler_foreach_job_cb )(job_info_h job_info, void *user_data) |
Called to retrieve the job information. |
typedef struct job_info_s* job_info_h |
The job info handle.
typedef bool(* job_scheduler_foreach_job_cb)(job_info_h job_info, void *user_data) |
Called to retrieve the job information.
[in] | job_info | The job_info handle |
[in] | user_data | The user data passed from the foreach function |
true
continue with the next iteration of the loop, otherwise false
to break out of the loop typedef struct job_service_s* job_service_h |
The job service handle.
typedef void(* job_service_start_cb)(job_info_h job_info, void *user_data) |
Called when the job starts.
[in] | job_info | The job info handle |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* job_service_stop_cb)(job_info_h job_info, void *user_data) |
Called when the job stops.
[in] | job_info | The job info handle |
[in] | user_data | The user data passed from the callback registration function |
enum job_error_e |
Enumeration for job error.
enum job_trigger_event_e |
Enumeration for the job trigger events.
JOB_TRIGGER_EVENT_BATTERY_LEVEL_EMPTY |
The battery level status: Empty |
JOB_TRIGGER_EVENT_BATTERY_LEVEL_CRITICAL |
The battery level status: Critical |
JOB_TRIGGER_EVENT_BATTERY_LEVEL_LOW |
The battery level status: Low |
JOB_TRIGGER_EVENT_BATTERY_LEVEL_HIGH |
The battery level status: High |
JOB_TRIGGER_EVENT_CHARGER_STATE_CONNECTED |
The charger state: Connected |
JOB_TRIGGER_EVENT_CHARGER_STATE_DISCONNECTED |
The charger state: Disconnected |
JOB_TRIGGER_EVENT_DISPLAY_STATE_ON |
The display state: On |
JOB_TRIGGER_EVENT_DISPLAY_STATE_OFF |
The display state: Off |
JOB_TRIGGER_EVENT_DISPLAY_STATE_DIM |
The display state: Dim |
JOB_TRIGGER_EVENT_EARJACK_STATE_CONNECTED |
The earjack state: Connected |
JOB_TRIGGER_EVENT_EARJACK_STATE_DISCONNECTED |
The earjack state: Disconnected |
JOB_TRIGGER_EVENT_GPS_STATE_DISABLED |
The GPS state: Disabled |
JOB_TRIGGER_EVENT_GPS_STATE_SEARCHING |
The GPS state: Searching |
JOB_TRIGGER_EVENT_GPS_STATE_CONNECTED |
The GPS state: Connected |
JOB_TRIGGER_EVENT_POWERSAVE_MODE_ENABLED |
The Power-saving mode: Enabled |
JOB_TRIGGER_EVENT_POWERSAVE_MODE_DISABLED |
The Power-saving mode: Disabled |
JOB_TRIGGER_EVENT_USB_STATE_CONNECTED |
The USB state: Connected |
JOB_TRIGGER_EVENT_USB_STATE_DISCONNECTED |
The USB state: Disconnected |
JOB_TRIGGER_EVENT_WIFI_STATE_DISABLED |
The WiFi state: Disabled |
JOB_TRIGGER_EVENT_WIFI_STATE_DISCONNECTED |
The WiFi state: Disconnected |
JOB_TRIGGER_EVENT_WIFI_STATE_CONNECTED |
The WiFi state: Connected |
int job_info_add_trigger_event | ( | job_info_h | job_info, |
job_trigger_event_e | event | ||
) |
Adds the trigger event to the job info handle.
[in] | job_info | The job info handle |
[in] | event | The job trigger event |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_NOT_SUPPORTED | Not supported |
JOB_ERROR_ALREADY_EXIST | Already exist |
JOB_ERROR_PERMISSION_DENIED | Permission denied |
int job_info_clone | ( | job_info_h | job_info, |
job_info_h * | clone | ||
) |
Clones the given job_info handle.
[in] | job_info | The job info handle |
[out] | clone | If successful, a newly created job info handle will be returned |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_OUT_OF_MEMORY | Out of memory |
int job_info_create | ( | job_info_h * | job_info | ) |
Creates the job info handle.
[out] | job_info | The job info handle to be newly created on success |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_OUT_OF_MEMORY | Out of memory |
int job_info_destroy | ( | job_info_h | job_info | ) |
Destroys the job info handle and releases all its resources.
[in] | job_info | The job info handle |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
int job_info_get_job_id | ( | job_info_h | job_info, |
char ** | job_id | ||
) |
Gets the ID of the job.
[in] | job_info | The job info handle |
[out] | job_id | The ID of the job |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_OUT_OF_MEMORY | Out of memory |
int job_info_remove_trigger_event | ( | job_info_h | job_info, |
job_trigger_event_e | event | ||
) |
Removes the trigger event from the job info handle.
[in] | job_info | The job info handle |
[in] | event | The job trigger event |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
int job_info_set_once | ( | job_info_h | job_info, |
bool | once | ||
) |
Sets the job not to be repeated.
[in] | job_info | The job info handle |
[in] | once | true , if the job does not need to be repeated |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
int job_info_set_periodic | ( | job_info_h | job_info, |
unsigned int | interval | ||
) |
Sets the periodic interval of the job.
[in] | job_info | The job info handle |
[in] | interval | The periodic interval (in minutes) |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
int job_info_set_persistent | ( | job_info_h | job_info, |
bool | persistent | ||
) |
Sets the job to be automatically scheduled after the device reboots.
[in] | job_info | The job info handle |
[in] | persistent | true , if the job needs to be automatically scheduled |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
int job_info_set_requirement_timeout | ( | job_info_h | job_info, |
unsigned int | timeout | ||
) |
Sets the timeout interval of the requirements.
[in] | job_info | The job info handle |
[in] | timeout | The timeout interval (ms) |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
int job_info_set_requires_battery_not_low | ( | job_info_h | job_info, |
bool | battery_not_low | ||
) |
Sets that the battery level must not be low to run the job.
[in] | job_info | The job info handle |
[in] | battery_not_low | true , the battery level must not be low. |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_NOT_SUPPORTED | Not supported |
int job_info_set_requires_charging | ( | job_info_h | job_info, |
bool | charging | ||
) |
Sets that the battery must be charging to run the job.
[in] | job_info | The job info handle |
[in] | charging | true , the battery must be charging. |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_NOT_SUPPORTED | Not supported |
int job_info_set_requires_wifi_connection | ( | job_info_h | job_info, |
bool | wifi_connection | ||
) |
Sets that the WiFi must be connected to run the job.
[in] | job_info | The job info handle |
[in] | wifi_connection | true , the WiFi must be connected. |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_NOT_SUPPORTED | Not supported |
JOB_ERROR_PERMISSION_DENIED | Permission denied |
int job_scheduler_cancel | ( | const char * | job_id | ) |
Cancels the scheduled job.
[in] | job_id | The ID of the scheduled job |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_NO_SUCH_JOB | No such job |
int job_scheduler_cancel_all | ( | void | ) |
Cancels all scheduled jobs.
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_IO_ERROR | IO error |
int job_scheduler_finish | ( | void | ) |
Finalizes the job scheduler.
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
int job_scheduler_foreach_job | ( | job_scheduler_foreach_job_cb | callback, |
void * | user_data | ||
) |
Retrieves all scheduled jobs.
[in] | callback | The iteration callback function |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_NO_SUCH_JOB | No scheduled jobs |
int job_scheduler_init | ( | void | ) |
Initializes the job scheduler.
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_OUT_OF_MEMORY | Out of memory |
int job_scheduler_notify_job_finished | ( | const char * | job_id | ) |
Notifies that the job is finished.
[in] | job_id | The ID of the scheduled job |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_NO_SUCH_JOB | No such job |
JOB_ERROR_IO_ERROR | IO error |
int job_scheduler_schedule | ( | job_info_h | job_info, |
const char * | job_id | ||
) |
Schedules the job.
[in] | job_info | The job info handle |
[in] | job_id | The ID of the job |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_IO_ERROR | IO error |
JOB_ERROR_ALREADY_EXIST | Already exist |
JOB_ERROR_OUT_OF_MEMORY | Out of memory |
JOB_ERROR_PERMISSION_DENIED | Permission denied |
int job_scheduler_service_add | ( | const char * | job_id, |
job_service_callback_s * | callback, | ||
void * | user_data, | ||
job_service_h * | job_service | ||
) |
Adds job service handler for receiving the information of the scheduled job.
[in] | job_id | The ID of the job |
[in] | callback | The set of callback functions to handle jobs |
[in] | user_data | The user data to be passed to the callback function |
[out] | job_service | The job service handle |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_NOT_INITIALIZED | Not initialized |
JOB_ERROR_OUT_OF_MEMORY | Out of memory |
int job_scheduler_service_remove | ( | job_service_h | job_service | ) |
Removes registered job service handler.
[in] | job_service | The job service handle |
0
on success, otherwise a negative error value JOB_ERROR_NONE | Successful |
JOB_ERROR_INVALID_PARAMETER | Invalid parameter |
JOB_ERROR_NOT_INITIALIZED | Not initialized |