Add exceptions and descriptions 29/158329/10
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 31 Oct 2017 05:39:16 +0000 (14:39 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 1 Nov 2017 22:20:22 +0000 (07:20 +0900)
- The minimum value of the periodic interval is 10 minutes.
- The maximum value of the requirement timeout is 10000 ms.
- If the developer sets the job to a one-time and persistent,
calling job_scheduler_schedule() will be failed.

Change-Id: I060f33732a521c94d569294cf9c9b2e4d1bfce2e
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/job_info.h
src/job_info.c

index cf4a6d2f1ee511282205d14e2528d5218eac0586..84e0eee9e9a0871d12fad6e957bd86b50aa19069 100644 (file)
@@ -111,30 +111,40 @@ int job_info_set_periodic(job_info_h job_info, unsigned int interval);
 /**
  * @brief Sets the job to be automatically scheduled after the device reboots.
  * @since_tizen 4.0
+ * @remarks If it's a one-time job, setting it to a persistent job returns
+ *          a negative error value on scheduling by using job_scheduler_schedule().
  * @param[in]   job_info        The job info handle
  * @param[in]   persistent      @c true, if the job needs to be automatically scheduled
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #JOB_ERROR_NONE              Successful
  * @retval #JOB_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see    job_info_set_once()
+ * @see    job_scheduler_schedule()
  */
 int job_info_set_persistent(job_info_h job_info, bool persistent);
 
 /**
  * @brief Sets the job not to be repeated.
  * @since_tizen 4.0
+ * @remarks If it's a persistent job, setting it to a one-time job returns
+ *          a negative error value on scheduling by using job_scheduler_schedule().
  * @param[in]   job_info        The job info handle
  * @param[in]   once            @c true, if the job does not need to be repeated
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #JOB_ERROR_NONE              Successful
  * @retval #JOB_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see    job_info_set_persistent()
+ * @see    job_scheduler_schedule()
  */
 int job_info_set_once(job_info_h job_info, bool once);
 
 /**
  * @brief Sets the timeout interval of the requirements.
  * @since_tizen 4.0
+ * @remarks If the requirements are not satisfied within the timeout value,
+ *          the job does not start.
  * @param[in]   job_info        The job info handle
  * @param[in]   timeout         The timeout interval (ms)
  * @return @c 0 on success,
index 12e9f94dda32744d0c94a8194c22cab9237d972f..534e39cafbaa65d5c022bc8f2a15ecc7ee589a7e 100644 (file)
@@ -37,6 +37,9 @@
 
 #define ARRAY_SIZE(x) ((sizeof(x)) / (sizeof(x[0])))
 
+#define MAX_REQ_TIMEOUT 10000
+#define MIN_PERIODIC_INTERVAL 10
+
 struct job_info_s {
        char *job_id;
        unsigned int interval; /* Periodic */
@@ -133,6 +136,9 @@ API int job_info_set_periodic(job_info_h job_info, unsigned int interval)
                                __LINE__, NULL);
        }
 
+       if (interval < MIN_PERIODIC_INTERVAL)
+               interval = MIN_PERIODIC_INTERVAL;
+
        job_info->interval = interval;
 
        return JOB_ERROR_NONE;
@@ -212,6 +218,9 @@ API int job_info_set_requirement_timeout(job_info_h job_info,
                                __LINE__, NULL);
        }
 
+       if (timeout > MAX_REQ_TIMEOUT)
+               timeout = MAX_REQ_TIMEOUT;
+
        job_info->timeout = timeout;
 
        return JOB_ERROR_NONE;