blob: bbd902989938b36b0a39a1a5833a3e93bc76131d [file] [log] [blame]
xj4049f512022-04-02 15:41:13 +08001/* //device/system/rild/rild.c
2**
3** Copyright 2006 The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#include <stdio.h>
19#include <stdlib.h>
xj9db5b622022-05-04 16:50:24 +080020#include <stdbool.h>
xj4049f512022-04-02 15:41:13 +080021#include <dlfcn.h>
22#include <string.h>
23#include <pthread.h>
24#include <stdint.h>
25#include <unistd.h>
26#include <fcntl.h>
27#include <errno.h>
xj9db5b622022-05-04 16:50:24 +080028#include <log/log.h>
xj4049f512022-04-02 15:41:13 +080029#include <liblog/lynq_deflog.h>
30#include <include/lynq_uci.h>
31#include <sys/socket.h>
32#include <sys/un.h>
xje74bccc2022-05-09 10:34:43 +080033#include <signal.h>
xj4049f512022-04-02 15:41:13 +080034
xj9db5b622022-05-04 16:50:24 +080035
xj4049f512022-04-02 15:41:13 +080036#define LOG_UCI_MODULE "lynq_autosuspend"
37#define LOG_UCI_FILE "lynq_uci"
38
39#define LOG_TAG "AUTOSUSPEND"
40
41#define USER_LOG_TAG "PMS"
42
xj9db5b622022-05-04 16:50:24 +080043#define SOCK_PATH "/tmp/autosuspend.cmd.server" //不能在当前这个目录创建socket文件,否则报错找不到文件(可能是因为这是在共享文件夹下,不支持创建socket文件)
44
45#define SOCK_DATA_PATH "/tmp/autosuspend.data.server"
xj4049f512022-04-02 15:41:13 +080046
47// #define LYINFLOG(X...) lynq_log_global_output(LOG_INFO,X)
48
49#define TIME_OUT_TIME 30
50
51
xj4049f512022-04-02 15:41:13 +080052#define MAX_LIB_ARGS 16
53
54int adb_debug_mode = 0;
55
xj9db5b622022-05-04 16:50:24 +080056
57pthread_cond_t feedback_cond = PTHREAD_COND_INITIALIZER;
58pthread_mutex_t feedback_mutex = PTHREAD_MUTEX_INITIALIZER;
59pthread_mutex_t time_info_mutex = PTHREAD_MUTEX_INITIALIZER;
60
xj4049f512022-04-02 15:41:13 +080061extern int autosuspend_enable(void);
62extern int autosuspend_disable(void);
63extern void init_wakelock_func(void);
64extern void init_sim_func();
65extern void init_network_func();
xj9db5b622022-05-04 16:50:24 +080066extern void set_wakeup_callback(void (*func)(bool success));
67extern void wakeup_feedback(bool success);
xje74bccc2022-05-09 10:34:43 +080068extern int (*lynq_screen)(int num);
xj4049f512022-04-02 15:41:13 +080069
xj9db5b622022-05-04 16:50:24 +080070struct time_info_t
71{
72 long sleep_start_time;
73 long wakeup_time;
74};
75
76struct time_info_t time_info;
77
xj4049f512022-04-02 15:41:13 +080078static void usage(const char *argv0) {
79 fprintf(stderr, "Usage: %s -l <possible_max_sleep_time> [-- <args for Autosuspend Service>]\n", argv0);
80 exit(EXIT_FAILURE);
81}
82
83
84
85static int make_argv(char * args, char ** argv) {
86 // Note: reserve argv[0]
87 int count = 1;
88 char * tok;
89 char * s = args;
90
91 while ((tok = strtok(s, " \0"))) {
92 argv[count] = tok;
93 s = NULL;
94 count++;
95 }
96 return count;
97}
98
99static int Accept(int fd, struct sockaddr *sa, socklen_t *salenptr)
100{
101 int n;
102
103 while((n = accept(fd, sa, salenptr)) < 0)
104 {
105 if((errno == ECONNABORTED) || (errno == EINTR))
106 continue;
107 else
108 {
109 ALOGI("accept error\n");
110 return -1;
111 }
112 }
113 return n;
114}
115
116static int Bind(int fd, const struct sockaddr *sa, socklen_t salen)
117{
118 if(bind(fd, sa, salen) < 0)
119 {
120 // ALOGI("bind error\n");
121 perror("bind error");
122 return -1;
123 }
124 return 0;
125}
126
xj4049f512022-04-02 15:41:13 +0800127
128static int Socket(int family, int type, int protocol)
129{
130 int n;
131
132 if ( (n = socket(family, type, protocol)) < 0)
133 {
134 ALOGI("socket error\n");
135 return -1;
136 }
137 return n;
138}
139
140static int Listen(int fd, int backlog)
141{
142 if(listen(fd, backlog) < 0)
143 {
144 ALOGI("listen error\n");
145 return -1;
146 }
147 return 0;
148}
149
xj4049f512022-04-02 15:41:13 +0800150
151static int listen_port(struct sockaddr_un *addr, char *sockpath)
152{
153 int listenfd;
154 listenfd = Socket(AF_UNIX,SOCK_STREAM,0);
155 if(listenfd == -1)
156 return -1;
157 memset(addr, 0, sizeof(struct sockaddr_un));
158 addr->sun_family = AF_UNIX;
159 strcpy(addr->sun_path,sockpath);
160 // int opt = 1;
161 // if(setsockopt(listenfd, SOL_SOCKET,SO_REUSEADDR, (const void *)&opt, sizeof(opt)) == -1)
162 // {
163 // perror("setsockopt error");
164 // return -1;
165 // }
166
167// 以上方法对非网络的本地socket无效,应该用unlink函数避免Address already in use的错误
168
169
170 unlink(sockpath);
171 if(Bind(listenfd,(struct sockaddr *)addr,sizeof(*addr)) == -1)
172 return -1;
173
174 if(Listen(listenfd,20) == -1)
175 return -1;
176
177 return listenfd;
178}
179
180static ssize_t Read(int fd, void *ptr, size_t nbytes)
181{
182 ssize_t n;
183
184 while((n = read(fd, ptr, nbytes)) == -1)
185 {
186 //printf("READ,%d\n",fd);
187 if (errno == EINTR)
188 {
189 ALOGI("read error eintr\n");
190 continue;
191 }
xj9db5b622022-05-04 16:50:24 +0800192 else if(errno == EAGAIN || errno == EWOULDBLOCK)
xj4049f512022-04-02 15:41:13 +0800193 {
xj9db5b622022-05-04 16:50:24 +0800194 ALOGI("read time out\n");
xj4049f512022-04-02 15:41:13 +0800195 return -1;
196 }
197 else
198 {
199 ALOGI("read error\n");
200 return -1;
201 }
202 }
203 //sleep(2);
204 //printf("READ1,%d\n", fd);
205 return n;
206}
207
208static ssize_t Write(int fd, const void *ptr, size_t nbytes)
209{
210 ssize_t n;
211
212 while((n = write(fd, ptr, nbytes)) == -1)
213 {
214 if (errno == EINTR)
215 continue;
216 else if(errno == EPIPE)
217 {
218 ALOGI("write error epipe\n");
219 return -1;
220 }
221 else
222 return -1;
223 }
224 return n;
225}
226
227static int Close(int fd)
228{
229 if (close(fd) == -1)
230 {
xj9db5b622022-05-04 16:50:24 +0800231 ALOGI("close error\n");
xj4049f512022-04-02 15:41:13 +0800232 return -1;
233 }
234 return 0;
235}
236
xj9db5b622022-05-04 16:50:24 +0800237
xj4049f512022-04-02 15:41:13 +0800238void *deal_autosuspend(void *sockfd)
239{
240 int commfd = *((int *)sockfd);
xj9db5b622022-05-04 16:50:24 +0800241 char buf[20];
242 char res[15];
xj4049f512022-04-02 15:41:13 +0800243
244 while(1)
245 {
246 memset(buf,0,sizeof(buf));
247 ALOGI("deal_autosuspend start to read.\n");
248 // 错误点:read函数在对端关闭后,也会直接返回0,不会阻塞,因此要判断是否返回0,返回0表示对端已经关闭,此时要跳出while循环不再监听
249 // 为什么对端会关闭?因为在客户端没有用nohup方式打开的情况下,系统睡眠后客户端进行会直接被杀死,对端会关闭,所以会导致read不阻塞,且总是返回0的现象
xj9db5b622022-05-04 16:50:24 +0800250 if(Read(commfd,buf,sizeof(buf)) <= 0)
xj4049f512022-04-02 15:41:13 +0800251 {
xje74bccc2022-05-09 10:34:43 +0800252 ALOGI("service receive suspend_cmd fail or client is closed.\n");
xj9db5b622022-05-04 16:50:24 +0800253 Close(commfd);
xj4049f512022-04-02 15:41:13 +0800254 break;
255 }
256 if(strcmp(buf,"enable") == 0)
257 {
jb.qiae8158e2022-09-22 00:39:45 -0700258 /*
xje74bccc2022-05-09 10:34:43 +0800259 system("echo 7 | emdlogger_ctrl");
260
261 if (lynq_screen(0) < 0) //notify ril for screen off
262 {
263 ALOGI("lynq_screen off fail\n");
264 return -1;
265 }
266
jb.qiae8158e2022-09-22 00:39:45 -0700267 sleep(5);*/
xj4049f512022-04-02 15:41:13 +0800268 if(autosuspend_enable() < 0)
269 {
270 ALOGI("autosuspend_enable fail.\n");
xje74bccc2022-05-09 10:34:43 +0800271 // strcpy(res,"fail");
272 // if(Write(commfd,res,strlen(res)) <= 0)
273 // {
274 // ALOGI("service send respond fail.\n");
275 // Close(commfd);
276 // break;
277 // }
xj4049f512022-04-02 15:41:13 +0800278 }
279 else
280 {
281 ALOGI("autosuspend_enable success.\n");
xje74bccc2022-05-09 10:34:43 +0800282 // strcpy(res,"enabled");
283 // if(Write(commfd,res,strlen(res)) <= 0)
284 // {
285 // ALOGI("service send respond fail.\n");
286 // Close(commfd);
287 // break;
288 // }
xj4049f512022-04-02 15:41:13 +0800289 }
290 }
291 else if(strcmp(buf,"disable") == 0)
292 {
293 if(autosuspend_disable() < 0)
294 {
295 ALOGI("autosuspend_disable fail.\n");
xje74bccc2022-05-09 10:34:43 +0800296 // strcpy(res,"fail");
297 // if(Write(commfd,res,strlen(res)) <= 0)
298 // {
299 // ALOGI("service send respond fail.\n");
300 // Close(commfd);
301 // break;
302 // }
xj4049f512022-04-02 15:41:13 +0800303 }
304 else
305 {
306 ALOGI("autosuspend_disable success.\n");
xje74bccc2022-05-09 10:34:43 +0800307 // strcpy(res,"disabled");
308 // if(Write(commfd,res,strlen(res)) <= 0)
309 // {
310 // ALOGI("service send respond fail.\n");
311 // Close(commfd);
312 // break;
313 // }
xj4049f512022-04-02 15:41:13 +0800314 }
315 }
xj9db5b622022-05-04 16:50:24 +0800316 // else if(strcmp(buf,"feedback") == 0)
317 // {
318
319 // ALOGI("send_feedback thread wait to send.\n");
320 // if (pthread_cond_wait(&feedback_cond,&feedback_mutex) != 0)
321 // {
322 // strerror_r(errno, buf, sizeof(buf));
323 // ALOGI("Error waiting on cond: %s\n", buf);
324 // Close(commfd);
325 // break;
326 // }
327
328 // ALOGI("send_feedback thread is now sending the feedback to client.\n");
329 // if(Write(commfd,&time_info,sizeof(struct time_info_t)) <= 0)
330 // {
331 // ALOGI("service send wakeup_feedback struct fail.\n");
332 // Close(commfd);
333 // break ;
334 // }
335 // ALOGI("service send feedback success.\n");
336 // strcpy(res,"success");
337 // if(Write(commfd,res,strlen(res)) <= 0)
338 // {
339 // ALOGI("service send respond fail.\n");
340 // Close(commfd);
341 // break;
342 // }
343
344 // }
xj4049f512022-04-02 15:41:13 +0800345 else
346 {
xj9db5b622022-05-04 16:50:24 +0800347 ALOGI("Unknown cmd : %s\n",buf);
xj4049f512022-04-02 15:41:13 +0800348 }
xj9db5b622022-05-04 16:50:24 +0800349
xj4049f512022-04-02 15:41:13 +0800350 }
351
352
353
354}
jb.qi6734e172022-11-12 21:47:13 -0800355/*jb.qi add for service send when DTR is low on 20221111 start */
356void *dtr_wakeup()
357{
358 FILE *fp;
359 int ret;
360 bool success = true;
361 char buf[30];
362 char dtr_buffer[25];
363 RLOGD("dtr_wakeup start\n");
364 while(1)
365 {
366 fp = popen("cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep 006:","r");
367 fgets(dtr_buffer, sizeof(dtr_buffer), fp);
368 if(dtr_buffer[7] == '0')
369 {
370 time_info.sleep_start_time = 123;
371 time_info.wakeup_time = 123;
372 if (pthread_cond_broadcast(&feedback_cond) != 0)
373 {
374 strerror_r(errno, buf, sizeof(buf));
375 ALOGI("Error broadcast cond: %s\n", buf);
376 }
377 RLOGD("dtr_wakeup success!\n");
378 sleep(3);
379 }
jb.qi12566152023-01-03 22:54:36 -0800380 usleep(500000);
jb.qi6734e172022-11-12 21:47:13 -0800381 pclose(fp);
382 }
383}
384/*jb.qi add for service send when DTR is low on 20221111 end */
xj4049f512022-04-02 15:41:13 +0800385
xj9db5b622022-05-04 16:50:24 +0800386void *send_feedback(void *sockfd)
387{
388 int commfd = *((int *)sockfd);
389 char buf[80];
390
391 while (1)
392 {
393 memset(buf,0,sizeof(buf));
394 ALOGI("send_feedback thread wait to send.\n");
395 pthread_mutex_lock(&feedback_mutex);
396 pthread_cond_wait(&feedback_cond,&feedback_mutex);
xj9db5b622022-05-04 16:50:24 +0800397
xj9db5b622022-05-04 16:50:24 +0800398 ALOGI("send_feedback thread is now sending the feedback to client.\n");
399 pthread_mutex_lock(&time_info_mutex);
400 if(Write(commfd,&time_info,sizeof(struct time_info_t)) <= 0)
401 {
402 ALOGI("service send wakeup_feedback struct fail.\n");
403 Close(commfd);
404 pthread_mutex_unlock(&time_info_mutex);
405 pthread_mutex_unlock(&feedback_mutex);
jb.qi6734e172022-11-12 21:47:13 -0800406 continue ;//jb.qi add for service send when DTR is low on 20221111
xj9db5b622022-05-04 16:50:24 +0800407 }
408 pthread_mutex_unlock(&time_info_mutex);
xj9db5b622022-05-04 16:50:24 +0800409 pthread_mutex_unlock(&feedback_mutex);
xj9db5b622022-05-04 16:50:24 +0800410 }
411
412}
413
xj4049f512022-04-02 15:41:13 +0800414
qjb66daefd2023-07-19 03:51:50 -0700415void *check_wakeup_sources(void *sockfd)
416{
417 FILE *fp;
418 int ret;
419 char buf[256];
420 RLOGD("start check wakeup_sources !!!\n");
421 while(1)
422 {
423 memset(buf,0,sizeof(buf));
424 fp = popen("cat /sys/kernel/debug/wakeup_sources|sed -e 's/\"^ \"/\"unnamed\"/g' | awk '{print $6 \"\t\" $1}'| grep -v \"^0\" |sort -n \n","r");
425 while(fgets(buf, 255, fp) != NULL)
426 {
427 RLOGD("%s", buf);
428 }
429 pclose(fp);
430 sleep(3);
431 }
432}
433
434
xj4049f512022-04-02 15:41:13 +0800435int main(int argc, char **argv) {
436
437
438 // int i = 0;
439 // RLOGD("**Autosuspend Service Daemon Started**");
440 // RLOGD("**Autosuspend Service param count=%d**", argc);
441 char tmp[20];
xj9db5b622022-05-04 16:50:24 +0800442
443 int commfd, commfd_data, server_sock, server_data_sock,len, len_data;
444
xj4049f512022-04-02 15:41:13 +0800445 struct sockaddr_un server_sockaddr;
xj9db5b622022-05-04 16:50:24 +0800446 struct sockaddr_un server_data_sockaddr;
xj4049f512022-04-02 15:41:13 +0800447 struct sockaddr_un client_sockaddr;
xj9db5b622022-05-04 16:50:24 +0800448
xj4049f512022-04-02 15:41:13 +0800449 len = sizeof(server_sockaddr);
450
xj9db5b622022-05-04 16:50:24 +0800451
qjb66daefd2023-07-19 03:51:50 -0700452 pthread_t tid,tid_1,tid_2; //jb.qi add for service send when DTR is low on 20221111
xj4049f512022-04-02 15:41:13 +0800453
xj4049f512022-04-02 15:41:13 +0800454 LYLOGEINIT(USER_LOG_TAG);
455 LYLOGSET(LOG_DEBUG);
456 // LYLOGSET(LOG_ERROR);
457
xj9db5b622022-05-04 16:50:24 +0800458 int auto_enable = 0;
xj4049f512022-04-02 15:41:13 +0800459
xje74bccc2022-05-09 10:34:43 +0800460 lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "debug", tmp); // 即获取系统层面的环境变量
xj9db5b622022-05-04 16:50:24 +0800461 ALOGI("Autosuspend Service Daemon. debug %s\n",tmp);
xj4049f512022-04-02 15:41:13 +0800462 adb_debug_mode=atoi(tmp);
463 lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "auto_enable", tmp);
464 auto_enable=atoi(tmp);
465 ALOGI("Autosuspend Service Daemon. auto_enable %s\n",tmp);
466 init_wakelock_func();
467 init_sim_func();
xj9db5b622022-05-04 16:50:24 +0800468
xje74bccc2022-05-09 10:34:43 +0800469 signal(SIGPIPE,SIG_IGN); // 忽略SIGPIPE信号,防止由于客户端关闭,继续往客户端write,会导致服务端收到SIGPIPE信号而Broken pipe
470
xj9db5b622022-05-04 16:50:24 +0800471 set_wakeup_callback(wakeup_feedback);
xje74bccc2022-05-09 10:34:43 +0800472 // 注册回调函数
xj9db5b622022-05-04 16:50:24 +0800473
xj4049f512022-04-02 15:41:13 +0800474 if(auto_enable==0)
475 {
476 if(autosuspend_disable() < 0)
477 {
478 ALOGI("autosuspend_disable fail.\n");
479 }
480 else
481 {
482 ALOGI("autosuspend_disable success.\n");
483 }
484 }
485 if(auto_enable==1)
486 {
487 if(autosuspend_enable() < 0)
488 {
489 ALOGI("autosuspend_enable fail.\n");
490 }
491 else
492 {
493 ALOGI("autosuspend_enable success.\n");
494 }
495 }
496
497
498 server_sock = listen_port(&server_sockaddr,SOCK_PATH);
499 if(server_sock == -1)
500 return -1;
501
xj9db5b622022-05-04 16:50:24 +0800502 server_data_sock = listen_port(&server_data_sockaddr,SOCK_DATA_PATH);
503 if(server_data_sock == -1)
504 return -1;
505
jb.qi6734e172022-11-12 21:47:13 -0800506 /*jb.qi add for service send when DTR is low on 20221111 start*/
507 pthread_create(&tid_1,NULL,dtr_wakeup,NULL);
508 pthread_detach(tid_1);
509 /*jb.qi add for service send when DTR is low on 20221111 end*/
xj9db5b622022-05-04 16:50:24 +0800510
qjb66daefd2023-07-19 03:51:50 -0700511 if(adb_debug_mode == 2)
512 {
513 pthread_create(&tid_2,NULL, check_wakeup_sources,NULL);
514 pthread_detach(tid_2);
515 }
516
xj4049f512022-04-02 15:41:13 +0800517 while (1)
518 {
519 ALOGI("service socket listening...\n");
520 commfd = Accept(server_sock,(struct sockaddr *)&client_sockaddr,&len);
521 if(commfd == -1)
522 {
523 return -1;
524 }
525 if(getpeername(commfd, (struct sockaddr *)&client_sockaddr, &len) == -1)
526 {
527 ALOGI("GETPEERNAME ERROR.\n");
xj9db5b622022-05-04 16:50:24 +0800528 // Close(server_sock);
529 Close(commfd);
xj4049f512022-04-02 15:41:13 +0800530 continue;
531 }
532 else
533 {
534 ALOGI("Client socket filepath: %s\n", client_sockaddr.sun_path);
535 }
xj9db5b622022-05-04 16:50:24 +0800536
537 commfd_data = Accept(server_data_sock,NULL,NULL);
538 if(commfd_data == -1)
539 {
540 return -1;
541 }
542 ALOGI("data channel connected.\n");
543
xj4049f512022-04-02 15:41:13 +0800544 pthread_create(&tid,NULL,deal_autosuspend,(void*)&commfd);//这里很容易错,最后一个参数要取地址,这是一个指针
xj9db5b622022-05-04 16:50:24 +0800545 pthread_detach(tid);
546
547 pthread_create(&tid,NULL,send_feedback,(void*)&commfd_data);
548 pthread_detach(tid);
549
xj4049f512022-04-02 15:41:13 +0800550
551 }
552
553 /* for (i = 1; i < argc ;) {
554 if (0 == strcmp(argv[i], "-l") && (argc - i > 1)) {
555 rilLibPath = argv[i + 1];
556 i += 2;
557 } else if (0 == strcmp(argv[i], "--")) {
558 i++;
559 hasLibArgs = 1;
560 break;
561 } else if (0 == strcmp(argv[i], "-c") && (argc - i > 1)) {
562 clientId = argv[i+1];
563 i += 2;
564 } else {
565 usage(argv[0]);
566 }
567 }
568
569 if (clientId == NULL) {
570 clientId = "0";
571 } else if (atoi(clientId) >= MAX_RILDS) {
572 RLOGE("Max Number of rild's supported is: %d", MAX_RILDS);
573 exit(0);
574 }
575 if (strncmp(clientId, "0", MAX_CLIENT_ID_LENGTH)) {
576 strncpy(ril_service_name, ril_service_name_base, MAX_SERVICE_NAME_LENGTH);
577 strncat(ril_service_name, clientId, MAX_SERVICE_NAME_LENGTH);
578 }
579
580 if (rilLibPath == NULL) {
581 if ( 0 == property_get(LIB_PATH_PROPERTY, libPath, NULL)) {
582 // No lib sepcified on the command line, and nothing set in props.
583 // Assume "no-ril" case.
584 goto done;
585 } else {
586 rilLibPath = libPath;
587 }
588 }
589
590 dlHandle = dlopen(rilLibPath, RTLD_NOW);
591
592 if (dlHandle == NULL) {
593 RLOGE("dlopen failed: %s", dlerror());
594 exit(EXIT_FAILURE);
595 }
596
597 RIL_startEventLoop();
598
599 rilInit =
600 (const RIL_RadioFunctions *(*)(const struct RIL_Env *, int, char **))
601 dlsym(dlHandle, "RIL_Init");
602
603 if (rilInit == NULL) {
604 RLOGE("RIL_Init not defined or exported in %s\n", rilLibPath);
605 exit(EXIT_FAILURE);
606 }
607
608 dlerror(); // Clear any previous dlerror
609 rilUimInit =
610 (RIL_RadioFunctions *(*)(const struct RIL_Env *, int, char **))
611 dlsym(dlHandle, "RIL_SAP_Init");
612 err_str = dlerror();
613 if (err_str) {
614 RLOGW("RIL_SAP_Init not defined or exported in %s: %s\n", rilLibPath, err_str);
615 } else if (!rilUimInit) {
616 RLOGW("RIL_SAP_Init defined as null in %s. SAP Not usable\n", rilLibPath);
617 }
618
619 if (hasLibArgs) {
620 rilArgv = argv + i - 1;
621 argc = argc -i + 1;
622 } else {
623 static char * newArgv[MAX_LIB_ARGS];
624 static char args[PROPERTY_VALUE_MAX];
625 rilArgv = newArgv;
626 property_get(LIB_ARGS_PROPERTY, args, "");
627 argc = make_argv(args, rilArgv);
628 }
629
630 rilArgv[argc++] = "-c";
631 rilArgv[argc++] = (char*)clientId;
632 RLOGD("RIL_Init argc = %d clientId = %s", argc, rilArgv[argc-1]);
633
634 // Make sure there's a reasonable argv[0]
635 rilArgv[0] = argv[0];
636
637 funcs = rilInit(&s_rilEnv, argc, rilArgv);
638 RLOGD("RIL_Init rilInit completed");
639
640 RIL_register(funcs);
641
642 RLOGD("RIL_Init RIL_register completed");
643
644 if (rilUimInit) {
645 RLOGD("RIL_register_socket started");
646 RIL_register_socket(rilUimInit, RIL_SAP_SOCKET, argc, rilArgv);
647 }
648
649 RLOGD("RIL_register_socket completed");
650
651done:
652
653 rilc_thread_pool();
654
655 RLOGD("RIL_Init starting sleep loop");*/
xj9db5b622022-05-04 16:50:24 +0800656 // while (1) {
657 // // ALOGI("start autosuspend_enable:%d\n",(i++));
658 // sleep(5);
xj4049f512022-04-02 15:41:13 +0800659
xj9db5b622022-05-04 16:50:24 +0800660 // }
xj4049f512022-04-02 15:41:13 +0800661}