Merge "Create wrapper function for set_wakeup_callback"
am: d848876ff7

Change-Id: I6ee09acad175923ad9bfd26ab64377626ed92108
diff --git a/libsuspend/autosuspend.c b/libsuspend/autosuspend.c
index 1d6c434..09fc061 100644
--- a/libsuspend/autosuspend.c
+++ b/libsuspend/autosuspend.c
@@ -28,8 +28,7 @@
 static bool autosuspend_enabled;
 static bool autosuspend_inited;
 
-static int autosuspend_init(void)
-{
+static int autosuspend_init(void) {
     if (autosuspend_inited) {
         return 0;
     }
@@ -51,8 +50,7 @@
     return 0;
 }
 
-int autosuspend_enable(void)
-{
+int autosuspend_enable(void) {
     int ret;
 
     ret = autosuspend_init();
@@ -75,8 +73,7 @@
     return 0;
 }
 
-int autosuspend_disable(void)
-{
+int autosuspend_disable(void) {
     int ret;
 
     ret = autosuspend_init();
@@ -98,3 +95,16 @@
     autosuspend_enabled = false;
     return 0;
 }
+
+void autosuspend_set_wakeup_callback(void (*func)(bool success)) {
+    int ret;
+
+    ret = autosuspend_init();
+    if (ret) {
+        return;
+    }
+
+    ALOGV("set_wakeup_callback");
+
+    autosuspend_ops->set_wakeup_callback(func);
+}
diff --git a/libsuspend/autosuspend_ops.h b/libsuspend/autosuspend_ops.h
index 698e25b..2f435d9 100644
--- a/libsuspend/autosuspend_ops.h
+++ b/libsuspend/autosuspend_ops.h
@@ -20,10 +20,9 @@
 struct autosuspend_ops {
     int (*enable)(void);
     int (*disable)(void);
+    void (*set_wakeup_callback)(void (*func)(bool success));
 };
 
-struct autosuspend_ops *autosuspend_autosleep_init(void);
-struct autosuspend_ops *autosuspend_earlysuspend_init(void);
 struct autosuspend_ops *autosuspend_wakeup_count_init(void);
 
 #endif
diff --git a/libsuspend/autosuspend_wakeup_count.c b/libsuspend/autosuspend_wakeup_count.c
index 0a172be..81cb44c 100644
--- a/libsuspend/autosuspend_wakeup_count.c
+++ b/libsuspend/autosuspend_wakeup_count.c
@@ -42,7 +42,7 @@
 static int wakeup_count_fd;
 static pthread_t suspend_thread;
 static sem_t suspend_lockout;
-static const char *sleep_state = "mem";
+static const char* sleep_state = "mem";
 static void (*wakeup_func)(bool success) = NULL;
 static int sleep_time = BASE_SLEEP_TIME;
 
@@ -55,8 +55,7 @@
     sleep_time = MIN(sleep_time * 2, 60000000);
 }
 
-static void *suspend_thread_func(void *arg __attribute__((unused)))
-{
+static void* suspend_thread_func(void* arg __attribute__((unused))) {
     char buf[80];
     char wakeup_count[20];
     int wakeup_count_len;
@@ -117,8 +116,7 @@
     return NULL;
 }
 
-static int autosuspend_wakeup_count_enable(void)
-{
+static int autosuspend_wakeup_count_enable(void) {
     char buf[80];
     int ret;
 
@@ -136,8 +134,7 @@
     return ret;
 }
 
-static int autosuspend_wakeup_count_disable(void)
-{
+static int autosuspend_wakeup_count_disable(void) {
     char buf[80];
     int ret;
 
@@ -155,8 +152,7 @@
     return ret;
 }
 
-void set_wakeup_callback(void (*func)(bool success))
-{
+static void autosuspend_set_wakeup_callback(void (*func)(bool success)) {
     if (wakeup_func != NULL) {
         ALOGE("Duplicate wakeup callback applied, keeping original");
         return;
@@ -165,12 +161,12 @@
 }
 
 struct autosuspend_ops autosuspend_wakeup_count_ops = {
-        .enable = autosuspend_wakeup_count_enable,
-        .disable = autosuspend_wakeup_count_disable,
+    .enable = autosuspend_wakeup_count_enable,
+    .disable = autosuspend_wakeup_count_disable,
+    .set_wakeup_callback = autosuspend_set_wakeup_callback,
 };
 
-struct autosuspend_ops *autosuspend_wakeup_count_init(void)
-{
+struct autosuspend_ops* autosuspend_wakeup_count_init(void) {
     int ret;
     char buf[80];
 
diff --git a/libsuspend/include/suspend/autosuspend.h b/libsuspend/include/suspend/autosuspend.h
index 59188a8..e130ca3 100644
--- a/libsuspend/include/suspend/autosuspend.h
+++ b/libsuspend/include/suspend/autosuspend.h
@@ -51,7 +51,7 @@
  * success is true if the suspend was sucessful and false if the suspend
  * aborted due to some reason.
  */
-void set_wakeup_callback(void (*func)(bool success));
+void autosuspend_set_wakeup_callback(void (*func)(bool success));
 
 __END_DECLS