[Bugfix] fix the bug of suspend failure when autosuspend is enabled
Change-Id: I4ed78e29eeb9ee163636bbbf2d28354936abe04f
diff --git a/lib/libautosuspend/libautosuspend.c b/lib/libautosuspend/libautosuspend.c
index 2588b04..a273595 100644
--- a/lib/libautosuspend/libautosuspend.c
+++ b/lib/libautosuspend/libautosuspend.c
@@ -320,20 +320,20 @@
return -1;
}
- if(Read(client_sock_fd,res,sizeof(res)) <= 0)
- {
- ALOGI("libautosuspend get respond fail.\n");
- pthread_mutex_unlock(&client_fd_mutex);
- return -1;
- }
+ // if(Read(client_sock_fd,res,sizeof(res)) <= 0)
+ // {
+ // ALOGI("libautosuspend get respond fail.\n");
+ // pthread_mutex_unlock(&client_fd_mutex);
+ // return -1;
+ // }
- ALOGI("libautosuspend get respond : %s.\n",res);
+ // ALOGI("libautosuspend get respond : %s.\n",res);
- if(strcmp(res,"enabled") != 0)
- {
- pthread_mutex_unlock(&client_fd_mutex);
- return -1;
- }
+ // if(strcmp(res,"enabled") != 0)
+ // {
+ // pthread_mutex_unlock(&client_fd_mutex);
+ // return -1;
+ // }
// libautosuspend_enabled = true;
@@ -368,20 +368,20 @@
return -1;
}
- if(Read(client_sock_fd,res,sizeof(res)) <= 0)
- {
- ALOGI("libautosuspend get respond fail.\n");
- pthread_mutex_unlock(&client_fd_mutex);
- return -1;
- }
+ // if(Read(client_sock_fd,res,sizeof(res)) <= 0)
+ // {
+ // ALOGI("libautosuspend get respond fail.\n");
+ // pthread_mutex_unlock(&client_fd_mutex);
+ // return -1;
+ // }
- ALOGI("libautosuspend get respond : %s.\n",res);
+ // ALOGI("libautosuspend get respond : %s.\n",res);
- if(strcmp(res,"disabled") != 0)
- {
- pthread_mutex_unlock(&client_fd_mutex);
- return -1;
- }
+ // if(strcmp(res,"disabled") != 0)
+ // {
+ // pthread_mutex_unlock(&client_fd_mutex);
+ // return -1;
+ // }
// libautosuspend_enabled = false;
@@ -392,34 +392,8 @@
}
-int lynq_wait_wakeup_event(long *sleep_start_time, long * wakeup_time)
-{
- int *socket_timeout = NULL;
- struct time_info_t time_info;
- int ret = 0;
-
- memset(&time_info,0,sizeof(struct time_info_t));
- if(sleep_start_time == NULL || wakeup_time == NULL )
- {
- ALOGI("lynq_wait_wakeup_event input errors.\n");
- return -1;
- }
- ret=libautosuspend_get_feedback(&time_info,socket_timeout);
- if(ret == 0)
- {
- *sleep_start_time = time_info.sleep_start_time;
- *wakeup_time = time_info.wakeup_time;
- return 0;
- }
- else
- {
- return -1;
- }
-
-}
-
-int libautosuspend_get_feedback(struct time_info_t *time_info, int *timeout)
+int libautosuspend_get_feedback(struct time_info_t *time_info)
{
// char value[15]="feedback";
// char res[15];
@@ -434,25 +408,25 @@
memset(time_info,0,sizeof(struct time_info_t));
- if(timeout == NULL)
- {
- ALOGI("client set timeout for receiving wakeup_feedback: NULL.\n");
- }
- else
- {
- struct timeval recv_timeout = {(*timeout),0};
- pthread_mutex_lock(&client_data_fd_mutex);
- if(setsockopt(client_data_sock_fd,SOL_SOCKET,SO_RCVTIMEO,(char*)&recv_timeout,sizeof(struct timeval)) == -1)
- {
- ALOGI("client set timeout for receiving wakeup_feedback: error.\n");
- pthread_mutex_unlock(&client_data_fd_mutex);
- return -1;
- }
+ // if(timeout == NULL)
+ // {
+ // ALOGI("client set timeout for receiving wakeup_feedback: NULL.\n");
+ // }
+ // else
+ // {
+ // struct timeval recv_timeout = {(*timeout),0};
+ // pthread_mutex_lock(&client_data_fd_mutex);
+ // if(setsockopt(client_data_sock_fd,SOL_SOCKET,SO_RCVTIMEO,(char*)&recv_timeout,sizeof(struct timeval)) == -1)
+ // {
+ // ALOGI("client set timeout for receiving wakeup_feedback: error.\n");
+ // pthread_mutex_unlock(&client_data_fd_mutex);
+ // return -1;
+ // }
- ALOGI("client set timeout for receiving wakeup_feedback: %d s.\n",(*timeout));
- pthread_mutex_unlock(&client_data_fd_mutex);
+ // ALOGI("client set timeout for receiving wakeup_feedback: %d s.\n",(*timeout));
+ // pthread_mutex_unlock(&client_data_fd_mutex);
- }
+ // }
// int rc = send_cmd(value,strlen(value));
// if(rc < 0)
@@ -489,6 +463,32 @@
}
+int lynq_wait_wakeup_event(long *sleep_start_time, long * wakeup_time)
+{
+ int *socket_timeout = NULL;
+ struct time_info_t time_info;
+ int ret = 0;
+
+ memset(&time_info,0,sizeof(struct time_info_t));
+ if(sleep_start_time == NULL || wakeup_time == NULL )
+ {
+ ALOGI("lynq_wait_wakeup_event input errors.\n");
+ return -1;
+ }
+ ret=libautosuspend_get_feedback(&time_info);
+ if(ret == 0)
+ {
+ *sleep_start_time = time_info.sleep_start_time;
+ *wakeup_time = time_info.wakeup_time;
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+
+
+}
// static void libautosuspend_get_feedback()
// {