Android EventLog含义

一. 概述

在调试分析Android的过程中,比较常用的地查看EventLog,非常简洁明了地展现当前Activity各种状态,当然不至于此,比如还有window的信息。那么本文就列举以下am相关的tags含义。

本文涉及的源码类有EventLog.java, EventLogTags.java,另外tags格式的定义位于文件/system/etc/event-log-tags

如果在终端输入:

那么会输出大量类似这样的信息:

通过字面意思,就能得到不少信息量,比如am_create_service,创建service,但是后面括号中内容的具体含义,其实有很高的价值。 接下来通过一张表格来展示含义。

二. EventLog

2.1 AM

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

2.2 Power

Num TagName 格式 功能
2722 battery_level level, voltage, temperature
2723 battery_status status,health,present,plugged,technology
2730 battery_discharge duration, minLevel,maxLevel
2724 power_sleep_requested wakeLocksCleared 唤醒锁数量
2725 power_screen_broadcast_send wakelockCount
2726 power_screen_broadcast_done on, broadcastDuration, wakelockCount
2727 power_screen_broadcast_stop which,wakelockCount 系统还没进入ready状态
2728 power_screen_state offOrOn, becauseOfUser, totalTouchDownTime, touchCycles
2729 power_partial_wake_state releasedorAcquired, tag

battery_level: [19,3660,352] //剩余电量19%, 电池电压3.66v, 电池温度35.2℃ power_screen_state: [0,3,0,0] // 灭屏状态(0), 屏幕超时(3). 当然还有其他设备管理策略(1),其他理由都为用户行为(2) power_screen_state: [1,0,0,0] // 亮屏状态(1),

下面列举tag可能使用的部分场景

  • power_sleep_requested: 位于PMS.goToSleepNoUpdateLocked
  • power_screen_state:位于Notifer.handleEarlyInteractiveChange, handleLateInteractiveChange

2.3 Notification

|Num|TagName|格式|功能| |—|—|—|

三. EventLog完整语义分析

在源码EventLogTags.java中,有大量类似的定义,那么括号中数字是什么含义呢? (以进程启动为例)

格式:

数据类型:

  • 1: int
  • 2: long
  • 3: string
  • 4: list

数据类型中int和string用得最多.

数据单位:

  • 1: Number of objects(对象个数)
  • 2: Number of bytes(字节数)
  • 3: Number of milliseconds(毫秒)
  • 4: Number of allocations(分配个数)
  • 5: Id
  • 6: Percent(百分比)

实例解析:

含义 ==> 进程启动: pid=9227,uid=10002, 进程名=com.android.browser, 类型ContentProvider,相应组件=com.android.browser/.provider.BrowserProvider2

作者微博:@Gityuan

原文出处:Gityuan.com

1 收藏 评论

关于作者:gityuan

Android系统工程师,www.gityuan.com博主,个人新浪微博:http://weibo.com/gityuan 个人主页 · 我的文章 · 3 ·     

可能感兴趣的话题



直接登录
跳到底部
返回顶部