adb logcat -b events > eventlog
1. 查看前台activity
adb logcat -b events -s am_on_resume_called
Android R 11
screen_toggled:屏幕电源状态信息
其中 0 表示屏幕关闭,1 表示屏幕打开,2 表示已锁屏。
10-18 15:05:04.383 992 992 I screen_toggled: 1
10-18 15:05:07.010 992 992 I screen_toggled: 0
10-18 15:23:15.063 992 992 I screen_toggled: 1
10-18 15:23:25.684 992 992 I screen_toggled: 0
10-18 15:36:31.623 992 992 I screen_toggled: 1
10-18 15:36:37.660 3283 3283 I screen_toggled: 2
状态栏没有下拉:
04-27 15:20:57.639 1098 6137 I notification_panel_hidden:
下拉状态栏完全展开:
04-27 15:21:45.970 1098 11208 I notification_panel_revealed: 5
Back按键:
KEYCODE_BACK = 4
04-27 15:28:23.540 1393 1393 I sysui_multi_action: [757,931,758,4,759,4,932,0,933,0] // 最后的0是按下
04-27 15:28:23.542 1098 5988 I sysui_multi_action: [757,803,799,key_back_down,802,1] // 按下
04-27 15:28:23.600 1393 1393 I sysui_multi_action: [757,931,758,4,759,4,932,0,933,1] // 最后的1是抬起
04-27 15:28:23.605 1098 5988 I sysui_multi_action: [757,803,799,key_back_up,802,1] // 抬起
HOME按键:
KEYCODE_BACK = 3
04-27 15:24:04.764 1393 1393 I sysui_multi_action: [757,931,758,4,759,3,932,0,933,0] // 按下
04-27 15:24:04.853 1393 1393 I sysui_multi_action: [757,931,758,4,759,3,932,0,933,1] // 抬起
Power按键:
04-27 21:27:05.063 1098 1315 I intercept_power: [ACTION_DOWN,1,0] // 按下
04-27 21:27:05.081 1098 1098 I screen_toggled: 1 // 屏幕打开
04-27 21:27:05.164 1098 1315 I intercept_power: [ACTION_UP,1,0] // 抬起
04-27 21:27:05.063 1098 1315 I intercept_power: [ACTION_DOWN,1,0] 04-27 21:27:05.070 1098 1315 I sysui_multi_action: [757,804,799,power_consecutive_short_tap_count,801,1,802,1] 04-27 21:27:05.071 1098 1315 I sysui_multi_action: [757,804,799,power_double_tap_interval,801,36601,802,1] 04-27 21:27:05.081 1098 1098 I screen_toggled: 1 04-27 21:27:05.084 1098 1098 I power_screen_broadcast_send: 1 04-27 21:27:05.134 483 483 I auditd : type=1400 audit(0.0:1147): avc: denied { read } for comm="Binder:483_2" name="wakeup17" dev="sysfs" ino=42494 scontext=u:r:system_suspend:s0 tcontext=u:object_r:sysfs:s0 tclass=dir permissive=0 04-27 21:27:05.145 1098 1276 I dvm_lock_sample: [system_server,1,Binder:1098_3,55,BatteryStatsService.java,590,void com.android.server.am.BatteryStatsService.noteStartSensor(int, int),BatteryExternalStatsWorker.java,508,void com.android.server.am.BatteryExternalStatsWorker.updateExternalStatsLocked(java.lang.String, int, boolean, boolean, boolean),11] 04-27 21:27:05.157 1098 1176 I sysui_multi_action: [757,1696,758,6,759,3] 04-27 21:27:05.164 1098 1315 I intercept_power: [ACTION_UP,1,0] 04-27 21:27:05.176 1098 1276 I sysui_multi_action: [757,127,758,1] 04-27 21:27:05.177 1098 1276 I sysui_multi_action: [757,804,799,note_load,801,5,802,1] 04-27 21:27:05.178 1098 1276 I notification_panel_revealed: 5
桌面点击计算器图标后的启动过程
计算器包名:com.google.android.calculator
桌面:com.android.launcher3
两个进程的log依次交叉出现的:
04-27 15:41:15.080 1098 9807 I wm_task_created: [100,-1] 04-27 15:41:15.081 1098 9807 I wm_stack_created: 100 04-27 15:41:15.087 1098 9807 I wm_create_task: [0,100] 04-27 15:41:15.087 1098 9807 I wm_create_activity: [0,33776883,100,com.google.android.calculator/com.android.calculator2.Calculator,android.intent.action.MAIN,NULL,NULL,270532608] 04-27 15:41:15.089 1098 9807 I wm_pause_activity: [0,42862506,com.android.launcher3/com.android.searchlauncher.SearchLauncher,userLeaving=true] 04-27 15:41:15.095 1913 1913 I wm_on_top_resumed_lost_called: [42862506,com.android.searchlauncher.SearchLauncher,topStateChangedWhenResumed] 04-27 15:41:15.095 1913 1913 I wm_on_paused_called: [42862506,com.android.searchlauncher.SearchLauncher,performPause] 04-27 15:41:15.096 1098 2225 I wm_add_to_stopping: [0,42862506,com.android.launcher3/com.android.searchlauncher.SearchLauncher,makeInvisible] 04-27 15:41:15.101 1098 1119 I am_uid_running: 10158 04-27 15:41:15.104 1098 1119 I sysui_multi_action: [757,803,799,window_time_0,802,6] 04-27 15:41:15.116 1098 1127 I am_proc_start: [0,17121,10158,com.google.android.calculator,pre-top-activity,{com.google.android.calculator/com.android.calculator2.Calculator}] 04-27 15:41:15.124 1098 1120 I service_manager_stats: [100,87,782092] 04-27 15:41:15.130 1098 5301 I am_proc_bound: [0,17121,com.google.android.calculator] 04-27 15:41:15.133 1098 5301 I wm_restart_activity: [0,33776883,100,com.google.android.calculator/com.android.calculator2.Calculator] 04-27 15:41:15.134 1098 5301 I wm_set_resumed_activity: [0,com.google.android.calculator/com.android.calculator2.Calculator,minimalResumeActivityLocked] 04-27 15:41:15.144 1098 9807 I am_uid_active: 10158 04-27 15:41:15.315 17121 17121 I wm_on_create_called: [33776883,com.android.calculator2.Calculator,performCreate] 04-27 15:41:15.318 17121 17121 I wm_on_start_called: [33776883,com.android.calculator2.Calculator,handleStartActivity] 04-27 15:41:15.330 17121 17121 I wm_on_resume_called: [33776883,com.android.calculator2.Calculator,RESUME_ACTIVITY] 04-27 15:41:15.340 17121 17121 I wm_on_top_resumed_gained_called: [33776883,com.android.calculator2.Calculator,topStateChangedWhenResumed] 04-27 15:41:15.465 1098 1120 I sysui_multi_action: [324,0,757,1090,758,12,806,com.google.android.calculator,871,com.android.calculator2.Calculator,1091,388] 04-27 15:41:15.468 1098 1125 I sysui_multi_action: [319,63,321,54,322,388,325,14230,757,761,758,7,759,1,806,com.google.android.calculator,871,com.android.calculator2.Calculator,904,com.android.launcher3,905,0,945,55,1320,8,1321,5] 04-27 15:41:15.471 1098 1125 I wm_activity_launch_time: [0,33776883,com.google.android.calculator/com.android.calculator2.Calculator,388] 04-27 15:41:15.588 1098 1119 I wm_stop_activity: [0,42862506,com.android.launcher3/com.android.searchlauncher.SearchLauncher] 04-27 15:41:15.596 1913 1913 I wm_on_stop_called: [42862506,com.android.searchlauncher.SearchLauncher,STOP_ACTIVITY_ITEM]
总结:
com.google.android.calculator 进程启动时,依次显示的log:
wm_create_activity
am_proc_start
am_proc_bound
wm_restart_activity
wm_set_resumed_activity
wm_on_create_called
wm_on_start_called
wm_on_resume_called
wm_on_top_resumed_gained_called
wm_activity_launch_time
com.android.launcher3 进程启动时,依次显示的log:
wm_pause_activity
wm_on_top_resumed_lost_called
wm_on_paused_called
wm_add_to_stopping
wm_stop_activity
wm_on_stop_called
查看进程号:
从最近任务栏手动移除计算器,依次显示的log:
04-27 15:58:53.905 1098 2234 I wm_finish_activity: [0,33776883,100,com.google.android.calculator/com.android.calculator2.Calculator,remove-task]
04-27 15:58:53.906 1098 2234 I wm_destroy_activity: [0,33776883,100,com.google.android.calculator/com.android.calculator2.Calculator,finish-imm:finishIfPossible]
04-27 15:58:53.911 17121 17121 I wm_on_destroy_called: [33776883,com.android.calculator2.Calculator,performDestroy]
04-27 15:58:53.926 1098 1119 I am_kill : [0,17121,com.google.android.calculator,915,remove task]
04-27 15:58:53.928 1098 1119 I sysui_multi_action: [757,803,799,window_time_0,802,3]
04-27 15:58:54.011 1098 2234 I am_proc_died: [0,17121,com.google.android.calculator,915,19]