diff options
Diffstat (limited to 'src/com/android/loganalysis/parser/EventsLogParser.java')
-rw-r--r-- | src/com/android/loganalysis/parser/EventsLogParser.java | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/src/com/android/loganalysis/parser/EventsLogParser.java b/src/com/android/loganalysis/parser/EventsLogParser.java index 8dc2ca3..b2d6b06 100644 --- a/src/com/android/loganalysis/parser/EventsLogParser.java +++ b/src/com/android/loganalysis/parser/EventsLogParser.java @@ -17,6 +17,7 @@ package com.android.loganalysis.parser; import com.android.loganalysis.item.IItem; +import com.android.loganalysis.item.BootEventItem; import com.android.loganalysis.item.LatencyItem; import com.android.loganalysis.item.TransitionDelayItem; @@ -34,6 +35,18 @@ import java.util.regex.Pattern; */ public class EventsLogParser implements IParser { + private static final String DATE = "date"; + private static final String TIME = "time"; + private static final String TRANSITION_INFO = "transitioninfo"; + private static final String PACKAGE_KEY = "806"; + private static final String ACTIVITY_KEY = "871"; + private static final String TRANSITION_DELAY_KEY = "319"; + private static final String STARTING_WINDOW_DELAY_KEY = "321"; + private static final String COLD_LAUNCH_KEY = "945"; + private static final String WINDOWS_DRAWN_DELAY_KEY = "322"; + private static final String BOOT_PROGRESS = "boot_progress_"; + private static final String STOP_ANIM = "sf_stop_bootanim"; + // 09-18 23:56:19.376 1140 1221 I sysui_multi_action: // [319,51,321,50,322,190,325,670,757,761,758,7,759,1,806,com.google.android.calculator,871, // com.android.calculator2.Calculator,905,0,945,41] @@ -46,15 +59,21 @@ public class EventsLogParser implements IParser { + "(?<time>[0-9:.]*)\\s+\\d+\\s+\\d+ I sysui_latency: \\[(?<action>.*)," + "(?<delay>.*)\\]$"); - private static final String DATE = "date"; - private static final String TIME = "time"; - private static final String TRANSITION_INFO = "transitioninfo"; - private static final String PACKAGE_KEY = "806"; - private static final String ACTIVITY_KEY = "871"; - private static final String TRANSITION_DELAY_KEY = "319"; - private static final String STARTING_WINDOW_DELAY_KEY = "321"; - private static final String COLD_LAUNCH_KEY = "945"; - private static final String WINDOWS_DRAWN_DELAY_KEY = "322"; + // 05-24 09:14:59.999 720 720 I boot_progress_start: 40429 + private static final Pattern BOOT_DURATION = + Pattern.compile( + String.format( + "^\\d+-\\d+\\s(?<time>[0-9:.]*)\\s+\\S+\\s+\\S+\\sI (?<event>%s\\S+): " + + "(?<duration>\\d+)$", + BOOT_PROGRESS)); + + // 05-24 09:15:20.737 516 542 I sf_stop_bootanim: 61167 + private static final Pattern STOPANIM_DURATION = + Pattern.compile( + String.format( + "^\\d+-\\d+\\s(?<time>[0-9:.]*)\\s+\\S+\\s+\\S+\\sI (?<event>%s): " + + "(?<duration>\\d+)$", + STOP_ANIM)); @Override public IItem parse(List<String> lines) { @@ -143,6 +162,29 @@ public class EventsLogParser implements IParser { } /** + * Method to parse the boot information from the events log + * + * @param input + * @return + * @throws IOException + */ + public List<BootEventItem> parseBootEventInfo(BufferedReader input) throws IOException { + List<BootEventItem> eventItems = new ArrayList<BootEventItem>(); + String line; + while ((line = input.readLine()) != null) { + Matcher match = null; + if ((match = matches(BOOT_DURATION, line)) != null + || (match = matches(STOPANIM_DURATION, line)) != null) { + BootEventItem eventItem = new BootEventItem(); + eventItem.setEventName(match.group("event")); + eventItem.setDuration(Double.parseDouble(match.group("duration"))); + eventItems.add(eventItem); + } + } + return eventItems; + } + + /** * Checks whether {@code line} matches the given {@link Pattern}. * * @return The resulting {@link Matcher} obtained by matching the {@code line} against |