b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 1 | #include <stddef.h> |
| 2 | #include "ql_sleep_wakelock.h" |
| 3 | #include "mbtk_sleep.h" |
| 4 | #include "mbtk_log.h" |
| 5 | |
| 6 | /* |
| 7 | * create wakelock, return the file description of the wakelock |
| 8 | */ |
| 9 | int ql_slp_wakelock_create(const char *name, size_t len) |
| 10 | { |
| 11 | int ret; |
| 12 | |
| 13 | ret = mbtk_wakelock_create(name, len); |
| 14 | if (ret == -1) |
| 15 | { |
| 16 | LOGE("mbtk_wakelock_create is error"); |
| 17 | } |
| 18 | |
| 19 | return ret; |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | * lock the wakelock by the file description of the wakelock |
| 24 | */ |
| 25 | int ql_slp_wakelock_lock(int fd) |
| 26 | { |
| 27 | int ret; |
| 28 | |
| 29 | ret = mbtk_wakelock_lock(fd); |
| 30 | if (ret == -1) |
| 31 | { |
| 32 | LOGE("ql_slp_wakelock_lock is error"); |
| 33 | } |
| 34 | |
| 35 | return ret; |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | * unlock the wakelock by the file description of the wakelock |
| 40 | */ |
| 41 | int ql_slp_wakelock_unlock(int fd) |
| 42 | { |
| 43 | int ret; |
| 44 | |
| 45 | ret = mbtk_wakelock_unlock(fd); |
| 46 | if (ret == -1) |
| 47 | { |
| 48 | LOGE("ql_slp_wakelock_unlock is error"); |
| 49 | } |
| 50 | |
| 51 | return ret; |
| 52 | } |
| 53 | |
| 54 | /* |
| 55 | * destroy the wakelock by the file description of the wakelock |
| 56 | */ |
| 57 | int ql_slp_wakelock_destroy(int fd) |
| 58 | { |
| 59 | int ret; |
| 60 | |
| 61 | ret = mbtk_wakelock_destroy(fd); |
| 62 | if (ret == -1) |
| 63 | { |
| 64 | LOGE("ql_slp_wakelock_destroy is error"); |
| 65 | } |
| 66 | |
| 67 | return ret; |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Enable/Disable autosleep function |
| 72 | */ |
| 73 | int ql_autosleep_enable(char enable) |
| 74 | { |
| 75 | int ret; |
| 76 | |
| 77 | ret = mbtk_autosuspend_enable(enable); |
| 78 | if (ret == -1) |
| 79 | { |
| 80 | LOGE("ql_autosleep_enable is error"); |
| 81 | } |
| 82 | |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | |