1. 程式人生 > >android常用adb快捷命令一覽表

android常用adb快捷命令一覽表

歡迎大家關注,持續更新~ {droyon}

1、快速檢視SettingsProvider資料庫表資訊:

adb shell settings list [system][secure][global]

2、依據Name檢視SettingsProvider資料庫表格

adb shell settings get [system][secure][global] [Name]

3、依據Name向對應的資料庫中插入value

adb shell settings put  [system][secure][global] [Name] [Value]

4、檢視啟動頁面intent部分詳情以及確認請求部分詳情

adb logcat -v time -s "ActivityManager"

5、獲取包名對應的PMS資訊

adb shell dumpsys package {包名}

6、顯示當前展示頁面的資訊,可以用於確認啟動activity的包名等資訊

adb shell dumpsys window visible

7、顯示activity詳情

adb shell dumpsys activity com.android.settings/com.android.settings.Settings

8、顯示系統元件詳情

  • 8.1、顯示服務詳情
adb shell dumpsys activity service com
.android.settings/.SettingsDumpService
  • 8.2、顯示系統服務詳情
adb shell dumpsys notification
  • 8.3、顯示Provider服務詳情:
adb shell dumpsys activity provider 
com.android.providers.settings/com.android.providers.settings.SettingsProvider

9、抓取手指點選事件時間

adb logcat -v time -s InputDispatcher

輸出案例:

07-29
11:04:56.258 I/ViewRootImpl( 8295): finishMotionEvent: handled = true stage=10: View Post IME stage,inputElapseTime=2 eventTime = 68608867 downTime = 68608867 title= com.android.launcher3/com.android.launcher3.Launcher

10、輸出AMS intent請求資訊:

adb logcat -v time -s "ActivityManager"

輸出案例:

07-29 11:29:48.520 I/ActivityManager( 6692): START u0 {act=android.intent.action.MAIN 
cat=[android.intent.category.LAUNCHER] flg=0x10200000 
mCallingUid=10012 cmp=com.android.settings/.Settings bnds=[1056,1804][1392,2222] (has extras)} 
from uid 10012 on display 0

11、輸出頁面啟動時間

adb logcat -v time -s "ActivityManager" |grep Display

輸出案例:

07-29 11:18:16.557 I/ActivityManager( 1579): Displayed com.android.settings/.SubSettings: +299ms

12、開機嚮導不正常導致HOME鍵和返回鍵不可用修正方案:

adb shell settings  put global device_provisioned 1
adb shell settings  put secure user_setup_complete 1

13、獲得Intent請求來源以及activityResult目標詳細log資訊

[adb shell dumpsys activity a] [adb shell dumpsys activity]

adb shell dumpsys activity -d list

輸出案例:

ENABLE_THERMAL = true
0 . DEBUG_ALL = false
1 . DEBUG_BACKUP = false
2 . DEBUG_BROADCAST = false
3 . DEBUG_BROADCAST_LIGHT = false
4 . DEBUG_BROADCAST_BACKGROUND = false
5 . DEBUG_CLEANUP = false
6 . DEBUG_CONFIGURATION = false
7 . DEBUG_FOCUS = false
8 . DEBUG_IMMERSIVE = false
9 . DEBUG_LOCKSCREEN = false
10. DEBUG_LRU = false
11. DEBUG_MU = false
13. DEBUG_OOM_ADJ = false
14. DEBUG_PAUSE = false
15. DEBUG_POWER = false
16. DEBUG_POWER_QUICK = false
17. DEBUG_PROCESSES = false
18. DEBUG_PROCESS_OBSERVERS = false
19. DEBUG_PROVIDER = false
20. DEBUG_RESULTS = false
21. DEBUG_SERVICE = false
22. DEBUG_SERVICE_EXECUTING = false
23. DEBUG_STACK = true
24. DEBUG_SWITCH = true
25. DEBUG_TASKS = true
26. DEBUG_THUMBNAILS = false
27. DEBUG_TRANSITION = false
28. DEBUG_URI_PERMISSION = false
29. DEBUG_USER_LEAVING = false
30. DEBUG_VISIBILITY = false
31. DEBUG_PSS = false
32. DEBUG_RECENTS = false
33. DEBUG_THERMAL = false
34. DEBUG_ADD_REMOVE = false
35. DEBUG_APP = false
36. DEBUG_CONTAINERS = false
37. DEBUG_IDLE = false
38. DEBUG_RELEASE = false
39. DEBUG_SAVED_STATE = false
40. DEBUG_SCREENSHOTS = false
41. DEBUG_STATES = false
42. DEBUG_VISIBLE_BEHIND = false

可以選擇將如下三項開啟:

23. DEBUG_STACK = true
24. DEBUG_SWITCH = true
25. DEBUG_TASKS = true

那麼,使用如下命令抓取log資訊:

adb logcat -v time -s "ActivityManager"

log備註:

01-02 05:47:11.624 12182 13492 I ActivityManager: START u0 {mCallingUid=1000 cmp=com.android.settings/.ChooseLockPattern (has extras)} from uid 1000 on display 0
01-02 05:47:11.624 12182 13492 I ActivityManager: sourceRecord = ActivityRecord{82c19d8 u0 com.android.settings/.ChooseLockGeneric$InternalActivity, isShadow:false t3}
01-02 05:47:11.624 12182 13492 D ActivityManager: startActivityLocked skipCheckAccessControl = true
01-02 05:47:11.634 12182 13492 I ActivityManager: startActivityUnchecked mReusedActivity=null r=ActivityRecord{a5b9d3b u0 com.android.settings/.ChooseLockPattern, isShadow:false t-1}
01-02 05:47:11.636 12182 13492 V ActivityManager: Starting new activity ActivityRecord{a5b9d3b u0 com.android.settings/.ChooseLockPattern, isShadow:false t3} in existing task TaskRecord{9629e54 #3 A=com.android.settings, isShadow:false U=0 StackId=1 sz=4} from source ActivityRecord{82c19d8 u0 com.android.settings/.ChooseLockGeneric$InternalActivity, isShadow:false t3}

注意:SourceRecord = 開頭的字串

14、事件被消費:

adb logcat -v threadtime -s ViewRootImpl

可以看到如下log:

04-25 01:57:21.441 11173 11173 I ViewRootImpl: finishKeyEvent: handled = true keycode = 4 name=KEYCODE_BACK stage=10: View Post IME stage,inputElapseTime=4 eventTime = 4616876 downTime = 4616876 title= com.android.settings/com.android.settings.Settings
04-25 01:57:21.840  2920  2920 I ViewRootImpl: updateImmersive mode: gain focus

關注我的技術公眾號,檢視更多優質技術文章推送

微信掃一掃下方二維碼即可關注:

關注我的技術公眾號,檢視更多優質技術文章推送