checkinparse

package
v0.0.0-...-d2356ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package checkinparse contains functions to parse checkin report into batterystats proto.

Index

Constants

This section is empty.

Variables

View Source
var (

	// KnownUIDs lists all constant UIDs defined in system/core/include/private/android_filesystem_config.h.
	// GIDs are excluded. These should never be renumbered.
	KnownUIDs = map[int32]string{
		0:    "ROOT",
		1000: "ANDROID_SYSTEM",
		1001: "RADIO",
		1002: "BLUETOOTH",
		1003: "GRAPHICS",
		1004: "INPUT",
		1005: "AUDIO",
		1006: "CAMERA",
		1007: "LOG",
		1008: "COMPASS",
		1009: "MOUNT",
		1010: "WIFI",
		1011: "ADB",
		1012: "INSTALL",
		1013: "MEDIA",
		1014: "DHCP",
		1015: "SDCARD_RW",
		1016: "VPN",
		1017: "KEYSTORE",
		1018: "USB",
		1019: "DRM",
		1020: "MDNSR",
		1021: "GPS",

		1023: "MEDIA_RW",
		1024: "MTP",

		1026: "DRMRPC",
		1027: "NFC",
		1028: "SDCARD_R",
		1029: "CLAT",
		1030: "LOOP_RADIO",
		1031: "MEDIA_DRM",
		1032: "PACKAGE_INFO",
		1033: "SDCARD_PICS",
		1034: "SDCARD_AV",
		1035: "SDCARD_ALL",
		1036: "LOGD",
		1037: "SHARED_RELRO",
		1038: "DBUS",
		1039: "TLSDATE",
		1040: "MEDIA_EX",
		1041: "AUDIOSERVER",
		1042: "METRICS_COLL",
		1043: "METRICSD",
		1044: "WEBSERV",
		1045: "DEBUGGERD",
		1046: "MEDIA_CODEC",
		1047: "CAMERASERVER",
		1048: "FIREWALL",
		1049: "TRUNKS",
		1050: "NVRAM",
		1051: "DNS",
		1052: "DNS_TETHER",
		1053: "WEBVIEW_ZYGOTE",
		1054: "VEHICLE_NETWORK",
		1055: "MEDIA_AUDIO",
		1056: "MEDIA_VIDEO",
		1057: "MEDIA_IMAGE",
		1058: "TOMBSTONED",
		1059: "MEDIA_OBB",
		1060: "ESE",
		1061: "OTA_UPDATE",

		2000: "SHELL",
		2001: "CACHE",
		2002: "DIAG",

		3001: "NET_BT_ADMIN",
		3002: "NET_BT",
		3003: "INET",
		3004: "NET_RAW",
		3005: "NET_ADMIN",
		3006: "NET_BW_STATS",
		3007: "NET_BW_ACCT",
		3008: "NET_BT_STACK",
		3009: "READPROC",
		3010: "WAKELOCK",

		9997: "EVERYBODY",
		9998: "MISC",
		9999: "NOBODY",
	}

	// BatteryStatsIDMap contains a list of all the fields in BatteryStats_* messages that are the IDs for the message.
	BatteryStatsIDMap = map[reflect.Type]map[int]bool{

		reflect.TypeOf(&bspb.BatteryStats_App_Apk_Service{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_Process{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_ScheduledJob{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_Sensor{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_Sync{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_UserActivity{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_Wakelock{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_App_WakeupAlarm{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_ControllerActivity_TxLevel{}): {
			0: true,
		},

		reflect.TypeOf(&bspb.BatteryStats_System_Battery{}): {
			5: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_BluetoothState{}): {
			0: true,
		},

		reflect.TypeOf(&bspb.BatteryStats_System_DataConnection{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_KernelWakelock{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_PowerUseItem{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_PowerUseSummary{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_ScreenBrightness{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_SignalStrength{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_WakeupReason{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_WifiSignalStrength{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_WifiSupplicantState{}): {
			0: true,
		},
		reflect.TypeOf(&bspb.BatteryStats_System_WifiState{}): {
			0: true,
		},
	}
)

Functions

func CreateBatteryReport

func CreateBatteryReport(cp *sessionpb.Checkin) *checkinutil.BatteryReport

CreateBatteryReport creates a checkinutil.BatteryReport from the given sessionpb.Checkin.

func GroupName

func GroupName(sharedUIDLabel string) string

GroupName returns a predefined UID group name for the given sharedUserID label. If there is no predefined name, then an empty string is returned.

func PackageUIDGroupName

func PackageUIDGroupName(pkg string) string

PackageUIDGroupName returns the predefined group name for the given package name. It will return an empty string if there is no predefined group name.

func ParseBatteryStats

func ParseBatteryStats(pc checkinutil.Counter, cr *checkinutil.BatteryReport, pkgs []*usagepb.PackageInfo) (*bspb.BatteryStats, []string, []error)

ParseBatteryStats parses the aggregated battery stats in checkin report according to frameworks/base/core/java/android/os/BatteryStats.java.

func SortByAbsTime

func SortByAbsTime(items []*WakelockInfo)

SortByAbsTime ranks a slice of wakelocks by the absolute value of duration in desc order.

func SortByCount

func SortByCount(items []*WakelockInfo)

SortByCount ranks a slice of wakelocks by count.

func SortByTime

func SortByTime(items []*WakelockInfo)

SortByTime ranks a slice of wakelocks by duration.

func SystemBattery

func SystemBattery(pc checkinutil.Counter, record []string, system *bspb.BatteryStats_System) (string, []error)

SystemBattery parses "bt" (BATTERY_DATA) in System.

format:

7,0,l,bt,N/A,4946,4946,25430,25430 (reportVersion < 8)
9,0,l,bt,0,19447364,2268899,19466586,2288120,1411399763148,19399912,2221446 (8 <= reportVersion < 18)
9,0,l,bt,0,19447364,2268899,19466586,2288120,1411399763148,19399912,2221446,3000000 (18 <= reportVersion <= 20)
9,0,l,bt,0,19447364,2268899,19466586,2288120,1411399763148,19399912,2221446,3000000,3240000,3400000 (reportVersion >= 20)

Types

type WakelockInfo

type WakelockInfo struct {
	Name          string
	UID           int32
	Duration      time.Duration
	MaxDuration   time.Duration
	TotalDuration time.Duration
	Count         float32
}

WakelockInfo is a data structure used to sort wakelocks by time or count.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL