Documentation ¶
Overview ¶
Package bugreportutils is a library of common bugreport parsing functions.
Index ¶
- Constants
- Variables
- func Contents(fname string, b []byte) (map[string][]byte, error)
- func DumpState(contents string) (time.Time, error)
- func ExtractBatterystatsCheckin(input string) string
- func ExtractBugReport(fname string, contents []byte) (string, string, error)
- func ExtractPIDMappings(contents string) (map[string][]AppInfo, []string)
- func IsBugReport(b []byte) bool
- func SecFractionAsMs(fr string) (int64, error)
- func TimeStampToMs(timestamp, remainder string, loc *time.Location) (int64, error)
- func TimeZone(contents string) (*time.Location, error)
- type AppInfo
- type MetaInfo
- type SensorInfo
Constants ¶
const ( // GPSSensorNumber is the hard-coded sensor number defined in frameworks/base/core/java/android/os/BatteryStats.Sensor GPSSensorNumber = -10000 // TimeLayout is the timestamp layout commonly printed in bug reports. TimeLayout = "2006-01-02 15:04:05" )
Variables ¶
var ( // BugReportSectionRE is a regular expression to match the beginning of a bug report section. BugReportSectionRE = regexp.MustCompile(`------\s+(?P<section>.*)\s+-----`) // TimeZoneRE is a regular expression to match the timezone string in a bug report. TimeZoneRE = regexp.MustCompile(`^\[persist.sys.timezone\]:\s+\[` + `(?P<timezone>\S+)\]`) // DumpstateRE is a regular expression that matches the time information from the dumpstate line at the start of a bug report. DumpstateRE = regexp.MustCompile(`==\sdumpstate:\s(?P<timestamp>\d+-\d+-\d+\s\d+:\d+:\d+)`) )
Functions ¶
func Contents ¶
Contents returns a map of the contents of each file from the given bytes slice, with the key being the file name. Supported file formats are text/plain and application/zip. For zipped files, each file name will be prepended by the zip file's name. An error will be non-nil for processing issues.
func ExtractBatterystatsCheckin ¶
ExtractBatterystatsCheckin extracts and returns only the lines in input that are included in the "CHECKIN BATTERYSTATS" section.
func ExtractBugReport ¶
ExtractBugReport extracts and returns only the first valid bug report data in the given contents. The second returned parameter will be the determined file name.
func ExtractPIDMappings ¶
ExtractPIDMappings returns mappings from PID to app names and UIDs extracted from the bug report.
func IsBugReport ¶
IsBugReport tries to determine if the given bytes resembles a bug report.
func SecFractionAsMs ¶
SecFractionAsMs converts the fraction of a second to milliseconds. e.g. "123456" from "27.123456" corresponds to 123ms (and 27 seconds).
func TimeStampToMs ¶
TimeStampToMs converts a timestamp in the TimeLayout format, combined with the fraction of a second, to a unix ms timestamp based on the location.
Types ¶
type MetaInfo ¶
type MetaInfo struct { DeviceID string SdkVersion int BuildFingerprint string ModelName string Sensors map[int32]SensorInfo }
MetaInfo contains metadata about the device being analyzed
func ParseMetaInfo ¶
ParseMetaInfo extracts the device ID, build fingerprint and model name from the bug report.