summaryrefslogtreecommitdiff
path: root/src/com/android/loganalysis/parser/DumpsysParser.java
diff options
context:
space:
mode:
authorEric Rowe <erowe@google.com>2013-03-19 11:28:41 -0700
committerEric Rowe <erowe@google.com>2013-03-19 16:06:00 -0700
commitf1d71ef83c53b4e12434bd1ee32073c349f9faa3 (patch)
tree55246282bb7ed72af2befffcccd0edfc90209451 /src/com/android/loganalysis/parser/DumpsysParser.java
parent891a0cb4f32ee00b3ea3d3dfbcd09aaab2f5796f (diff)
downloadloganalysis-f1d71ef83c53b4e12434bd1ee32073c349f9faa3.tar.gz
Add dumpsys parser for bugreports.
Change-Id: I526c6c73d5dbb33921b52a27dfabe5aae29e63ba
Diffstat (limited to 'src/com/android/loganalysis/parser/DumpsysParser.java')
-rw-r--r--src/com/android/loganalysis/parser/DumpsysParser.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/com/android/loganalysis/parser/DumpsysParser.java b/src/com/android/loganalysis/parser/DumpsysParser.java
new file mode 100644
index 0000000..151db33
--- /dev/null
+++ b/src/com/android/loganalysis/parser/DumpsysParser.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013 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.parser;
+
+import com.android.loganalysis.item.DumpsysBatteryInfoItem;
+import com.android.loganalysis.item.DumpsysItem;
+
+import java.util.List;
+
+/**
+ * A {@link IParser} to handle the output of the dumpsys section of the bugreport.
+ */
+public class DumpsysParser extends AbstractSectionParser {
+ private static final String BATTERY_INFO_SECTION_REGEX = "DUMP OF SERVICE batteryinfo:";
+ private static final String NOOP_SECTION_REGEX = "DUMP OF SERVICE .*";
+
+ private DumpsysItem mDumpsys = new DumpsysItem();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return The {@link DumpsysItem}
+ */
+ public DumpsysItem parse(List<String> lines) {
+ setup();
+ for (String line : lines) {
+ parseLine(line);
+ }
+ commit();
+
+ return mDumpsys;
+ }
+
+ /**
+ * Sets up the parser by adding the section parsers.
+ */
+ protected void setup() {
+ addSectionParser(new DumpsysBatteryInfoParser(), BATTERY_INFO_SECTION_REGEX);
+ addSectionParser(new NoopParser(), NOOP_SECTION_REGEX);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void commit() {
+ // signal EOF
+ super.commit();
+
+ if (mDumpsys != null) {
+ mDumpsys.setBatteryInfo(
+ (DumpsysBatteryInfoItem) getSection(DumpsysBatteryInfoItem.TYPE));
+ }
+ }
+} \ No newline at end of file