2014年4月18日 星期五

[程式] Android Debug Bridge (adb)

  • Check & Kill Running Process
    $ adb root
    $ adb remount
    $ adb shell
    $ ps | grep "<part of process name>"
    ex.
    $ ps | grep "service"
    USER   PID PPID VSIZE RSS   WCHAN    PC         NAME
    root   123 1    4321  888   c194c4d0 b76d1703 S /system/bin/theservice
    system 987 222  12345 54321 ffffffff 400a4d5b S com.test.security.service
    
    Note.
    USER  - user of process
    PID   - process ID
    PPID  - process parent ID
    VSIZE - virtual size
    RSS   - resident set size
    WCHAN - wait channel in ps
    (address of the kernel function where the process is sleeping (use wchan if you want the kernel function name). Running tasks will display a dash (’-’) in this column.)
    PC    - program counter
    NAME  - process name
    
    $ kill <PID>

    REF:
    http://blog.csdn.net/tcpipstack/article/details/8541980
    http://www.devdiv.com/adb_shell_ps_-blog-1682-6510.html
    http://somethingthatilearned2day.com/2006/11/29/wchan-in-ps-l/

  • Check Running Services
    $ adb shell dumpsys activity services
       or
       adb shell dumpsys activity services | grep <keyword to search>
    ex.
    $ adb shell dumpsys activity services | grep firmware

  • [ E ]
    Use "adb devices" and get respond:
    List of devices attached
    ???????????? no permissions
    [ S ]
    $ adb kill-server
    $ sudo adb start-server
       (The command "adb" wouldn't be found if $PATH isn't set under sudo)
       or
       cd ~/adt-bundle-linux-x86_64-20131030/sdk/platform-tools
       sudo ./adb start-server
    $ adb devices

    REF:
    http://www.blogjava.net/brian/articles/316019.html

  • [ E ]
    While pushing .apk to device, Error:
    failed to copy '<LOCAL_PACKAGE_NAME>.apk' to '/system/app/<LOCAL_PACKAGE_NAME>.apk': Read-only file system
    [ S ]
    $ adb root
    $ adb remount
    $ adb push <LOCAL_PACKAGE_NAME>.apk /system/app

  • [ P ]
    使用 adb push ... 在 terminal 上顯示成功,但實際上 apk 沒有確實更新。
    [ S ]
    $ adb shell stop
    $ adb shell start
    $ adb push ...

  • 查看目前有哪些Task,其中各有那些activity
    $ adb shell dumpsys activity activities
    Check "Recent tasks" 部分(依最近的task排序)
    ("Running activities (most recent first)"部分亦可,但依recent activity排序)
    REF:
    http://stackoverflow.com/questions/2442713/view-the-tasks-activity-stack

  • Logcat
    $ adb logcat
    or
    $ adb logcat -v time | grep <string to search>
    其中 -v time 為顯示時間 (optional)
    grep ... 為篩選 log 條件 (optional)

沒有留言:

張貼留言