summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/loganalysis/item/BootEventItem.java54
-rw-r--r--src/com/android/loganalysis/parser/EventsLogParser.java60
2 files changed, 105 insertions, 9 deletions
diff --git a/src/com/android/loganalysis/item/BootEventItem.java b/src/com/android/loganalysis/item/BootEventItem.java
new file mode 100644
index 0000000..ec948bb
--- /dev/null
+++ b/src/com/android/loganalysis/item/BootEventItem.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 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 com.android.loganalysis.item;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/** An {@link IItem} used to store boot event info logged in event log. */
+public class BootEventItem extends GenericItem {
+
+ /** Constant for JSON output */
+ public static final String EVENT_NAME = "EVENT_NAME";
+
+ public static final String EVENT_DURATION = "DURATION";
+
+ private static final Set<String> ATTRIBUTES =
+ new HashSet<String>(Arrays.asList(EVENT_NAME, EVENT_DURATION));
+
+ /** The constructor for {@link BootEventItem}. */
+ public BootEventItem() {
+ super(ATTRIBUTES);
+ }
+
+ public String getEventName() {
+ return (String) getAttribute(EVENT_NAME);
+ }
+
+ public void setEventName(String eventName) {
+ setAttribute(EVENT_NAME, eventName);
+ }
+
+ public Double getDuration() {
+ return (Double) getAttribute(EVENT_DURATION);
+ }
+
+ public void setDuration(Double eventDuration) {
+ setAttribute(EVENT_DURATION, eventDuration);
+ }
+}
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