Android 解读Event和Main Log

本文详细介绍了Android系统中EventLogTags的相关文件,包括不同组件的EventLogTags.logtags文件,如SystemServer和ActivityManagerService。重点讨论了screen_toggled事件,用于记录屏幕电源状态。同时提到了Key Log的使用,以及如何通过EventLog.writeEvent进行日志写入。此外,还列举了多个参考资源,帮助理解Android系统的日志分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 Android P EventLogTags文件

Android P 9.0.0 所有EventLogTags文件List:

system/bt/EventLogTags.logtags

system/core/liblog/event.logtags

system/core/libsysutils/EventLogTags.logtags

system/core/logcat/event.logtags

system/core/logd/LogTags.cpp

system/core/logd/event.logtags

system/core/storaged/EventLogTags.logtags

frameworks/base/core/java/android/app/admin/SecurityLogTags.logtags

frameworks/base/core/java/android/content/EventLogTags.logtags

frameworks/base/core/java/android/net/EventLogTags.logtags

frameworks/base/core/java/android/os/EventLogTags.logtags

frameworks/base/core/java/android/speech/tts/EventLogTags.logtags

frameworks/base/core/java/android/webkit/EventLogTags.logtags

frameworks/base/core/java/com/android/server/DropboxLogTags.logtags

frameworks/base/core/java/org/chromium/arc/EventLogTags.logtags

frameworks/ex/common/java/com/android/common/GoogleLogTags.logtags

frameworks/native/services/surfaceflinger/EventLog/EventLogTags.logtags

packages/apps/QuickSearchBox/src/com/android/quicksearchbox/EventLogTags.logtags

packages/apps/Settings/src/com/android/settings/EventLogTags.logtags

packages/services/Telephony/src/com/android/phone/EventLogTags.logtags

frameworks/base/core/java/com/android/internal/app/EventLogTags.logtags

frameworks/base/core/java/com/android/internal/logging/EventLogTags.logtags

frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/EventLogTags.logtags

frameworks/base/packages/SystemUI/src/com/android/systemui/EventLogTags.logtags

frameworks/base/services/core/java/com/android/server/EventLogTags.logtags

frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags

frameworks/opt/telephony/src/java/com/android/internal/telephony/EventLogTags.logtags

packages/apps/TimeZoneUpdater/src/main/com/android/timezone/updater/EventLogTags.logtags

packages/providers/CalendarProvider/src/com/android/providers/calendar/EventLogTags.logtags

packages/providers/ContactsProvider/src/com/android/providers/contacts/EventLogTags.logtags

 

2 Key Log

代码引用,通过关键字搜索“EventLog.writeEvent”

 

3 system/core/logcat/event.logtags

# Device boot timings.  We include monotonic clock values because the

# intrinsic event log times are wall-clock.

#

# Runtime starts:

3000 boot_progress_start (time|2|3)

# ZygoteInit class preloading starts:

3020 boot_progress_preload_start (time|2|3)

# ZygoteInit class preloading ends:

3030 boot_progress_preload_end (time|2|3)

......

# Dalvik VM / ART

20003 dvm_lock_sample (process|3),(main|1|5),(thread|3),(time|1|3),(file|3),(line|1|5),(ownerfile|3),(ownerline|1|5),(sample_percent|1|6)

......

# Database operation samples.

# db: the filename of the database

# sql: the executed query (without query args)

# time: cpu time millis (not wall time), including lock acquisition

# blocking_package: if this is on a main thread, the package name, otherwise ""

# sample_percent: the percent likelihood this query was logged

52000 db_sample (db|3),(sql|3),(time|1|3),(blocking_package|3),(sample_percent|1|6)

......

# 0 for screen off, 1 for screen on, 2 for key-guard done

70000 screen_toggled (screen_state|1|5)

3.1 screen_toggled:屏幕电源状态信息

其中 0 表示屏幕关闭,1 表示屏幕打开,2 表示已锁屏。

