Android -- eventlogs

原创 2018年04月15日 12:12:51

准备工作:

    Android7.1.2-r1源码,并编译。

疑问:

    frameworks/base/Android.mk:

    framework_res_source_path := APPS/framework-res_intermediates/src

        => out/target/common/obj/APPS/framework-res_intermediates/

    在frameworks/base的源码中看到几个很奇怪的EventLogTags.logtags文件,在Android.mk作为src参与编译,记录如下:

    # EventLogTags files.
    LOCAL_SRC_FILES += \
       core/java/android/app/admin/SecurityLogTags.logtags \
       core/java/android/content/EventLogTags.logtags \
       core/java/android/speech/tts/EventLogTags.logtags \
       core/java/android/webkit/EventLogTags.logtags \
       core/java/com/android/internal/logging/EventLogTags.logtags \

    于是简单的搜索下logtags格式的文件:

    ~/fu/workdir/android-7.1.2_r1$ find frameworks/ -name EventLogTags.logtags

frameworks/native/services/surfaceflinger/EventLog/EventLogTags.logtags
frameworks/opt/telephony/src/java/com/android/internal/telephony/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/core/java/com/android/internal/logging/EventLogTags.logtags
frameworks/base/core/java/android/content/EventLogTags.logtags
frameworks/base/core/java/android/webkit/EventLogTags.logtags
frameworks/base/core/java/android/speech/tts/EventLogTags.logtags
frameworks/base/services/core/java/com/android/server/EventLogTags.logtags
frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags

随便打开一个文件,发现开头第一句都是:

# See system/core/logcat/event.logtags for a description of the format of this file.

于是,打开system/core/logcat/event.logtags:

里面有logcat时的提示信息的格式:

# The data type is a number from the following values:
# 1: int
# 2: long
# 3: string
# 4: list
# 5: float
#
# The data unit is a number taken from the following list:
# 1: Number of objects
# 2: Number of bytes
# 3: Number of milliseconds
# 4: Number of allocations
# 5: Id
# 6: Percent

# Default value for data of type int/long is 2 (bytes).

举例:

以frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java为例,其中EventLogTags.SYSUI_STATUSBAR_TOUCH:

    public boolean interceptTouchEvent(MotionEvent event) {
        if (DEBUG_GESTURES) {
            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
                EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH,
                        event.getActionMasked(), (int) event.getX(), (int) event.getY(),
                        mDisabled1, mDisabled2);
            }

        }

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

# ---------------------------
# PhoneStatusBar.java
# ---------------------------

36000 sysui_statusbar_touch (type|1),(x|1),(y|1),(disable1|1),(disable2|1)

找到其编译出来的java文件:

out/target/common/obj/JAVA_LIBRARIES/SystemUI-proto-tags_intermediates/src/src/com/android/systemui/EventLogTags.java

public class EventLogTags {
  private EventLogTags() { }  // don't instantiate

  /** 36000 sysui_statusbar_touch (type|1),(x|1),(y|1),(disable1|1),(disable2|1) */
  public static final int SYSUI_STATUSBAR_TOUCH = 36000;

那么,如何将logtags编译为java文件了?build/tools/java-event-log-tags.py这个文件就是干这个事情的,负责将EventLogTags.logtags转化为java文件,或者是将java文件中的writeEvent调用转为标准的java调用,以及生成system/etc/event-log-tags文件。

out/target/product/generic_arm64/system/etc/event-log-tags里面包含了所有的信息格式:Tagid,type,unit

至于怎么转换的,要研究下这个py脚本。

我这里只是大概流程,有篇文章比较详细,里面包括logcat的信息:https://blog.csdn.net/js_wawayu/article/details/53398701

如何找到?JAVATAGS

A:~/fu/workdir/android-7.1.2_r1$ grep -nr "JAVATAGS" build/
    build/core/definitions.mk:1139:$(hide) $(JAVATAGS) -o $@ $^
    build/core/config.mk:564:JAVATAGS := build/tools/java-event-log-tags.py
    打开文件build/core/definitions.mk
###########################################################
## Commands for running java-event-log-tags.py
###########################################################

define transform-logtags-to-java
@mkdir -p $(dir $@)
@echo "logtags: $@ <= $<"
$(hide) $(JAVATAGS) -o $@ $^

endef

B: ~/fu/workdir/android-7.1.2_r1$ grep -nr "transform-logtags-to-java" build/
build/core/definitions.mk:1136:define transform-logtags-to-java
build/core/java.mk:371:    $(transform-logtags-to-java)
打开文件build/core/java.mk

$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt

    $(transform-logtags-to-java)       

就是这里,,,

~/fu/workdir/android-7.1.2_r1$ find out/ -name all-event-log-tags.txt

out/target/common/obj/all-event-log-tags.txt

你会发现:

out/target/product/generic_arm64/system/etc/event-log-tags与out/target/common/obj/all-event-log-tags.txt完全相同。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shentong1/article/details/79947893
收藏助手
不良信息举报
您举报文章:Android -- eventlogs
举报原因:
原因补充:

(最多只允许输入30个字)