android模拟电源按键

来源:互联网 发布:天擎网络 编辑:程序博客网 时间:2024/05/18 07:17

对于设备上不方便按压的,或者甚至没有电源按键的,可以参考一下。

总结如下:

1、adb shell getevent查看power key event NUM



2、创建脚本,如:outPowerKey.sh,并push到设备system/bin/下


3、创建service运行上述脚本文件


4、测试及使用方法

adb shell

setprop persist.service.ist.outPowerKey 1

如果是短按则设备会睡眠或唤醒,如果是长按则会弹出关机/重启框。


使用方法:

代码中使用setprop进行操作

SystemProperties.set("persist.service.ist.outPowerKey","1");

或者

SystemProperties.set("ctl.start","RRPowerKey");


0 0
原创粉丝点击