繁体   English   中英

使用usb充电启动时,添加初始化脚本以重启android marshmallow平板电脑

[英]Adding init script to reboot android marshmallow tablet when it's booted with usb charging

我已经尝试制作脚本,将平板电脑从充电模式重新启动到正常,如果它是通过插入usb充电器启动的话。 Android初始化语言非常简单,但实际上它的分区对我来说是非常神秘的。

所以我在root上实现了my_script.sh。 添加到系统文件my_script.sh initrd / my_script.sh 0750并重新打包boot.img。 验证一切都是它的地方,访问权限应该是正确的。

#!/system/bin/sh
/system/bin/reboot -c reboot now

然后我在init.rc中

service rebootit /system/bin/sh /my_script.sh
    class main
    user root
    oneshot

然后我在init.rc上的“充电器”下放了以下内容

start rebootit

知道如何实现这一目标吗?

编辑1.尝试以下。

service rebootit /system/bin/reboot -c reboot now
    class main
    user root
    oneshot

这是结果。

 [4.648753] init: cannot execve('/system/bin/reboot'): Permission denied
 [4.649167] type=1400 audit(85946.779:4): avc: denied { execute_no_trans } for pid=331 comm="init" path="/system/bin/reboot" dev="mmcblk0p21" ino=730 scontext=u:r:init:s0 tcontext=u:object_r:system_file:s0 tclass=file permissive=0

编辑2。

好。 一些进展。 echo b> / proc / sysrq-trigger似乎重新启动但现在我需要找到一些变量,我可以用它来分离在启动到正常模式时运行的脚本。 我试图使用我从另一个init文件中找到的这种脚本。 只是修改它适合我的需要,但仍然没有运气。

#!/system/bin/sh
bootmode=`getprop ro.bootmode`
if [ "$bootmode" = "charger" ]; then # Reboot the tablet
echo b > /proc/sysrq-trigger
fi

编辑3.解决方案

现在我终于明白了。

在init.rc上我添加了以下内容:

#Check if chargermode and start rebootit service.
on property:ro.bootmode=charger
    start rebootit   

之后又添加了以下内容:

#rebootit service which command reboot
service rebootit /su/bin/su /system/bin/reboot -c reboot now
    user root
    oneshot

您需要安装SU才能工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM