Android 解读main log和event log日志信息

原创 2016年09月22日 13:17:03
ENV:Android M 6.0.1

一 分析main log

1.1 通过adb logcat输出的main log文件,每一行都是以如下格式作为开头信息

格式:timestamp PID TID log-level log-tag

eg:
zhanghu@winth:~$ adb logcat -d
09-19 10:46:21.243 3358 3446 D WindowManager: send fingerprint nav broadcast
09-19 10:46:21.244 3358 3445 I ActivityManager: isCurrentInputMethod = false ,alive = true ,restrict = false
09-19 10:46:21.248 6744 6744 D NavigationKeycodeReceiver: action =android.intent.action.FINGERPRINT_NAVIGATION
09-19 10:46:21.248 6744 6744 D NavigationKeycodeReceiver: mNavigationExtra = extra_single_click,mTopPkgName = null

2.2 main log分类

系统根据log类型,分为main,radio,events,system,crash
frameworks/base/core/java/android/util/Log.java //用于记录main log
frameworks/base/core/java/android/util/Slog.java //用于记录framework log
frameworks/base/telephony/java/android/telephony/Rlog.java //用于记录radio log
frameworks/base/core/java/com/android/internal/os/RuntimeInit.java //内部记录了crash log

看下RuntimeInit.java类捕获应用异常的实现:
/**
 * Main entry point for runtime initialization.  Not for
 * public consumption.
 * @hide
 */

public class RuntimeInit {
    private final static String TAG = "AndroidRuntime";
    private final static boolean DEBUG = false;

    /** true if commonInit() has been called */
    private static boolean initialized;

    private static IBinder mApplicationObject;

    private static volatile boolean mCrashing = false;

    private static final native void nativeZygoteInit();
    private static final native void nativeFinishInit();
    private static final native void nativeSetExitWithoutCleanup(boolean exitWithoutCleanup);

    private static int Clog_e(String tag, String msg, Throwable tr) {
        return Log.println_native(Log.LOG_ID_CRASH, Log.ERROR, tag,
                msg + '\n' + Log.getStackTraceString(tr));
    }

    /**
     * Use this to log a message when a thread exits due to an uncaught
     * exception.  The framework catches these for the main threads, so
     * this should only matter for threads created by applications.
     */

    private static class UncaughtHandler implements Thread.UncaughtExceptionHandler {
        public void uncaughtException(Thread t, Throwable e) {
            try {
                // Don't re-enter -- avoid infinite loops if crash-reporting crashes.
                if (mCrashing) return;
                mCrashing = true;

                if (mApplicationObject == null) {
                    Clog_e(TAG, "*** FATAL EXCEPTION IN SYSTEM PROCESS: " + t.getName(), e);
                } else {
                    StringBuilder message = new StringBuilder();
                    message.append("FATAL EXCEPTION: ").append(t.getName()).append("\n");
                    final String processName = ActivityThread.currentProcessName();
                    if (processName != null) {
                        message.append("Process: ").append(processName).append(", ");
                    }
                    message.append("PID: ").append(Process.myPid());
                    Clog_e(TAG, message.toString(), e);
                }

                // Bring up crash dialog, wait for it to be dismissed
                ActivityManagerNative.getDefault().handleApplicationCrash(
                        mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
            } catch (Throwable t2) {
                try {
                    Clog_e(TAG, "Error reporting crash", t2);
                } catch (Throwable t3) {
                    // Even Clog_e() fails!  Oh well.
                }
            } finally {
                // Try everything to make sure this process goes away.
                Process.killProcess(Process.myPid());
                System.exit(10);
            }
        }
    }

    private static final void commonInit() {
        if (DEBUG) Slog.d(TAG, "Entered RuntimeInit!");

        /* set default handler; this applies to all threads in the VM */
        Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
        ......
    }
    
    ......
}


应用异常终止时出现的 FATAL EXCEPTION 关键字就是在上面uncaughtException函数内输出的,如:
09-19 16:55:37.697  8771  8771 E AndroidRuntime: FATAL EXCEPTION: main
09-19 16:55:37.697  8771  8771 E AndroidRuntime: Process: com.android.systemui, PID: 8771
09-19 16:55:37.697  8771  8771 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'long com.android.internal.widget.ILockSettings.getLong(java.lang.String, long, int)' on a null object reference
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.internal.widget.LockPatternUtils.getLong(LockPatternUtils.java:1123)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.internal.widget.LockPatternUtils.getLockoutAttemptDeadline(LockPatternUtils.java:1085)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.keyguard.KeyguardUpdateMonitor.hasFailedUnlockAttemptLockout(KeyguardUpdateMonitor.java:2139)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.keyguard.KeyguardUpdateMonitor.startListeningForFingerprint(KeyguardUpdateMonitor.java:1220)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.keyguard.KeyguardUpdateMonitor.updateFingerprintListeningState(KeyguardUpdateMonitor.java:1205)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.keyguard.KeyguardUpdateMonitor.onKeyguardVisibilityChanged(KeyguardUpdateMonitor.java:1588)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.updateStates(StatusBarKeyguardViewManager.java:471)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.reset(StatusBarKeyguardViewManager.java:163)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.setOccluded(StatusBarKeyguardViewManager.java:237)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.systemui.keyguard.KeyguardViewMediator.handleSetOccluded(KeyguardViewMediator.java:1006)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.systemui.keyguard.KeyguardViewMediator.access$3300(KeyguardViewMediator.java:139)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.systemui.keyguard.KeyguardViewMediator$4.handleMessage(KeyguardViewMediator.java:1307)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:102)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at android.os.Looper.loop(Looper.java:148)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:5429)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at java.lang.reflect.Method.invoke(Native Method)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
09-19 16:55:37.697  8771  8771 E AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
......


过滤输出指定类型的log
zhanghu@winth:~$ adb logcat --help
Usage: logcat [options] [filterspecs]
options include:
......
-b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',
'events', 'crash' or 'all'. Multiple -b parameters are
allowed and results are interleaved. The default is
-b main -b system -b crash.
......
eg:
zhanghu@winth:~$ adb logcat -b main 
zhanghu@winth:~$ adb logcat -b radio
zhanghu@winth:~$ adb logcat -b system

博客原文:http://blog.csdn.net/yelangjueqi/article/details/52621903

二 分析event log

2.1 event log输出格式

通过adb logcat输出的event log文件,每一行都是以如下格式作为开头信息
格式:timestamp PID TID log-level log-tag tag-values
Log levels include the following:
V: verbose
D: debug
I: information
W: warning
E: error

eg:
zhanghu@winth:~$ adb logcat -b events -d 
09-19 10:47:24.111 3358 4026 I am_focused_activity: [0,com.android.launcher3/.Launcher]
09-19 10:47:24.132 3358 4026 I am_pause_activity: [0,98033839,com.android.settings/.Settings]
09-19 10:47:24.133 14252 14252 I sysui_view_visibility: [35,0]
09-19 10:47:24.135 3358 4026 I am_task_to_front: [0,1]
09-19 10:47:24.135 3358 4026 I am_new_intent: [0,214536308,1,com.android.launcher3/.Launcher,android.intent.action.MAIN,NULL,NULL,274726912]
09-19 10:47:24.140 14252 14252 I sysui_view_visibility: [1,0]

