#!/bin/sh

export LD_PRELOAD=/usr/lib/libdebugger.so
# For UI Auto tp test
#export QWS_MOUSE_PROTO="IntelliMouse:/dev/input/mice"
# QT env
source /etc/profile

# Set touchscreen env if there is a tp device
# Grep the tp name (such as 'goodix-ts') to find out there is a tp.
# e.g. TS=`cat /proc/bus/input/devices | grep "touch-ts"`
#TS=`cat /proc/bus/input/devices | grep "chipone-ts"`
TS=`cat /proc/bus/input/devices | grep "goodix-ts"`
if [ -n "$TS" ];
then
  export QWS_MOUSE_PROTO="Tslib:/dev/input/event1 IntelliMouse:/dev/input/mice"
fi


case "$1" in
  start)
    #logcat -v time -r4096 -f "/data/log/`date +%Y%m%d-%H-%M-%S.log`" &
    logcat -v time -r1024 -f "/data/log/system.log" &
    if [ -d "/data/ota/" ];then
      echo "clean /data/ota"
      rm -rf /data/ota/*
    fi
    aio -qws &
    if [ -e "/data/stress_test.sh" ];then
        chmod 777 /data/stress_test.sh
        /data/stress_test.sh &
    fi

    #/etc/init.d/meminfo.sh > "/data/`date +%Y%m%d-%H-%M-%S.log`" &
    ;;
  stop)
    pkill -9 aio
    sleep 1
    pkill wpa_supplicant
    pkill -9 viss_isp
    sleep 1
    ;;
  *)
    ;;
esac
