首先,我的手机是小米Red Mi Note 7。
MIUI版本:10.2.3。
Android版本:9 PKQ1.180904.001。
Shell脚本:
set -xeo pipefail
_stopnow() {
test -f stopnow && echo "Stopping!" && rm stopnow && exit 0 || return 0
}
while true
do
_stopnow
am instrument -w -r -e debug false -e class com.package.mobile.name com.package.mobile.test/android.support.test.runner.AndroidJUnitRunner
done
我尝试过的:
此方法的结论:已杀死
因为我没有/init.d文件夹,所以我改用/ init。
我有一个名为/ system / etc / init / mypackagepipefail.rc和/ system / bin / runpipefail]
mypackagepipefail.rc
on boot
start /system/bin/runpipefail
user system
group system readproc
runpipefail
#!/bin/sh
set -xeo pipefail
_stopnow() {
test -f stopnow && echo "Stopping!" && rm stopnow && exit 0 || return 0
}
while true
do
_stopnow
# Below here, you put in your command you want to run:
am instrument -w -r -e debug false -e class com.airasia.mobile.BigpayTest com.airasia.mobile.test/android.support.test.runner.AndroidJUnitRunner
此方法的结论:似乎服务在启动/启动时未运行。
上面的service.rc的使用是否有问题?还有其他方法可以在启动时运行shell脚本吗?
任何帮助都会很棒。非常感谢。
我刚刚发现我们可以使用node js运行脚本。所以我正在使用Dory Js,并与shelljs一起运行。看看这个。