system/core/logcat/event.logtags
# The entries in this file map a sparse set of log tag numbers to tag names.
# This is installed on the device, in /system/etc, and parsed by logcat.
#
# Tag numbers are decimal integers, from 0 to 2^31.  (Let's leave the
# negative values alone for now.)
#
# Tag names are one or more ASCII letters and numbers or underscores, i.e.
# "[A-Z][a-z][0-9]_".  Do not include spaces or punctuation (the former
# impacts log readability, the latter makes regex searches more annoying).
#
# Tag numbers and names are separated by whitespace.  Blank lines and lines
# starting with '#' are ignored.
#
# Optionally, after the tag names can be put a description for the value(s)
# of the tag. Description are in the format
#    (<name>|data type[|data unit])
# Multiple values are separated by commas.
#
# 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).
#
# TODO: generate ".java" and ".h" files with integer constants from this file.

# These are used for testing, do not modify without updating
# tests/framework-tests/src/android/util/EventLogFunctionalTest.java.
42    answer (to life the universe etc|3)
314   pi
2718  e

# "account" is the java hash of the account name
2720 sync (id|3),(event|1|5),(source|1|5),(account|1|5)

# This event is logged when the location service uploads location data.
2740 location_controller
# This event is logged when someone is deciding to force a garbage collection
2741 force_gc (reason|3)
# This event is logged on each tickle
2742 tickle (authority|3)

# contacts aggregation: time and number of contacts.
# count is negative for query phase, positive for merge phase
2747 contacts_aggregation (aggregation time|2|3), (count|1|1)

# 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
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)

75000 sqlite_mem_alarm_current (current|1|2)
75001 sqlite_mem_alarm_max (max|1|2)
75002 sqlite_mem_alarm_alloc_attempt (attempts|1|4)
75003 sqlite_mem_released (Memory released|1|2)
75004 sqlite_db_corrupt (Database file corrupt|3)

50000 menu_item_selected (Menu type where 0 is options and 1 is context|1|5),(Menu item title|3)
50001 menu_opened (Menu type where 0 is options and 1 is context|1|5)

# HSM wifi state change
# Hierarchical state class name (as defined in WifiStateTracker.java)
# Logged on every state change in the hierarchical state machine
50021 wifi_state_changed (wifi_state|3)
# HSM wifi event
# [31-16] Reserved for future use
# [15 - 0] HSM event (as defined in WifiStateTracker.java)
# Logged when an event is handled in a hierarchical state
50022 wifi_event_handled (wifi_event|1|5)
# Supplicant state change
# [31-13] Reserved for future use
# [8 - 0] Supplicant state (as defined in SupplicantState.java)
# Logged when the supplicant switches to a new state
50023 wifi_supplicant_state_changed (supplicant_state|1|5)

# 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)

# http request/response stats
52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2)
60000 viewroot_draw (Draw time|1|3)
60001 viewroot_layout (Layout time|1|3)
60002 view_build_drawing_cache (View created drawing cache|1|5)
60003 view_use_drawing_cache (View drawn using bitmap cache|1|5)

# graphics timestamp
# 60100 - 60199 reserved for surfaceflinger

# 0 for screen off, 1 for screen on, 2 for key-guard done
70000 screen_toggled (screen_state|1|5)

# aggregation service
70200 aggregation (aggregation time|2|3)
70201 aggregation_test (field1|1|2),(field2|1|2),(field3|1|2),(field4|1|2),(field5|1|2)

# libc failure logging
80100 bionic_event_memcpy_buffer_overflow (uid|1)
80105 bionic_event_strcat_buffer_overflow (uid|1)
80110 bionic_event_memmov_buffer_overflow (uid|1)
80115 bionic_event_strncat_buffer_overflow (uid|1)
80120 bionic_event_strncpy_buffer_overflow (uid|1)
80125 bionic_event_memset_buffer_overflow (uid|1)
80130 bionic_event_strcpy_buffer_overflow (uid|1)

80200 bionic_event_strcat_integer_overflow (uid|1)
80205 bionic_event_strncat_integer_overflow (uid|1)

80300 bionic_event_resolver_old_response (uid|1)
80305 bionic_event_resolver_wrong_server (uid|1)
80310 bionic_event_resolver_wrong_query (uid|1)

# libcore failure logging
90100 exp_det_cert_pin_failure (certs|4)

1397638484 snet_event_log (subtag|3) (uid|1) (message|3)

# NOTE - the range 1000000-2000000 is reserved for partners and others who
# want to define their own log tags without conflicting with the core platform.



frameworks/base/services/core/java/com/android/server/EventLogTags.logtags
# See system/core/logcat/event.logtags for a description of the format of this file.

option java_package com.android.server

# ---------------------------
# BatteryService.java
# ---------------------------
2722 battery_level (level|1|6),(voltage|1|1),(temperature|1|1)
2723 battery_status (status|1|5),(health|1|5),(present|1|5),(plugged|1|5),(technology|3)
# This is logged when battery goes from discharging to charging.
# It lets us count the total amount of time between charges and the discharge level
2730 battery_discharge (duration|2|3),(minLevel|1|6),(maxLevel|1|6)


# ---------------------------
# PowerManagerService.java
# ---------------------------
# This is logged when the device is being forced to sleep (typically by
# the user pressing the power button).
2724 power_sleep_requested (wakeLocksCleared|1|1)
# This is logged when the screen on broadcast has completed
2725 power_screen_broadcast_send (wakelockCount|1|1)
# This is logged when the screen broadcast has completed
2726 power_screen_broadcast_done (on|1|5),(broadcastDuration|2|3),(wakelockCount|1|1)
# This is logged when the screen on broadcast has completed
2727 power_screen_broadcast_stop (which|1|5),(wakelockCount|1|1)
# This is logged when the screen is turned on or off.
2728 power_screen_state (offOrOn|1|5),(becauseOfUser|1|5),(totalTouchDownTime|2|3),(touchCycles|1|1)
# This is logged when the partial wake lock (keeping the device awake
# regardless of whether the screen is off) is acquired or released.
2729 power_partial_wake_state (releasedorAcquired|1|5),(tag|3)

#
# Leave IDs through 2739 for more power logs (2730 used by battery_discharge above)
#


# ---------------------------
# DeviceStorageMonitorService.java
# ---------------------------
# The disk space free on the /data partition, in bytes
2744 free_storage_changed (data|2|2)
# Device low memory notification and disk space free on the /data partition, in bytes at that time
2745 low_storage (data|2|2)
# disk space free on the /data, /system, and /cache partitions in bytes
2746 free_storage_left (data|2|2),(system|2|2),(cache|2|2)
# file on cache partition was deleted
2748 cache_file_deleted (path|3)


# ---------------------------
# NotificationManagerService.java
# ---------------------------
# when a NotificationManager.notify is called. status: 0=post, 1=update, 2=ignored
2750 notification_enqueue (uid|1|5),(pid|1|5),(pkg|3),(id|1|5),(tag|3),(userid|1|5),(notification|3),(status|1)
# when someone tries to cancel a notification, the notification manager sometimes
# calls this with flags too
2751 notification_cancel (uid|1|5),(pid|1|5),(pkg|3),(id|1|5),(tag|3),(userid|1|5),(required_flags|1),(forbidden_flags|1),(reason|1|5),(listener|3)
# when someone tries to cancel all of the notifications for a particular package
2752 notification_cancel_all (uid|1|5),(pid|1|5),(pkg|3),(userid|1|5),(required_flags|1),(forbidden_flags|1),(reason|1|5),(listener|3)
# when the notification panel is shown
# Note: New tag range starts here since 2753+ have been used below.
27500 notification_panel_revealed (items|1)
# when the notification panel is hidden
27501 notification_panel_hidden
# when notifications are newly displayed on screen, or disappear from screen
27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3)
# when notifications are expanded, or contracted
27511 notification_expansion (key|3),(user_action|1),(expanded|1),(lifespan|1),(freshness|1),(exposure|1)
# when a notification has been clicked
27520 notification_clicked (key|3),(lifespan|1),(freshness|1),(exposure|1)
# when a notification action button has been clicked
27521 notification_action_clicked (key|3),(action_index|1),(lifespan|1),(freshness|1),(exposure|1)
# when a notification has been canceled
27530 notification_canceled (key|3),(reason|1),(lifespan|1),(freshness|1),(exposure|1)
# replaces 27510 with a row per notification
27531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1)
# a notification emited noise, vibration, or light
27532 notification_alert (key|3),(buzz|1),(beep|1),(blink|1)

# ---------------------------
# Watchdog.java
# ---------------------------
2802 watchdog (Service|3)
2803 watchdog_proc_pss (Process|3),(Pid|1|5),(Pss|1|2)
2804 watchdog_soft_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2),(Skip|3)
2805 watchdog_hard_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2)
2806 watchdog_pss_stats (EmptyPss|1|2),(EmptyCount|1|1),(BackgroundPss|1|2),(BackgroundCount|1|1),(ServicePss|1|2),(ServiceCount|1|1),(VisiblePss|1|2),(VisibleCount|1|1),(ForegroundPss|1|2),(ForegroundCount|1|1),(NoPssCount|1|1)
2807 watchdog_proc_stats (DeathsInOne|1|1),(DeathsInTwo|1|1),(DeathsInThree|1|1),(DeathsInFour|1|1),(DeathsInFive|1|1)
2808 watchdog_scheduled_reboot (Now|2|1),(Interval|1|3),(StartTime|1|3),(Window|1|3),(Skip|3)
2809 watchdog_meminfo (MemFree|1|2),(Buffers|1|2),(Cached|1|2),(Active|1|2),(Inactive|1|2),(AnonPages|1|2),(Mapped|1|2),(Slab|1|2),(SReclaimable|1|2),(SUnreclaim|1|2),(PageTables|1|2)
2810 watchdog_vmstat (runtime|2|3),(pgfree|1|1),(pgactivate|1|1),(pgdeactivate|1|1),(pgfault|1|1),(pgmajfault|1|1)
2811 watchdog_requested_reboot (NoWait|1|1),(ScheduleInterval|1|3),(RecheckInterval|1|3),(StartTime|1|3),(Window|1|3),(MinScreenOff|1|3),(MinNextAlarm|1|3)


# ---------------------------
# BackupManagerService.java
# ---------------------------
2820 backup_data_changed (Package|3)
2821 backup_start (Transport|3)
2822 backup_transport_failure (Package|3)
2823 backup_agent_failure (Package|3),(Message|3)
2824 backup_package (Package|3),(Size|1|2)
2825 backup_success (Packages|1|1),(Time|1|3)
2826 backup_reset (Transport|3)
2827 backup_initialize
2830 restore_start (Transport|3),(Source|2|5)
2831 restore_transport_failure
2832 restore_agent_failure (Package|3),(Message|3)
2833 restore_package (Package|3),(Size|1|2)
2834 restore_success (Packages|1|1),(Time|1|3)

2840 full_backup_package (Package|3)
2841 full_backup_agent_failure (Package|3),(Message|3)
2842 full_backup_transport_failure
2843 full_backup_success (Package|3)
2844 full_restore_package (Package|3)

2850 backup_transport_lifecycle (Transport|3),(Bound|1|1)


# ---------------------------
# SystemServer.java
# ---------------------------
# SystemServer.run() starts:
3010 boot_progress_system_run (time|2|3)


# ---------------------------
# PackageManagerService.java
# ---------------------------
# Package Manager starts:
3060 boot_progress_pms_start (time|2|3)
# Package Manager .apk scan starts:
3070 boot_progress_pms_system_scan_start (time|2|3)
# Package Manager .apk scan starts:
3080 boot_progress_pms_data_scan_start (time|2|3)
# Package Manager .apk scan ends:
3090 boot_progress_pms_scan_end (time|2|3)
# Package Manager ready:
3100 boot_progress_pms_ready (time|2|3)
# + check activity_launch_time for Home app
# Value of "unknown sources" setting at app install time
3110 unknown_sources_enabled (value|1)
# Package Manager critical info
3120 pm_critical_info (msg|3)


# ---------------------------
# WindowManagerService.java
# ---------------------------
# Out of memory for surfaces.
31000 wm_no_surface_memory (Window|3),(PID|1|5),(Operation|3)
# Task created.
31001 wm_task_created (TaskId|1|5),(StackId|1|5)
# Task moved to top (1) or bottom (0).
31002 wm_task_moved (TaskId|1|5),(ToTop|1),(Index|1)
# Task removed with source explanation.
31003 wm_task_removed (TaskId|1|5),(Reason|3)
# Stack created.
31004 wm_stack_created (StackId|1|5),(RelativeBoxId|1|5),(Position|1),(Weight|1|6)
# Home stack moved to top (1) or bottom (0).
31005 wm_home_stack_moved (ToTop|1)
# Stack removed.
31006 wm_stack_removed (StackId|1|5)


# ---------------------------
# InputMethodManagerService.java
# ---------------------------
# Re-connecting to input method service because we haven't received its interface
32000 imf_force_reconnect_ime (IME|4),(Time Since Connect|2|3),(Showing|1|1)


# ---------------------------
# WallpaperManagerService.java
# ---------------------------
33000 wp_wallpaper_crashed (component|3)

# ---------------------------
# Device idle
# ---------------------------
34000 device_idle (state|1|5), (reason|3)
34001 device_idle_step
34002 device_idle_wake_from_idle (is_idle|1|5), (reason|3)
34003 device_idle_on_start
34004 device_idle_on_phase (what|3)
34005 device_idle_on_complete
34006 device_idle_off_start (reason|3)
34007 device_idle_off_phase (what|3)
34008 device_idle_off_complete

# ---------------------------
# DisplayManagerService.java
# ---------------------------
# Auto-brightness adjustments by the user.
35000 auto_brightness_adj (old_adj|5),(old_lux|5),(old_brightness|5),(old_gamma|5),(new_adj|5),(new_lux|5),(new_brightness|5),(new_gamma|5)

# ---------------------------
# ConnectivityService.java
# ---------------------------
# Connectivity state changed
50020 connectivity_state_changed (type|1),(subtype|1),(state|1)


# ---------------------------
# NetworkStatsService.java
# ---------------------------
51100 netstats_mobile_sample (dev_rx_bytes|2|2),(dev_tx_bytes|2|2),(dev_rx_pkts|2|1),(dev_tx_pkts|2|1),(xt_rx_bytes|2|2),(xt_tx_bytes|2|2),(xt_rx_pkts|2|1),(xt_tx_pkts|2|1),(uid_rx_bytes|2|2),(uid_tx_bytes|2|2),(uid_rx_pkts|2|1),(uid_tx_pkts|2|1),(trusted_time|2|3)
51101 netstats_wifi_sample (dev_rx_bytes|2|2),(dev_tx_bytes|2|2),(dev_rx_pkts|2|1),(dev_tx_pkts|2|1),(xt_rx_bytes|2|2),(xt_tx_bytes|2|2),(xt_rx_pkts|2|1),(xt_tx_pkts|2|1),(uid_rx_bytes|2|2),(uid_tx_bytes|2|2),(uid_rx_pkts|2|1),(uid_tx_pkts|2|1),(trusted_time|2|3)


# ---------------------------
# LockdownVpnTracker.java
# ---------------------------
51200 lockdown_vpn_connecting (egress_net|1)
51201 lockdown_vpn_connected (egress_net|1)
51202 lockdown_vpn_error (egress_net|1)

# ---------------------------
# ConfigUpdateInstallReceiver.java
# ---------------------------
51300 config_install_failed (dir|3)

# ---------------------------
# IntentFirewall.java
# ---------------------------
51400 ifw_intent_matched (Intent Type|1|5),(Component Name|3),(Caller Uid|1|5),(Caller Pkg Count|1|1),(Caller Pkgs|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)

# ---------------------------
# IdleMaintenanceService.java
# ---------------------------
51500 idle_maintenance_window_start (time|2|3), (lastUserActivity|2|3), (batteryLevel|1|6), (batteryCharging|1|5)
51501 idle_maintenance_window_finish (time|2|3), (lastUserActivity|2|3), (batteryLevel|1|6), (batteryCharging|1|5)

# ---------------------------
# MountService.java
# ---------------------------
2755 fstrim_start (time|2|3)
2756 fstrim_finish (time|2|3)

# ---------------------------
# AudioService.java
# ---------------------------
40000 volume_changed (stream|1), (prev_level|1), (level|1), (max_level|1), (caller|3)
40001 stream_devices_changed (stream|1), (prev_devices|1), (devices|1)

# ---------------------------
# GestureLauncherService.java
# ---------------------------
40100 camera_gesture_triggered (gesture_on_time|2|3), (sensor1_on_time|2|3), (sensor2_on_time|2|3), (event_extra|1|1)




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.

option java_package com.android.server.am

2719 configuration_changed (config mask|1|5)
2721 cpu (total|1|6),(user|1|6),(system|1|6),(iowait|1|6),(irq|1|6),(softirq|1|6)

# ActivityManagerService.systemReady() starts:
3040 boot_progress_ams_ready (time|2|3)
# ActivityManagerService calls enableScreenAfterBoot():
3050 boot_progress_enable_screen (time|2|3)

# Do not change these names without updating the checkin_events setting in
# google3/googledata/wireless/android/provisioning/gservices.config !!
#
# An activity is being finished:
30001 am_finish_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3)
# A task is being brought to the front of the screen:
30002 am_task_to_front (User|1|5),(Task|1|5)
# An existing activity is being given a new intent:
30003 am_new_intent (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)
# A new task is being created:
30004 am_create_task (User|1|5),(Task ID|1|5)
# A new activity is being created in an existing task:
30005 am_create_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)
# An activity has been resumed into the foreground but was not already running:
30006 am_restart_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)
# An activity has been resumed and is now in the foreground:
30007 am_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)
# Application Not Responding
30008 am_anr (User|1|5),(pid|1|5),(Package Name|3),(Flags|1|5),(reason|3)
# Activity launch time
30009 am_activity_launch_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3)
# Application process bound to work
30010 am_proc_bound (User|1|5),(PID|1|5),(Process Name|3)
# Application process died
30011 am_proc_died (User|1|5),(PID|1|5),(Process Name|3)
# The Activity Manager failed to pause the given activity.
30012 am_failed_to_pause (User|1|5),(Token|1|5),(Wanting to pause|3),(Currently pausing|3)
# Attempting to pause the current activity
30013 am_pause_activity (User|1|5),(Token|1|5),(Component Name|3)
# Application process has been started
30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)
# An application process has been marked as bad
30015 am_proc_bad (User|1|5),(UID|1|5),(Process Name|3)
# An application process that was bad is now marked as good
30016 am_proc_good (User|1|5),(UID|1|5),(Process Name|3)
# Reporting to applications that memory is low
30017 am_low_memory (Num Processes|1|1)
# An activity is being destroyed:
30018 am_destroy_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3)
# An activity has been relaunched, resumed, and is now in the foreground:
30019 am_relaunch_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)
# An activity has been relaunched:
30020 am_relaunch_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)
# The activity's onPause has been called.
30021 am_on_paused_called (User|1|5),(Component Name|3)
# The activity's onResume has been called.
30022 am_on_resume_called (User|1|5),(Component Name|3)
# Kill a process to reclaim memory.
30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3)
# Discard an undelivered serialized broadcast (timeout/ANR/crash)
30024 am_broadcast_discard_filter (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5)
30025 am_broadcast_discard_app (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3)
# A service is being created
30030 am_create_service (User|1|5),(Service Record|1|5),(Name|3),(UID|1|5),(PID|1|5)
# A service is being destroyed
30031 am_destroy_service (User|1|5),(Service Record|1|5),(PID|1|5)
# A process has crashed too many times, it is being cleared
30032 am_process_crashed_too_much (User|1|5),(Name|3),(PID|1|5)
# An unknown process is trying to attach to the activity manager
30033 am_drop_process (PID|1|5)
# A service has crashed too many times, it is being stopped
30034 am_service_crashed_too_much (User|1|5),(Crash Count|1|1),(Component Name|3),(PID|1|5)
# A service is going to be restarted after its process went away
30035 am_schedule_service_restart (User|1|5),(Component Name|3),(Time|2|3)
# A client was waiting for a content provider, but its process was lost
30036 am_provider_lost_process (User|1|5),(Package Name|3),(UID|1|5),(Name|3)
# The activity manager gave up on a new process taking too long to start
30037 am_process_start_timeout (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3)

# Unhandled exception
30039 am_crash (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Exception|3),(Message|3),(File|3),(Line|1|5)
# Log.wtf() called
30040 am_wtf (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Tag|3),(Message|3)

# User switched
30041 am_switch_user (id|1|5)

# Activity fully drawn time
30042 am_activity_fully_drawn_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3)

# Activity focused
30043 am_focused_activity (User|1|5),(Component Name|3)

# Home Stack brought to front or rear
30044 am_home_stack_moved (User|1|5),(To Front|1|5),(Top Stack Id|1|5),(Focused Stack Id|1|5),(Reason|3)

# Running pre boot receiver
30045 am_pre_boot (User|1|5),(Package|3)

# Report collection of global memory state
30046 am_meminfo (CachedKb|2|2),(FreeKb|2|2),(ZramKb|2|2),(KernelKb|2|2),(NativeKb|2|2)
# Report collection of memory used by a process
30047 am_pss (Pid|1|5),(UID|1|5),(Process Name|3),(PssKb|2|2),(UssKb|2|2)



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

     

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

option java_package com.android.internal.logging;

# interaction logs
524287 sysui_view_visibility (category|1|5),(visible|1|6)
524288 sysui_action (category|1|5),(pkg|3)
524290 sysui_count (name|3),(increment|1)
524291 sysui_histogram (name|3),(bucket|1)


还有其他EventLogTags.logtags,在此不再记录了。

frameworks/base/core/java/android/util/EventLog.java
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package android.util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Collection;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Access to the system diagnostic event record.  System diagnostic events are
 * used to record certain system-level events (such as garbage collection,
 * activity manager state, system watchdogs, and other low level activity),
 * which may be automatically collected and analyzed during system development.
 *
 * <p>This is <b>not</b> the main "logcat" debugging log ({@link android.util.Log})!
 * These diagnostic events are for system integrators, not application authors.
 *
 * <p>Events use integer tag codes corresponding to /system/etc/event-log-tags.
 * They carry a payload of one or more int, long, or String values.  The

 * event-log-tags file defines the payload contents for each type code.
 */

public class EventLog {
    /** @hide */ public EventLog() {}

    private static final String TAG = "EventLog";

    private static final String TAGS_FILE = "/system/etc/event-log-tags";
    private static final String COMMENT_PATTERN = "^\\s*(#.*)?$";
    private static final String TAG_PATTERN = "^\\s*(\\d+)\\s+(\\w+)\\s*(\\(.*\\))?\\s*$";
    private static HashMap<String, Integer> sTagCodes = null;
    private static HashMap<Integer, String> sTagNames = null;

    /** A previously logged event read from the logs. */
    public static final class Event {
        private final ByteBuffer mBuffer;

        // Layout of event log entry received from Android logger.
        //  see system/core/include/log/logger.h
        private static final int LENGTH_OFFSET = 0;
        private static final int HEADER_SIZE_OFFSET = 2;
        private static final int PROCESS_OFFSET = 4;
        private static final int THREAD_OFFSET = 8;
        private static final int SECONDS_OFFSET = 12;
        private static final int NANOSECONDS_OFFSET = 16;

        // Layout for event log v1 format, v2 and v3 use HEADER_SIZE_OFFSET
        private static final int V1_PAYLOAD_START = 20;
        private static final int DATA_OFFSET = 4;

        // Value types
        private static final byte INT_TYPE    = 0;
        private static final byte LONG_TYPE   = 1;
        private static final byte STRING_TYPE = 2;
        private static final byte LIST_TYPE   = 3;
        private static final byte FLOAT_TYPE = 4;

        /** @param data containing event, read from the system */
        /*package*/ Event(byte[] data) {
            mBuffer = ByteBuffer.wrap(data);
            mBuffer.order(ByteOrder.nativeOrder());
        }

        /** @return the process ID which wrote the log entry */
        public int getProcessId() {
            return mBuffer.getInt(PROCESS_OFFSET);
        }

        /** @return the thread ID which wrote the log entry */
        public int getThreadId() {
            return mBuffer.getInt(THREAD_OFFSET);
        }

        /** @return the wall clock time when the entry was written */
        public long getTimeNanos() {
            return mBuffer.getInt(SECONDS_OFFSET) * 1000000000l
                    + mBuffer.getInt(NANOSECONDS_OFFSET);
        }

        /** @return the type tag code of the entry */
        public int getTag() {
            int offset = mBuffer.getShort(HEADER_SIZE_OFFSET);
            if (offset == 0) {
                offset = V1_PAYLOAD_START;
            }
            return mBuffer.getInt(offset);
        }

        /** @return one of Integer, Long, Float, String, null, or Object[] of same. */
        public synchronized Object getData() {
            try {
                int offset = mBuffer.getShort(HEADER_SIZE_OFFSET);
                if (offset == 0) {
                    offset = V1_PAYLOAD_START;
                }
                mBuffer.limit(offset + mBuffer.getShort(LENGTH_OFFSET));
                mBuffer.position(offset + DATA_OFFSET); // Just after the tag.
                return decodeObject();
            } catch (IllegalArgumentException e) {
                Log.wtf(TAG, "Illegal entry payload: tag=" + getTag(), e);
                return null;
            } catch (BufferUnderflowException e) {
                Log.wtf(TAG, "Truncated entry payload: tag=" + getTag(), e);
                return null;
            }
        }

        /** @return the loggable item at the current position in mBuffer. */
        private Object decodeObject() {
            byte type = mBuffer.get();
            switch (type) {
            case INT_TYPE:
                return mBuffer.getInt();

            case LONG_TYPE:
                return mBuffer.getLong();

            case FLOAT_TYPE:
                return mBuffer.getFloat();

            case STRING_TYPE:
                try {
                    int length = mBuffer.getInt();
                    int start = mBuffer.position();
                    mBuffer.position(start + length);
                    return new String(mBuffer.array(), start, length, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    Log.wtf(TAG, "UTF-8 is not supported", e);
                    return null;
                }

            case LIST_TYPE:
                int length = mBuffer.get();
                if (length < 0) length += 256;  // treat as signed byte
                Object[] array = new Object[length];
                for (int i = 0; i < length; ++i) array[i] = decodeObject();
                return array;

            default:
                throw new IllegalArgumentException("Unknown entry type: " + type);
            }
        }
    }

    // We assume that the native methods deal with any concurrency issues.

    /**
     * Record an event log message.
     * @param tag The event type tag code
     * @param value A value to log
     * @return The number of bytes written
     */

    public static native int writeEvent(int tag, int value);

    /**
     * Record an event log message.
     * @param tag The event type tag code
     * @param value A value to log
     * @return The number of bytes written
     */

    public static native int writeEvent(int tag, long value);

    /**
     * Record an event log message.
     * @param tag The event type tag code
     * @param value A value to log
     * @return The number of bytes written
     */

    public static native int writeEvent(int tag, float value);

    /**
     * Record an event log message.
     * @param tag The event type tag code
     * @param str A value to log
     * @return The number of bytes written
     */

    public static native int writeEvent(int tag, String str);

    /**
     * Record an event log message.
     * @param tag The event type tag code
     * @param list A list of values to log
     * @return The number of bytes written
     */

    public static native int writeEvent(int tag, Object... list);

    /**
     * Read events from the log, filtered by type.
     * @param tags to search for
     * @param output container to add events into
     * @throws IOException if something goes wrong reading events
     */

    public static native void readEvents(int[] tags, Collection<Event> output)
            throws IOException;

    /**
     * Get the name associated with an event type tag code.
     * @param tag code to look up
     * @return the name of the tag, or null if no tag has that number
     */

    public static String getTagName(int tag) {
        readTagsFile();
        return sTagNames.get(tag);
    }

    /**
     * Get the event type tag code associated with an event name.
     * @param name of event to look up
     * @return the tag code, or -1 if no tag has that name
     */

    public static int getTagCode(String name) {
        readTagsFile();
        Integer code = sTagCodes.get(name);
        return code != null ? code : -1;
    }

    /**
     * Read TAGS_FILE, populating sTagCodes and sTagNames, if not already done.
     */

    private static synchronized void readTagsFile() {
        if (sTagCodes != null && sTagNames != nullreturn;

        sTagCodes = new HashMap<String, Integer>();
        sTagNames = new HashMap<Integer, String>();

        Pattern comment = Pattern.compile(COMMENT_PATTERN);
        Pattern tag = Pattern.compile(TAG_PATTERN);
        BufferedReader reader = null;
        String line;

        try {
            reader = new BufferedReader(new FileReader(TAGS_FILE), 256);
            while ((line = reader.readLine()) != null) {
                if (comment.matcher(line).matches()) continue;

                Matcher m = tag.matcher(line);
                if (!m.matches()) {
                    Log.wtf(TAG, "Bad entry in " + TAGS_FILE + ": " + line);
                    continue;
                }

                try {
                    int num = Integer.parseInt(m.group(1));
                    String name = m.group(2);
                    sTagCodes.put(name, num);
                    sTagNames.put(num, name);
                } catch (NumberFormatException e) {
                    Log.wtf(TAG, "Error in " + TAGS_FILE + ": " + line, e);
                }
            }
        } catch (IOException e) {
            Log.wtf(TAG, "Error reading " + TAGS_FILE, e);
            // Leave the maps existing but unpopulated
        } finally {
            try { if (reader != null) reader.close(); } catch (IOException e) {}
        }
    }
}



以上列出了主要的文件。

2.2 event log格式分析


event log文件格式:timestamp PID TID log-level log-tag tag-values
分为两部分看:
第一部分 timestamp PID TID log-level
第二部分 log-tag tag-values

2.2.1 第一部分(timestamp PID TID log-level)很容易理解

2.2.2 主要看第二部分(log-tag tag-values),以am相关的tags来讲述

在文件frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags中,存在如下一句log-tags定义(定义中的30014与am_proc_start是绑定的):
# Application process has been started
30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)

而上面这句log-tags在/system/etc/event-log-tags中也同样存在,打印看下:
zhanghu@winth:~$ adb shell cat /system/etc/event-log-tags | grep am_proc_start
99:30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)
即:/system/etc/event-log-tags 包含了系统所有EventLogTags.logtags文件中的log-tags的定义(EventLogTags.logtags文件根据系统服务的区别,存放在不同的路径下)

am_proc_start后面的跟的(User|1|5),(PID|1|5),(UID|1|5),etc 这些是什么意思呢?在system/core/logcat/event.logtags文件中有说明,摘录如下:
# (<name>|data type[|data unit])
# Multiple values are separated by commas.
#
# 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
翻译如下:
数据类型:

1: int
2: long
3: string
4: list
5:float

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

数据单位:

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


2.2.3 实例解析

event log:
09-06 16:18:46.197 1632 2405 I am_proc_start: [0,4394,1000,com.android.usbsecurity,broadcast,com.android.usbsecurity/.UsbSecurityReceiver]

log-tag tag-values部分是下面这部分:
am_proc_start: [0,4394,1000,com.android.usbsecurity,broadcast,com.android.usbsecurity/.UsbSecurityReceiver]
根据am_proc_start这个关键字,在/system/etc/event-log-tags文件或在../server/am/EventLogTags.logtags中找到它的定义:
30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)

根据上面这个定义我们就知道event log的tag-values这个值的含义了,放在一起对比下:
am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)
am_proc_start: [0,4394,1000,com.android.usbsecurity,broadcast,com.android.usbsecurity/.UsbSecurityReceiver]
含义:
进程启动: pid=4394,uid=1000, 进程名=com.android.usbsecurity, 类型broadcast,相应组件=com.android.usbsecurity/.UsbSecurityReceiver

上面am_proc_start生成位置在ActivityManagerService.startProcessLocked方法内,如下:
          EventLog.writeEvent(EventLogTags.AM_PROC_START,
                    UserHandle.getUserId(uid), startResult.pid, uid,
                    app.processName, hostingType,
                    hostingNameStr != null ? hostingNameStr : "");

EventLogTags.AM_PROC_START这句的EventLogTags引自自动生成的文件(out/target/common/obj/JAVA_LIBRARIES/services.core_intermediates/src/java/com/android/server/am/EventLogTags.java)

out/target/common/obj/JAVA_LIBRARIES/services.core_intermediates/src/java/com/android/server/am/EventLogTags.java

/* This file is auto-generated.  DO NOT MODIFY.
 * Source file: frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags
 */

