summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Paik2017-12-15 15:26:28 -0600
committerSteve Paik2017-12-18 12:22:04 -0600
commit2d44190539b9313c9c9882cdee7f5f012ad1935b (patch)
tree1a1de37b56035892514c16a0806ba62fe8e01aeb /libsuspend
parentfea16e1dea1f93a0daac1bb81ad26ecd7fc57513 (diff)
downloadplatform-system-core-2d44190539b9313c9c9882cdee7f5f012ad1935b.tar.gz
platform-system-core-2d44190539b9313c9c9882cdee7f5f012ad1935b.tar.xz
platform-system-core-2d44190539b9313c9c9882cdee7f5f012ad1935b.zip
Create wrapper function for set_wakeup_callback
Bug: 70669809 Test: Compiles Change-Id: I55f8b9995c2d872504b586addb07a18206da7fbe
Diffstat (limited to 'libsuspend')
-rw-r--r--libsuspend/autosuspend.c22
-rw-r--r--libsuspend/autosuspend_ops.h3
-rw-r--r--libsuspend/autosuspend_wakeup_count.c22
-rw-r--r--libsuspend/include/suspend/autosuspend.h2
4 files changed, 27 insertions, 22 deletions
diff --git a/libsuspend/autosuspend.c b/libsuspend/autosuspend.c
index 1d6c4349e..09fc0617e 100644
--- a/libsuspend/autosuspend.c
+++ b/libsuspend/autosuspend.c
@@ -28,8 +28,7 @@ static struct autosuspend_ops *autosuspend_ops;
28static bool autosuspend_enabled; 28static bool autosuspend_enabled;
29static bool autosuspend_inited; 29static bool autosuspend_inited;
30 30
31static int autosuspend_init(void) 31static int autosuspend_init(void) {
32{
33 if (autosuspend_inited) { 32 if (autosuspend_inited) {
34 return 0; 33 return 0;
35 } 34 }
@@ -51,8 +50,7 @@ out:
51 return 0; 50 return 0;
52} 51}
53 52
54int autosuspend_enable(void) 53int autosuspend_enable(void) {
55{
56 int ret; 54 int ret;
57 55
58 ret = autosuspend_init(); 56 ret = autosuspend_init();
@@ -75,8 +73,7 @@ int autosuspend_enable(void)
75 return 0; 73 return 0;
76} 74}
77 75
78int autosuspend_disable(void) 76int autosuspend_disable(void) {
79{
80 int ret; 77 int ret;
81 78
82 ret = autosuspend_init(); 79 ret = autosuspend_init();
@@ -98,3 +95,16 @@ int autosuspend_disable(void)
98 autosuspend_enabled = false; 95 autosuspend_enabled = false;
99 return 0; 96 return 0;
100} 97}
98
99void autosuspend_set_wakeup_callback(void (*func)(bool success)) {
100 int ret;
101
102 ret = autosuspend_init();
103 if (ret) {
104 return;
105 }
106
107 ALOGV("set_wakeup_callback");
108
109 autosuspend_ops->set_wakeup_callback(func);
110}
diff --git a/libsuspend/autosuspend_ops.h b/libsuspend/autosuspend_ops.h
index 698e25be8..2f435d97f 100644
--- a/libsuspend/autosuspend_ops.h
+++ b/libsuspend/autosuspend_ops.h
@@ -20,10 +20,9 @@
20struct autosuspend_ops { 20struct autosuspend_ops {
21 int (*enable)(void); 21 int (*enable)(void);
22 int (*disable)(void); 22 int (*disable)(void);
23 void (*set_wakeup_callback)(void (*func)(bool success));
23}; 24};
24 25
25struct autosuspend_ops *autosuspend_autosleep_init(void);
26struct autosuspend_ops *autosuspend_earlysuspend_init(void);
27struct autosuspend_ops *autosuspend_wakeup_count_init(void); 26struct autosuspend_ops *autosuspend_wakeup_count_init(void);
28 27
29#endif 28#endif
diff --git a/libsuspend/autosuspend_wakeup_count.c b/libsuspend/autosuspend_wakeup_count.c
index 0a172be79..81cb44cd9 100644
--- a/libsuspend/autosuspend_wakeup_count.c
+++ b/libsuspend/autosuspend_wakeup_count.c
@@ -42,7 +42,7 @@ static int state_fd;
42static int wakeup_count_fd; 42static int wakeup_count_fd;
43static pthread_t suspend_thread; 43static pthread_t suspend_thread;
44static sem_t suspend_lockout; 44static sem_t suspend_lockout;
45static const char *sleep_state = "mem"; 45static const char* sleep_state = "mem";
46static void (*wakeup_func)(bool success) = NULL; 46static void (*wakeup_func)(bool success) = NULL;
47static int sleep_time = BASE_SLEEP_TIME; 47static int sleep_time = BASE_SLEEP_TIME;
48 48
@@ -55,8 +55,7 @@ static void update_sleep_time(bool success) {
55 sleep_time = MIN(sleep_time * 2, 60000000); 55 sleep_time = MIN(sleep_time * 2, 60000000);
56} 56}
57 57
58static void *suspend_thread_func(void *arg __attribute__((unused))) 58static void* suspend_thread_func(void* arg __attribute__((unused))) {
59{
60 char buf[80]; 59 char buf[80];
61 char wakeup_count[20]; 60 char wakeup_count[20];
62 int wakeup_count_len; 61 int wakeup_count_len;
@@ -117,8 +116,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
117 return NULL; 116 return NULL;
118} 117}
119 118
120static int autosuspend_wakeup_count_enable(void) 119static int autosuspend_wakeup_count_enable(void) {
121{
122 char buf[80]; 120 char buf[80];
123 int ret; 121 int ret;
124 122
@@ -136,8 +134,7 @@ static int autosuspend_wakeup_count_enable(void)
136 return ret; 134 return ret;
137} 135}
138 136
139static int autosuspend_wakeup_count_disable(void) 137static int autosuspend_wakeup_count_disable(void) {
140{
141 char buf[80]; 138 char buf[80];
142 int ret; 139 int ret;
143 140
@@ -155,8 +152,7 @@ static int autosuspend_wakeup_count_disable(void)
155 return ret; 152 return ret;
156} 153}
157 154
158void set_wakeup_callback(void (*func)(bool success)) 155static void autosuspend_set_wakeup_callback(void (*func)(bool success)) {
159{
160 if (wakeup_func != NULL) { 156 if (wakeup_func != NULL) {
161 ALOGE("Duplicate wakeup callback applied, keeping original"); 157 ALOGE("Duplicate wakeup callback applied, keeping original");
162 return; 158 return;
@@ -165,12 +161,12 @@ void set_wakeup_callback(void (*func)(bool success))
165} 161}
166 162
167struct autosuspend_ops autosuspend_wakeup_count_ops = { 163struct autosuspend_ops autosuspend_wakeup_count_ops = {
168 .enable = autosuspend_wakeup_count_enable, 164 .enable = autosuspend_wakeup_count_enable,
169 .disable = autosuspend_wakeup_count_disable, 165 .disable = autosuspend_wakeup_count_disable,
166 .set_wakeup_callback = autosuspend_set_wakeup_callback,
170}; 167};
171 168
172struct autosuspend_ops *autosuspend_wakeup_count_init(void) 169struct autosuspend_ops* autosuspend_wakeup_count_init(void) {
173{
174 int ret; 170 int ret;
175 char buf[80]; 171 char buf[80];
176 172
diff --git a/libsuspend/include/suspend/autosuspend.h b/libsuspend/include/suspend/autosuspend.h
index 59188a804..e130ca3df 100644
--- a/libsuspend/include/suspend/autosuspend.h
+++ b/libsuspend/include/suspend/autosuspend.h
@@ -51,7 +51,7 @@ int autosuspend_disable(void);
51 * success is true if the suspend was sucessful and false if the suspend 51 * success is true if the suspend was sucessful and false if the suspend
52 * aborted due to some reason. 52 * aborted due to some reason.
53 */ 53 */
54void set_wakeup_callback(void (*func)(bool success)); 54void autosuspend_set_wakeup_callback(void (*func)(bool success));
55 55
56__END_DECLS 56__END_DECLS
57 57