blob: 9aa5ebf89c17a2811a8b462cb8d889fefe887cbb [file] [log] [blame]
b.liu9bcf4932024-02-06 17:17:43 +08001#include <stdio.h>
2#include <unistd.h>
3#include <stdlib.h>
4#include <signal.h>
5#include <fcntl.h>
6
7#include "mbtk_utils.h"
8
9static int running = 0;
10
11static void sig_handler(int sig)
12{
13 printf("Signal : %d\n", sig);
14 running = 0;
15}
16
17
18int main(int argc, char *argv[])
19{
b.liub3b923a2024-06-06 15:15:49 +080020 int fd = open("/tmp/usb.info", O_CREAT | O_WRONLY, 0666);
b.liu9bcf4932024-02-06 17:17:43 +080021 signal(SIGINT, sig_handler);
22 signal(SIGTERM, sig_handler);
23 if(fd > 0) {
24 char buff[1024];
25 running = 1;
26 while(running){
27 memset(buff, 0, 1024);
28 if(mbtk_cmd_line("cat /sys/class/android_usb/android0/state", buff, 1024)) {
29 write(fd, buff, strlen(buff));
30 write(fd, "\n", 1);
31 }
32 sleep(1);
33 }
34 close(fd);
35 }
36 return 0;
37}
38