作者:Android那些事儿
链接:https://www.jianshu.com/p/a393686aa86c
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
adb shell settings list [system][secure][global]
adb shell settings get [system][secure][global] [Name]
adb shell settings put [system][secure][global] [Name] [Value]
adb logcat -v time -s "ActivityManager"
adb shell dumpsys package {包名}
adb shell dumpsys window visible
adb shell dumpsys activity com.android.settings/com.android.settings.Settings
adb shell dumpsys activity service com.android.settings/.SettingsDumpService
adb shell dumpsys notification
adb shell dumpsys activity provider
com.android.providers.settings/com.android.providers.settings.SettingsProvider
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
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
adb logcat -v time -s "ActivityManager" |grep Display
输出案例:
07-29 11:18:16.557 I/ActivityManager( 1579): Displayed com.android.settings/.SubSettings: +299ms
adb shell settings put global device_provisioned 1
adb shell settings put secure user_setup_complete 1
[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 = 开头的字串
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