#!/system/bin/sh
init_dev(){
# init work
chmod 666 /dev/dgard0
chmod 666 /dev/ttyS0
chmod 666 /dev/ttyS5
chmod 666 /dev/ttyS7
chmod 666 /dev/tamper0
chmod 666 /dev/magnetometer0
chmod 666 /dev/doorbutton0
chmod 666 /dev/elevator0
chmod 666 /dev/microwave0
chmod 666 /dev/lightdetector0
chmod 666 /dev/gpio0
chmod 666 /dev/firealarm0
chmod 666 /dev/lightdetect_threshold
#chmod 666 /dev/camera_restart0
chmod 666 /dev/wrtrelay0
chmod 666 /dev/b2-pwm0
echo peripheral > /sys/devices/platform/fe8a0000.usb2-phy/otg_mode
}
FLAG=$(getprop persist.sys.first_run)
echo "install robot bin start"
#FLAG=$?
if [ 1 -eq $FLAG ];then
setprop persist.sys.first_run 0
echo "will reboot after install rebot.apk"
#tar -xzvf /system/user/enjoylink.tgz -C /data/
sync
echo "install robot.apk"
pm install /system/user/app/xx.apk
sync
sleep 1
init_dev
am start -n com/.view.main.MainActivity
#reboot
fi
while true
do
BOOTCOMPLETED=`getprop sys.bootstat.first_boot_completed`
echo check BOOTCOMPLETED=$BOOTCOMPLETED
if [ $BOOTCOMPLETED == "1" ] ; then
init_dev
sleep 1
echo to start home launcher ...
input keyevent 3
echo done.
exit 0
fi
echo do nothing, but sleep ...
sleep 1
done
###sleep 120
###PSAPP=`ps -ef | grep com.gemdale.gempad | wc -l`
###if [ $PSAPP -eq 1 ];then
### input keyevent 3
###fi