几行让Android进入休眠的C代码

Android进入休眠的C代码:

static void gotoSleep()

{

//echo standby >/sys/android_power/request_state

char *standby="standby" ;

int fd = open("/sys/android_power/request_state", O_WRONLY, 0);

if (fd == -1) {

perror("Could not open /sys/android_power/request_state\n");

return ;

}

write(fd, standby, strlen(standby));

close(fd);

}

static void wakeUp()

{

char *wake="wake";

int fd = open("/sys/android_power/request_state", O_WRONLY, 0);

if (fd == -1) {

perror("Could not open /sys/android_power/request_state\n");

return ;

}

write(fd, wake, strlen(wake));

close(fd);

}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwswsj.html