Closed zjw2004112 closed 2 years ago
问下用thread能唤醒屏幕吗?
var hour1 = 08, min1 = 20, second1 = 30; run(); //实时显示脚本运行时长,并对返回的时长与设定的时长进行判断 function run() { //声明运行函数 threads.shutDownAll(); threads.start(function () { while (true) { console.show(); console.log(new Date().getSeconds()); if ((new Date().getHours() 1 == hour1 && new Date().getMinutes() 1 == min1 ) { if (!device.isScreenOn()) { device.wakeUp(); sleep(1000); swipe(500, 0, 500, 1900, 2000); gotoDaKa(); back(); sleep(2000); run(); } else { gotoDaKa(); back(); sleep(2000); run(); } } sleep(1000); } }); }
ps:在不息屏的情况下执行没问题,但是在息屏threads好像没执行了,问下怎么解决?
最好不要在息屏时循环sleep 不管是主线程还是子线程,息屏时都会受到手机电池管理策略的影响,Update频率会降低,出现假死的情况 所以才要依靠外部的程序发出一个通知来点亮屏幕
你可以在循环里加个打印测试一下,息屏之后,打印的间隔会越来越长
问下用thread能唤醒屏幕吗?
var hour1 = 08, min1 = 20, second1 = 30; run(); //实时显示脚本运行时长,并对返回的时长与设定的时长进行判断 function run() { //声明运行函数 threads.shutDownAll(); threads.start(function () { while (true) { console.show(); console.log(new Date().getSeconds()); if ((new Date().getHours() 1 == hour1 && new Date().getMinutes() 1 == min1 ) { if (!device.isScreenOn()) { device.wakeUp(); sleep(1000); swipe(500, 0, 500, 1900, 2000); gotoDaKa(); back(); sleep(2000); run(); } else { gotoDaKa(); back(); sleep(2000); run(); } } sleep(1000); } }); }
ps:在不息屏的情况下执行没问题,但是在息屏threads好像没执行了,问下怎么解决?