Loading libsuspend/autosuspend_wakeup_count.c +16 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <unistd.h> #define LOG_TAG "libsuspend" //#define LOG_NDEBUG 0 #include <cutils/log.h> #include "autosuspend_ops.h" Loading @@ -37,6 +38,7 @@ static int wakeup_count_fd; static pthread_t suspend_thread; static sem_t suspend_lockout; static const char *sleep_state = "mem"; static void (*wakeup_func)(void) = NULL; static void *suspend_thread_func(void *arg __attribute__((unused))) { Loading Loading @@ -80,6 +82,11 @@ static void *suspend_thread_func(void *arg __attribute__((unused))) if (ret < 0) { strerror_r(errno, buf, sizeof(buf)); ALOGE("Error writing to %s: %s\n", SYS_POWER_STATE, buf); } else { void (*func)(void) = wakeup_func; if (func != NULL) { (*func)(); } } } Loading Loading @@ -131,6 +138,15 @@ static int autosuspend_wakeup_count_disable(void) return ret; } void set_wakeup_callback(void (*func)(void)) { if (wakeup_func != NULL) { ALOGE("Duplicate wakeup callback applied, keeping original"); return; } wakeup_func = func; } struct autosuspend_ops autosuspend_wakeup_count_ops = { .enable = autosuspend_wakeup_count_enable, .disable = autosuspend_wakeup_count_disable, Loading libsuspend/include/suspend/autosuspend.h +7 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,13 @@ int autosuspend_enable(void); */ int autosuspend_disable(void); /* * set_wakeup_callback * * Set a function to be called each time the device wakes up from suspend. */ void set_wakeup_callback(void (*func)(void)); __END_DECLS #endif Loading
libsuspend/autosuspend_wakeup_count.c +16 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <unistd.h> #define LOG_TAG "libsuspend" //#define LOG_NDEBUG 0 #include <cutils/log.h> #include "autosuspend_ops.h" Loading @@ -37,6 +38,7 @@ static int wakeup_count_fd; static pthread_t suspend_thread; static sem_t suspend_lockout; static const char *sleep_state = "mem"; static void (*wakeup_func)(void) = NULL; static void *suspend_thread_func(void *arg __attribute__((unused))) { Loading Loading @@ -80,6 +82,11 @@ static void *suspend_thread_func(void *arg __attribute__((unused))) if (ret < 0) { strerror_r(errno, buf, sizeof(buf)); ALOGE("Error writing to %s: %s\n", SYS_POWER_STATE, buf); } else { void (*func)(void) = wakeup_func; if (func != NULL) { (*func)(); } } } Loading Loading @@ -131,6 +138,15 @@ static int autosuspend_wakeup_count_disable(void) return ret; } void set_wakeup_callback(void (*func)(void)) { if (wakeup_func != NULL) { ALOGE("Duplicate wakeup callback applied, keeping original"); return; } wakeup_func = func; } struct autosuspend_ops autosuspend_wakeup_count_ops = { .enable = autosuspend_wakeup_count_enable, .disable = autosuspend_wakeup_count_disable, Loading
libsuspend/include/suspend/autosuspend.h +7 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,13 @@ int autosuspend_enable(void); */ int autosuspend_disable(void); /* * set_wakeup_callback * * Set a function to be called each time the device wakes up from suspend. */ void set_wakeup_callback(void (*func)(void)); __END_DECLS #endif