grep screen_toggled bugreport-2015-10-18-16-52-22.txt

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

 

4 tools/loganalysis/src/com/android/loganalysis/parser/DvmLockSampleParser.java

    /**

     * Matches the DVM lock sample log format:

     *

     * <p>09-04 05:40:07.809 1026 10592 I dvm_lock_sample:

     * [system_server,1,Binder:1026_F,46,NetworkPolicyManagerService.java,2284,-,802,9]

     */

    private static final Pattern LOG_CONTENTION_EVENT_PATTERN =

            Pattern.compile(

                    "\\["

                            + String.join(

                                    ",\\s*",

                                    Arrays.asList(

                                       NAME_REGEX, // Process name

                                            INT_REGEX, // Process sensitivity flag

                                            NAME_REGEX, // Waiting thread name

                                            INT_REGEX, // Wait time

                                            FILE_REGEX, // Waiting Source File

                                            INT_REGEX, // Waiting Source Line

                                            FILE_REGEX, // Owner File Name ("-" if the same)

                                            INT_REGEX, // Owner Acquire Source Line

                                            INT_REGEX // Sample Percentage

                                            ))

                            + "\\]");

5 frameworks/base/core/java/android/content/EventLogTags.logtags

option java_package android.content;

52002 content_query_sample (uri|3),(projection|3),(selection|3),(sortorder|3),(time|1|3),(blocking_package|3),(sample_percent|1|6)

52003 content_update_sample (uri|3),(operation|3),(selection|3),(time|1|3),(blocking_package|3),(sample_percent|1|6)

52004 binder_sample (descriptor|3),(method_num|1|5),(time|1|3),(blocking_package|3),(sample_percent|1|6)

6 frameworks/base/core/java/com/android/server/DropboxLogTags.logtags

# -----------------------------

# BootReceiver.java

# -----------------------------

81002 dropbox_file_copy (FileName|3),(Size|1),(Tag|3)

7 frameworks/ex/common/java/com/android/common/GoogleLogTags.logtags

#####

# Android Market

# @param changes Number of changes made to database in reconstruct

202001 vending_reconstruct (changes|1)

202901 transaction_event (data|3)

#####

# Google Services Framework

203001 sync_details (authority|3),(send|1|2),(recv|1|2),(details|3)

203002 google_http_request (elapsed|2|3),(status|1),(appname|3),(reused|1)

#####

# Google Talk Service

# This event is logged when GTalkService encounters important events

204001 gtalkservice (eventType|1)

# This event is logged for GTalk connection state changes. The status field is an int, but

# it really contains 4 separate values, each taking up a byte

#     (eventType << 24) + (connection state << 16) + (connection error << 8) + network state

204002 gtalk_connection (status|1)

# This event is logged when GTalk connection is closed.

# The status field is an int, but contains 2 different values, it's represented as

#

#     (networkType << 8) + connection error

#

# the possible error values are

#

# no_error=0, no_network=1, connection_failed=2, unknown_host=3, auth_failed=4,

# auth_expired=5, heart_beat_timeout=6, server_error=7, server_reject_rate_limiting=8, unknown=10

#

# duration is the connection duration.

204003 gtalk_conn_close (status|1),(duration|1)

# This event is logged for GTalk heartbeat resets

# interval_and_nt contains both the heartbeat interval and the network type, It's represented as

#     (networkType << 16) + interval

# interval is in seconds; network type can be 0 (mobile) or 1 (wifi); ip is the host ip addr.

204004 gtalk_heartbeat_reset (interval_and_nt|1),(ip|3)

# This event is logged when an Rmq v2 packet is sent or received.

204005 c2dm (packet_type|1),(persistent_id|3),(stream_id|1),(last_stream_id|1)

#####

# Google Login Service and Setup Wizard

# This event is for when communicating to the server times out during account setup

205001 setup_server_timeout

205002 setu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值