The functions below have become operational on headless profile.
- device_power_request_lock()
- device_power_release_lock()
In addition, the functions below have become working properly as well
on headless profile associated with the functions aboves.
- device_power_get_lock_count()
- device_power_add_lock_count_changed_callback()
- device_power_remove_lock_count_changed_callback()
Note that, device_power_change_state() bypasses power locks. This policy
stands valid on both headed and headless profile. So it is encouraged
that checking POWER_LOCK_CPU count using device_power_get_lock_count()
before calling device_power_change_state() for DEVICE_POWER_STATE_SLEEP.
Change-Id: Iaf4d4cdd0aa02dbd6fabea2096a3a011574f97a3
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
* @return @c 0 on success, otherwise a negative error value
* @retval #DEVICE_ERROR_NONE Successful
* @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @remarks It is strongly encouraged that checking power lock count when it comes
+ * to changing state to DEVICE_POWER_STATE_SLEEP as it bypasses POWER_LOCK_CPU.
* @code
* #include <device/power-internal.h>
* ...
* int main(void)
* {
* int ret = 0;
+ * int count = 0;
+ *
+ * ret = device_power_get_lock_count(POWER_LOCK_CPU , &count);
+ * if (ret != DEVICE_ERROR_NONE) {
+ * ...
+ * return 0;
+ * }
+ *
+ * if (count > 0) {
+ * ...
+ * return 0;
+ * }
+ *
* ret = device_power_change_state(DEVICE_POWER_STATE_SLEEP, 3, power_state_change_cb, NULL);
* if (ret != DEVICE_ERROR_NONE) {
* ...
* }
* ...
* @endcode
+ * @see device_power_get_lock_count()
* @see device_power_change_state_callback()
* @see device_power_state_e
*/
* @privlevel public
* @privilege %http://tizen.org/privilege/display
* @remarks If the process dies after success request lock, then every lock will be removed.
- * The display state feature(http://tizen.org/feature/display.state) also should be checked.
+ * If display feature(http://tizen.org/feature/display) is false, then only the type POWER_LOCK_CPU is effective,
+ * and the other type returns DEVICE_ERROR_NOT_SUPPORTED. And even thoguh the display feature is false, it requires
+ * display privilege(http://tizen.org/privilege/display).
* @param[in] type The power type to request lock
* @param[in] timeout_ms The positive number in milliseconds or @c 0 for permanent lock \n
* So you must release the permanent lock of power state with #device_power_release_lock() if @a timeout_ms is zero
* @since_tizen 2.3
* @privlevel public
* @privilege %http://tizen.org/privilege/display
- * @remarks The display state feature(http://tizen.org/feature/display.state) also should be checked.
+ * @remarks If display feature(http://tizen.org/feature/display) is false, then only the type POWER_LOCK_CPU is effective,
+ * and the other type returns DEVICE_ERROR_NOT_SUPPORTED. And even thoguh the display feature is false, it requires
+ * display privilege(http://tizen.org/privilege/display).
* @param[in] type The power type to release lock
* @return @c 0 on success, otherwise a negative error value
* @retval #DEVICE_ERROR_NONE Successful
if (!is_feature_display_supported() || !is_feature_display_state_supported()) {
if ((type == POWER_LOCK_DISPLAY) || (type == POWER_LOCK_DISPLAY_DIM)) {
return DEVICE_ERROR_NOT_SUPPORTED;
- } else if (type == POWER_LOCK_CPU) {
- /* in case of headless, request for cpu lock is handled
- * in power module of deviced, not in display module */
-
- /* In current policy, headless doesn't support cpulock. Disable it.
- ret = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
- DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
- "LockCpu", g_variant_new("(i)", timeout_ms), NULL);
- return errno_to_device_error(ret);
- */
- return DEVICE_ERROR_NONE;
}
}
if (!is_feature_display_supported() || !is_feature_display_state_supported()) {
if ((type == POWER_LOCK_DISPLAY) || (type == POWER_LOCK_DISPLAY_DIM)) {
return DEVICE_ERROR_NOT_SUPPORTED;
- } else if (type == POWER_LOCK_CPU) {
- /* in case of headless, request for cpu unlock is handled
- * in power module of deviced, not in display module */
-
- /* In current policy, headless doesn't support cpulock. Disable it.
- ret_val = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
- DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
- "UnlockCpu", NULL, NULL);
- return errno_to_device_error(ret_val);
- */
- return DEVICE_ERROR_NONE;
}
}