Welcome 微信登录

首页 / 操作系统 / Linux / 几行让Android进入休眠的C代码

让Android进入休眠的C代码:static void gotoSleep(){//echo standby >/sys/android_power/request_statechar *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 ");        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 ");        return ;    }     write(fd, wake, strlen(wake));    close(fd);}