* 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>
+ * ...
+ * static void power_state_change_cb(device_power_state_e state, int retval, void *user_data)
+ * {
+ * ...
+ * }
+ * ...
+ * 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
*/
int device_power_change_state(device_power_state_e state, int timeout_sec, device_power_change_state_callback cb, void *user_data);
_I("power_lock_e = %d", type);
- 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 (check_async_call_rate(&num_calls) < 0) {
//LCOV_EXCL_START System Error
_E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
_I("power_lock_e = %d", type);
- 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;
- }
- }
-
if (type == POWER_LOCK_CPU && power_locked_CPU) {
ret_val = unlock_state(DISPLAY_STATE_SCREEN_OFF, PM_SLEEP_MARGIN);
if (ret_val == 0) {