1. EventLog
在调试分析Android的过程中,比较常用的地查看EventLog,非常简洁明了地展现当前Activity各种状态,当然不至于此,比如还有window的信息。那么本文就列举以下am相关的tags含义。
本文涉及的源码类有EventLog.java, EventLogTags.java,另外tags格式的定义位于文件/system/etc/event-log-tags
。
如果在终端输入:
logcat -b events
那么会输出大量类似这样的信息:
06-01 13:44:55.518 7361 8289 I am_create_service: [0,111484394,.StatService,10094,7769]
06-01 13:44:55.540 7361 8343 I am_proc_bound: [0,3976,com.android.providers.calendar]
06-01 13:44:55.599 7361 8033 I am_create_service: [0,61349752,.UpdateService,10034,1351]
06-01 13:44:55.625 7361 7774 I am_destroy_service: [0,61349752,1351]
...
通过字面意思,就能得到不少信息量,比如am_create_service,创建service,但是后面括号中内容的具体含义,其实有很高的价值。 接下来通过一张表格来展示含义。
Tag含义
Num | TagName | 格式 | 功能 |
---|---|---|---|
30001 | am_finish_activity | User,Token,TaskID,ComponentName,Reason | |
30002 | am_task_to_front | User,Task | |
30003 | am_new_intent | User,Token,TaskID,ComponentName,Action,MIMEType,URI,Flags | |
30004 | am_create_task | User ,Task ID | |
30005 | am_create_activity | User ,Token ,TaskID ,ComponentName,Action,MIMEType,URI,Flags | |
30006 | am_restart_activity | User ,Token ,TaskID,ComponentName | |
30007 | am_resume_activity | User ,Token ,TaskID,ComponentName | |
30008 | am_anr | User ,pid ,Package Name,Flags ,reason | ANR |
30009 | am_activity_launch_time | User ,Token ,ComponentName,time | |
30010 | am_proc_bound | User ,PID ,ProcessName | |
30011 | am_proc_died | User ,PID ,ProcessName | |
30012 | am_failed_to_pause | User ,Token ,Wanting to pause,Currently pausing | |
30013 | am_pause_activity | User ,Token ,ComponentName | |
30014 | am_proc_start | User ,PID ,UID ,ProcessName,Type,Component | |
30015 | am_proc_bad | User ,UID ,ProcessName | |
30016 | am_proc_good | User ,UID ,ProcessName | |
30017 | am_low_memory | NumProcesses | Lru |
30018 | am_destroy_activity | User ,Token ,TaskID,ComponentName,Reason | |
30019 | am_relaunch_resume_activity | User ,Token ,TaskID,ComponentName | |
30020 | am_relaunch_activity | User ,Token ,TaskID,ComponentName | |
30021 | am_on_paused_called | User ,ComponentName | |
30022 | am_on_resume_called | User ,ComponentName | |
30023 | am_kill | User ,PID ,ProcessName,OomAdj ,Reason | 杀进程 |
30024 | am_broadcast_discard_filter | User ,Broadcast ,Action,ReceiverNumber,BroadcastFilter | |
30025 | am_broadcast_discard_app | User ,Broadcast ,Action,ReceiverNumber,App | |
30030 | am_create_service | User ,ServiceRecord ,Name,UID ,PID | |
30031 | am_destroy_service | User ,ServiceRecord ,PID | |
30032 | am_process_crashed_too_much | User ,Name,PID | |
30033 | am_drop_process | PID | |
30034 | am_service_crashed_too_much | User ,Crash Count,ComponentName,PID | |
30035 | am_schedule_service_restart | User ,ComponentName,Time | |
30036 | am_provider_lost_process | User ,Package Name,UID ,Name | |
30037 | am_process_start_timeout | User ,PID ,UID ,ProcessName | timeout |
30039 | am_crash | User ,PID ,ProcessName,Flags ,Exception,Message,File,Line | Crash |
30040 | am_wtf | User ,PID ,ProcessName,Flags ,Tag,Message | Wtf |
30041 | am_switch_user | id | |
30042 | am_activity_fully_drawn_time | User ,Token ,ComponentName,time | |
30043 | am_focused_activity | User ,ComponentName | |
30044 | am_home_stack_moved | User ,To Front ,Top Stack Id ,Focused Stack Id ,Reason | |
30045 | am_pre_boot | User ,Package | |
30046 | am_meminfo | Cached,Free,Zram,Kernel,Native | 内存 |
30047 | am_pss | Pid, UID, ProcessName, Pss, Uss | 进程 |
下面列举tag可能使用的部分场景:
- am_low_memory:位于AMS.killAllBackgroundProcesses或者AMS.appDiedLocked,记录当前Lru进程队列长度。
- am_pss:位于AMS.applyOomAdjLocked或者AMS.requestPssLocked
- am_meminfo:位于AMS.dumpApplicationMemoryUsage
- am_proc_start:位于AMS.startProcessLocked,启动进程
- am_proc_bound:位于AMS.attachApplicationLocked
- am_kill: 位于ProcessRecord.kill,杀掉进程
- am_anr: 位于AMS.appNotResponding
- am_crash:位于AMS.handleApplicationCrashInner
- am_wtf:位于AMS.handleApplicationWtf
- am_activity_launch_time:位于ActivityRecord.reportLaunchTimeLocked(),后面两个参数分别是thisTime和 totalTime
- am_activity_fully_drawn_time:位于ActivityRecord.reportFullyDrawnLocked, 后面两个参数分别是thisTime和 totalTime
- am_broadcast_discard_filter:位于BroadcastQueue.logBroadcastReceiverDiscardLocked
- am_broadcast_discard_app:位于BroadcastQueue.logBroadcastReceiverDiscardLocked