summaryrefslogtreecommitdiff
path: root/src/com/android/loganalysis/parser/DumpsysProcStatsParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/loganalysis/parser/DumpsysProcStatsParser.java')
-rw-r--r--src/com/android/loganalysis/parser/DumpsysProcStatsParser.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/com/android/loganalysis/parser/DumpsysProcStatsParser.java b/src/com/android/loganalysis/parser/DumpsysProcStatsParser.java
new file mode 100644
index 0000000..010036b
--- /dev/null
+++ b/src/com/android/loganalysis/parser/DumpsysProcStatsParser.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 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.DumpsysProcStatsItem;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link IParser} to parse procstats and create a mapping table of process names and UIDs
+ */
+public class DumpsysProcStatsParser implements IParser {
+
+ /**
+ * Matches: * com.google.android.googlequicksearchbox:search / u0a19 / v300401240: -----
+ */
+ private static final Pattern UID = Pattern.compile("^\\s*\\* (.*):?.*/ (.*)/.*");
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return The {@link DumpsysProcStatsItem}.
+ */
+ @Override
+ public DumpsysProcStatsItem parse(List<String> lines) {
+ DumpsysProcStatsItem item = new DumpsysProcStatsItem();
+ for (String line : lines) {
+ Matcher m = UID.matcher(line);
+ if(m.matches()) {
+ item.put(m.group(2).trim(), m.group(1).trim());
+ }
+ }
+ return item;
+ }
+
+}