blob: 010036b54c2afdeb65e24d68b28b423b8ca20f43 [file] [log] [blame]
/*
* 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;
}
}