# 進入 service-mamager/bin 資料夾
$ cd bin
# 確認電腦已經連接手機 (只能連接一支手機)
$ ./adb.darwin devices
List of devices attached
LC53DYH00494 device
# 確認 app_process32 是否存在,不存在請改用 app_process
$ ./adb.darwin shell 'ls /system/bin/app_process32'
/system/bin/app_process32
# 確認 nohup 存在,不存在請改用 daemonize,兩者都不存在,可能要依賴電腦
$ ./adb.darwin shell 'ls /system/bin/nohup; ls /system/bin/daemonize'
/system/bin/nohup
/system/bin/daemonize: No such file or directory
# 確認 apk 安裝位置,請再次確認 Robotmon App 已經安裝
$ ./adb.darwin shell 'pm path com.r2studio.robotmon'
package:/data/app/com.r2studio.robotmon-1/base.apk
# 組合啟動 Service 指令
# 上述指令目的要湊出粗體字串
# nohup sh -c "LD_LIBRARY_PATH=/system/lib:/data/data/com.r2studio.robotmon/lib:/data/app/com.r2studio.robotmon-1/lib/arm:/data/app/com.r2studio.robotmon-2/lib/arm CLASSPATH=/data/app/com.r2studio.robotmon-1/base.apk app_process32 /system/bin com.r2studio.robotmon.Main $@" > /dev/null 2> /dev/null &
$ ./adb.darwin shell 'nohup sh -c "LD_LIBRARY_PATH=/system/lib:/data/data/com.r2studio.robotmon/lib:/data/app/com.r2studio.robotmon-1/lib/arm:/data/app/com.r2studio.robotmon-2/lib/arm CLASSPATH=/data/app/com.r2studio.robotmon-1/base.apk app_process32 /system/bin com.r2studio.robotmon.Main $@" > /dev/null 2> /dev/null &'
# 確認 Service 是否啟動,啟動成功會出現類似下列訊息,第二欄位為 process id
$ ./adb.darwin shell 'ps | grep app_process'
shell 9512 9508 1570960 39576 ffffffff ecc9c570 S app_process32
# 停止 Service
$ ./adb.darwin shell 'kill 9512'
# 確認是否成功停止 Service,沒出現額外訊息表示成功停止
$ ./adb.darwin shell 'ps | grep app_process'
# 進階排除錯誤,查看 Log。如果 Service 啟動失敗,手機會出現錯誤訊息來 Debug
$ ./adb.darwin logcat
# 訊息太多可用 grep 來 filter,關鍵字為 main, GoLog...
$ ./adb.darwin logcat | grep main
$ ./adb.darwin logcat | grep GoLog