package com.android.server.am;

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

  /** 2719 configuration_changed (config mask|1|5) */
  public static final int CONFIGURATION_CHANGED = 2719;

  /** 2721 cpu (total|1|6),(user|1|6),(system|1|6),(iowait|1|6),(irq|1|6),(softirq|1|6) */
  public static final int CPU = 2721;

  /** 3040 boot_progress_ams_ready (time|2|3) */
  public static final int BOOT_PROGRESS_AMS_READY = 3040;

  /** 3050 boot_progress_enable_screen (time|2|3) */
  public static final int BOOT_PROGRESS_ENABLE_SCREEN = 3050;

  /** 30001 am_finish_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) */
  public static final int AM_FINISH_ACTIVITY = 30001;

  /** 30002 am_task_to_front (User|1|5),(Task|1|5) */
  public static final int AM_TASK_TO_FRONT = 30002;

  /** 30003 am_new_intent (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) */
  public static final int AM_NEW_INTENT = 30003;

  /** 30004 am_create_task (User|1|5),(Task ID|1|5) */
  public static final int AM_CREATE_TASK = 30004;

  /** 30005 am_create_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) */
  public static final int AM_CREATE_ACTIVITY = 30005;

  /** 30006 am_restart_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) */
  public static final int AM_RESTART_ACTIVITY = 30006;

  /** 30007 am_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) */
  public static final int AM_RESUME_ACTIVITY = 30007;

  /** 30008 am_anr (User|1|5),(pid|1|5),(Package Name|3),(Flags|1|5),(reason|3) */
  public static final int AM_ANR = 30008;

  /** 30009 am_activity_launch_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3) */
  public static final int AM_ACTIVITY_LAUNCH_TIME = 30009;

  /** 30010 am_proc_bound (User|1|5),(PID|1|5),(Process Name|3) */
  public static final int AM_PROC_BOUND = 30010;

  /** 30011 am_proc_died (User|1|5),(PID|1|5),(Process Name|3) */
  public static final int AM_PROC_DIED = 30011;

  /** 30012 am_failed_to_pause (User|1|5),(Token|1|5),(Wanting to pause|3),(Currently pausing|3) */
  public static final int AM_FAILED_TO_PAUSE = 30012;

  /** 30013 am_pause_activity (User|1|5),(Token|1|5),(Component Name|3) */
  public static final int AM_PAUSE_ACTIVITY = 30013;

  /** 30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) */
  public static final int AM_PROC_START = 30014;

  /** 30015 am_proc_bad (User|1|5),(UID|1|5),(Process Name|3) */
  public static final int AM_PROC_BAD = 30015;

  /** 30016 am_proc_good (User|1|5),(UID|1|5),(Process Name|3) */
  public static final int AM_PROC_GOOD = 30016;

  /** 30017 am_low_memory (Num Processes|1|1) */
  public static final int AM_LOW_MEMORY = 30017;

  /** 30018 am_destroy_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) */
  public static final int AM_DESTROY_ACTIVITY = 30018;

  /** 30019 am_relaunch_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) */
  public static final int AM_RELAUNCH_RESUME_ACTIVITY = 30019;

  /** 30020 am_relaunch_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) */
  public static final int AM_RELAUNCH_ACTIVITY = 30020;

  /** 30021 am_on_paused_called (User|1|5),(Component Name|3),(Reason|3) */
  public static final int AM_ON_PAUSED_CALLED = 30021;

  /** 30022 am_on_resume_called (User|1|5),(Component Name|3),(Reason|3) */
  public static final int AM_ON_RESUME_CALLED = 30022;

  /** 30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3) */
  public static final int AM_KILL = 30023;

  /** 30024 am_broadcast_discard_filter (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5) */
  public static final int AM_BROADCAST_DISCARD_FILTER = 30024;

  /** 30025 am_broadcast_discard_app (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3) */
  public static final int AM_BROADCAST_DISCARD_APP = 30025;

  /** 30030 am_create_service (User|1|5),(Service Record|1|5),(Name|3),(UID|1|5),(PID|1|5) */
  public static final int AM_CREATE_SERVICE = 30030;

  /** 30031 am_destroy_service (User|1|5),(Service Record|1|5),(PID|1|5) */
  public static final int AM_DESTROY_SERVICE = 30031;

  /** 30032 am_process_crashed_too_much (User|1|5),(Name|3),(PID|1|5) */
  public static final int AM_PROCESS_CRASHED_TOO_MUCH = 30032;

  /** 30033 am_drop_process (PID|1|5) */
  public static final int AM_DROP_PROCESS = 30033;

  /** 30034 am_service_crashed_too_much (User|1|5),(Crash Count|1|1),(Component Name|3),(PID|1|5) */
  public static final int AM_SERVICE_CRASHED_TOO_MUCH = 30034;

  /** 30035 am_schedule_service_restart (User|1|5),(Component Name|3),(Time|2|3) */
  public static final int AM_SCHEDULE_SERVICE_RESTART = 30035;

  /** 30036 am_provider_lost_process (User|1|5),(Package Name|3),(UID|1|5),(Name|3) */
  public static final int AM_PROVIDER_LOST_PROCESS = 30036;

  /** 30037 am_process_start_timeout (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3) */
  public static final int AM_PROCESS_START_TIMEOUT = 30037;

  /** 30039 am_crash (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Exception|3),(Message|3),(File|3),(Line|1|5) */
  public static final int AM_CRASH = 30039;

  /** 30040 am_wtf (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Tag|3),(Message|3) */
  public static final int AM_WTF = 30040;

  /** 30041 am_switch_user (id|1|5) */
  public static final int AM_SWITCH_USER = 30041;

  /** 30042 am_activity_fully_drawn_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3) */
  public static final int AM_ACTIVITY_FULLY_DRAWN_TIME = 30042;

  /** 30043 am_focused_activity (User|1|5),(Component Name|3),(Reason|3) */
  public static final int AM_FOCUSED_ACTIVITY = 30043;

  /** 30044 am_focused_stack (User|1|5),(Focused Stack Id|1|5),(Last Focused Stack Id|1|5),(Reason|3) */
  public static final int AM_FOCUSED_STACK = 30044;

  /** 30045 am_pre_boot (User|1|5),(Package|3) */
  public static final int AM_PRE_BOOT = 30045;

  /** 30046 am_meminfo (Cached|2|2),(Free|2|2),(Zram|2|2),(Kernel|2|2),(Native|2|2) */
  public static final int AM_MEMINFO = 30046;

  /** 30047 am_pss (Pid|1|5),(UID|1|5),(Process Name|3),(Pss|2|2),(Uss|2|2),(SwapPss|2|2) */
  public static final int AM_PSS = 30047;

  /** 30048 am_stop_activity (User|1|5),(Token|1|5),(Component Name|3) */
  public static final int AM_STOP_ACTIVITY = 30048;

  /** 30049 am_on_stop_called (User|1|5),(Component Name|3),(Reason|3) */
  public static final int AM_ON_STOP_CALLED = 30049;

  /** 30050 am_mem_factor (Current|1|5),(Previous|1|5) */
  public static final int AM_MEM_FACTOR = 30050;

  public static void writeConfigurationChanged(int configMask) {
    android.util.EventLog.writeEvent(CONFIGURATION_CHANGED, configMask);
  }

  public static void writeCpu(int total, int user, int system, int iowait, int irq, int softirq) {
    android.util.EventLog.writeEvent(CPU, total, user, system, iowait, irq, softirq);
  }

  public static void writeBootProgressAmsReady(long time) {
    android.util.EventLog.writeEvent(BOOT_PROGRESS_AMS_READY, time);
  }

  public static void writeBootProgressEnableScreen(long time) {
    android.util.EventLog.writeEvent(BOOT_PROGRESS_ENABLE_SCREEN, time);
  }

  public static void writeAmFinishActivity(int user, int token, int taskId, String componentName, String reason) {
    android.util.EventLog.writeEvent(AM_FINISH_ACTIVITY, user, token, taskId, componentName, reason);
  }

  public static void writeAmTaskToFront(int user, int task) {
    android.util.EventLog.writeEvent(AM_TASK_TO_FRONT, user, task);
  }

  public static void writeAmNewIntent(int user, int token, int taskId, String componentName, String action, String mimeType, String uri, int flags) {
    android.util.EventLog.writeEvent(AM_NEW_INTENT, user, token, taskId, componentName, action, mimeType, uri, flags);
  }

  public static void writeAmCreateTask(int user, int taskId) {
    android.util.EventLog.writeEvent(AM_CREATE_TASK, user, taskId);
  }

  public static void writeAmCreateActivity(int user, int token, int taskId, String componentName, String action, String mimeType, String uri, int flags) {
    android.util.EventLog.writeEvent(AM_CREATE_ACTIVITY, user, token, taskId, componentName, action, mimeType, uri, flags);
  }

  public static void writeAmRestartActivity(int user, int token, int taskId, String componentName) {
    android.util.EventLog.writeEvent(AM_RESTART_ACTIVITY, user, token, taskId, componentName);
  }

  public static void writeAmResumeActivity(int user, int token, int taskId, String componentName) {
    android.util.EventLog.writeEvent(AM_RESUME_ACTIVITY, user, token, taskId, componentName);
  }

  public static void writeAmAnr(int user, int pid, String packageName, int flags, String reason) {
    android.util.EventLog.writeEvent(AM_ANR, user, pid, packageName, flags, reason);
  }

  public static void writeAmActivityLaunchTime(int user, int token, String componentName, long time) {
    android.util.EventLog.writeEvent(AM_ACTIVITY_LAUNCH_TIME, user, token, componentName, time);
  }

  public static void writeAmProcBound(int user, int pid, String processName) {
    android.util.EventLog.writeEvent(AM_PROC_BOUND, user, pid, processName);
  }

  public static void writeAmProcDied(int user, int pid, String processName) {
    android.util.EventLog.writeEvent(AM_PROC_DIED, user, pid, processName);
  }

  public static void writeAmFailedToPause(int user, int token, String wantingToPause, String currentlyPausing) {
    android.util.EventLog.writeEvent(AM_FAILED_TO_PAUSE, user, token, wantingToPause, currentlyPausing);
  }

  public static void writeAmPauseActivity(int user, int token, String componentName) {
    android.util.EventLog.writeEvent(AM_PAUSE_ACTIVITY, user, token, componentName);
  }

  public static void writeAmProcStart(int user, int pid, int uid, String processName, String type, String component) {
    android.util.EventLog.writeEvent(AM_PROC_START, user, pid, uid, processName, type, component);
  }

  public static void writeAmProcBad(int user, int uid, String processName) {
    android.util.EventLog.writeEvent(AM_PROC_BAD, user, uid, processName);
  }

  public static void writeAmProcGood(int user, int uid, String processName) {
    android.util.EventLog.writeEvent(AM_PROC_GOOD, user, uid, processName);
  }

  public static void writeAmLowMemory(int numProcesses) {
    android.util.EventLog.writeEvent(AM_LOW_MEMORY, numProcesses);
  }

  public static void writeAmDestroyActivity(int user, int token, int taskId, String componentName, String reason) {
    android.util.EventLog.writeEvent(AM_DESTROY_ACTIVITY, user, token, taskId, componentName, reason);
  }

  public static void writeAmRelaunchResumeActivity(int user, int token, int taskId, String componentName) {
    android.util.EventLog.writeEvent(AM_RELAUNCH_RESUME_ACTIVITY, user, token, taskId, componentName);
  }

  public static void writeAmRelaunchActivity(int user, int token, int taskId, String componentName) {
    android.util.EventLog.writeEvent(AM_RELAUNCH_ACTIVITY, user, token, taskId, componentName);
  }

  public static void writeAmOnPausedCalled(int user, String componentName, String reason) {
    android.util.EventLog.writeEvent(AM_ON_PAUSED_CALLED, user, componentName, reason);
  }

  public static void writeAmOnResumeCalled(int user, String componentName, String reason) {
    android.util.EventLog.writeEvent(AM_ON_RESUME_CALLED, user, componentName, reason);
  }

  public static void writeAmKill(int user, int pid, String processName, int oomadj, String reason) {
    android.util.EventLog.writeEvent(AM_KILL, user, pid, processName, oomadj, reason);
  }

  public static void writeAmBroadcastDiscardFilter(int user, int broadcast, String action, int receiverNumber, int broadcastfilter) {
    android.util.EventLog.writeEvent(AM_BROADCAST_DISCARD_FILTER, user, broadcast, action, receiverNumber, broadcastfilter);
  }

  public static void writeAmBroadcastDiscardApp(int user, int broadcast, String action, int receiverNumber, String app) {
    android.util.EventLog.writeEvent(AM_BROADCAST_DISCARD_APP, user, broadcast, action, receiverNumber, app);
  }

  public static void writeAmCreateService(int user, int serviceRecord, String name, int uid, int pid) {
    android.util.EventLog.writeEvent(AM_CREATE_SERVICE, user, serviceRecord, name, uid, pid);
  }

  public static void writeAmDestroyService(int user, int serviceRecord, int pid) {
    android.util.EventLog.writeEvent(AM_DESTROY_SERVICE, user, serviceRecord, pid);
  }

  public static void writeAmProcessCrashedTooMuch(int user, String name, int pid) {
    android.util.EventLog.writeEvent(AM_PROCESS_CRASHED_TOO_MUCH, user, name, pid);
  }

  public static void writeAmDropProcess(int pid) {
    android.util.EventLog.writeEvent(AM_DROP_PROCESS, pid);
  }

  public static void writeAmServiceCrashedTooMuch(int user, int crashCount, String componentName, int pid) {
    android.util.EventLog.writeEvent(AM_SERVICE_CRASHED_TOO_MUCH, user, crashCount, componentName, pid);
  }

  public static void writeAmScheduleServiceRestart(int user, String componentName, long time) {
    android.util.EventLog.writeEvent(AM_SCHEDULE_SERVICE_RESTART, user, componentName, time);
  }

  public static void writeAmProviderLostProcess(int user, String packageName, int uid, String name) {
    android.util.EventLog.writeEvent(AM_PROVIDER_LOST_PROCESS, user, packageName, uid, name);
  }

  public static void writeAmProcessStartTimeout(int user, int pid, int uid, String processName) {
    android.util.EventLog.writeEvent(AM_PROCESS_START_TIMEOUT, user, pid, uid, processName);
  }

  public static void writeAmCrash(int user, int pid, String processName, int flags, String exception, String message, String file, int line) {
    android.util.EventLog.writeEvent(AM_CRASH, user, pid, processName, flags, exception, message, file, line);
  }

  public static void writeAmWtf(int user, int pid, String processName, int flags, String tag, String message) {
    android.util.EventLog.writeEvent(AM_WTF, user, pid, processName, flags, tag, message);
  }

  public static void writeAmSwitchUser(int id) {
    android.util.EventLog.writeEvent(AM_SWITCH_USER, id);
  }

  public static void writeAmActivityFullyDrawnTime(int user, int token, String componentName, long time) {
    android.util.EventLog.writeEvent(AM_ACTIVITY_FULLY_DRAWN_TIME, user, token, componentName, time);
  }

  public static void writeAmFocusedActivity(int user, String componentName, String reason) {
    android.util.EventLog.writeEvent(AM_FOCUSED_ACTIVITY, user, componentName, reason);
  }

  public static void writeAmFocusedStack(int user, int focusedStackId, int lastFocusedStackId, String reason) {
    android.util.EventLog.writeEvent(AM_FOCUSED_STACK, user, focusedStackId, lastFocusedStackId, reason);
  }

  public static void writeAmPreBoot(int user, String package_) {
    android.util.EventLog.writeEvent(AM_PRE_BOOT, user, package_);
  }

  public static void writeAmMeminfo(long cached, long free, long zram, long kernel, long native_) {
    android.util.EventLog.writeEvent(AM_MEMINFO, cached, free, zram, kernel, native_);
  }

  public static void writeAmPss(int pid, int uid, String processName, long pss, long uss, long swappss) {
    android.util.EventLog.writeEvent(AM_PSS, pid, uid, processName, pss, uss, swappss);
  }

  public static void writeAmStopActivity(int user, int token, String componentName) {
    android.util.EventLog.writeEvent(AM_STOP_ACTIVITY, user, token, componentName);
  }

  public static void writeAmOnStopCalled(int user, String componentName, String reason) {
    android.util.EventLog.writeEvent(AM_ON_STOP_CALLED, user, componentName, reason);
  }

  public static void writeAmMemFactor(int current, int previous) {
    android.util.EventLog.writeEvent(AM_MEM_FACTOR, current, previous);
  }
}


