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

2014-11-24 07:48:45 · 作者: · 浏览: 2

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);


}