Event log就说道这里,应该已经表达清楚了。


版权声明:本文为博主(http://blog.csdn.net/yelangjueqi)原创文章,未经博主允许不得转载。

相关文章推荐

android event log含义

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

Android event日志打印原理

基于android 7.0代码,分析Event日志的打印原理   我们在调试分析Android的过程中,经常会查看EventLog,它非常简洁明了地展现当前Activity各种状态,当然不至于此,比如...

Android event log 说明

目录1. Android 系统中对于 event log 的定义文件 2. event 的类别 3. 手机中查看 event log 事件信息 1. Android 系统中对于 event lo...

event-log-tags

文件位于/system/etc/event-log-tags 用于EventLog.writeEvent(),常见于event log,分析一些event log时需要知道log的一些意义,记录下来...

System UI Tuner分析

前言:practice make perfect. 坚持一些东西,并没有很难。界面展示系统界面调制器是安卓M加入的,当用户长按下拉菜单的齿轮卡3秒中就可以在setting app里加入界面调制器。 ...

Android 开机Process xxx (pid xxxx) has died问题分析

系统中有一个监听BOOT_COMPLETED广播的自启应用,概率性出现启动后被kill掉的现象。Log如下: 08-12 16:48:40.453 773 908 I ActivityMa...

ANR问题分析流程

什么是ANR? ANR即Application Not Responding。出问题时,弹出对话框,提示“XXX无响应“。ANR有哪些类型? 1、按键分发超时 按键按下/抬起/触摸等事件分发超时...

通过Android系统日志监听程序启动事件

经常有这样的需求:在程序A启动之后,在这个程序上覆盖一个界面,让用户输入密码后才能启动程序A,这类场景主要集中在安全软件中。 那应该怎样得知某某程序启动了,系统没有相应的广播,这很难知道程序启动了。...
  • hustpzb
  • hustpzb
  • 2013年01月21日 16:35
  • 29699

event_log之am_pss

logcat_events.txt Line 26: Line 3847: 01-02 13:03:58.149279   887   901 I am_pss  : [16438,10036,co...

Android EventLog简介

希望大家可以关注下gityuan,本文转载自gityuan:http://gityuan.com/2016/05/15/event-log/ 1、手机设备连接电脑 2、执行命令:adb shel...
  • wo_sxn
  • wo_sxn
  • 2016年11月10日 22:22
  • 2699
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Android 解读main log和event log日志信息
举报原因:
原因补充:

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