The pit encountered by BatteryHistorian
- 1. JS compilation problem
- 2. Android Q cannot resolve bugreport issues
- 3. Build a local offline version of Battery Historian
Browse android development and share the problems encountered by Battery Historian in Android development, you can get the following information
1. Solve the problem that the compilation cannot pass when executing go run setup.go;
2. Upload After bgr.zip/bgr.txt, Android Q cannot resolve the problem;
3. Build an offline version of Battery Historian
1. JS compilation problem
As follows, when executing go run setup.go, an error as shown in the following picture will appear. This problem has not been solved in the latest (2020.08.20) code. I don’t know when the problem was introduced. You can refer to Github The description of the BatteryHistorian 183 problem, the main solution is to roll back the version. If you pull the closure-library separately from Github, you need to roll back the version under the path you pulled down first, and then copy it to third_party. You cannot roll back directly under third_party/closure-library, and you will be prompted “ambiguous argument ‘v20170409 ‘: unknown revision or path not in the working tree.”; if after executing go get -d -u github.com/google/battery-historian/...
, there is closure-library folder, then you can roll back the version directly here
// There is a closure-library folder directly go run setup.go (this fails) cd third_party/closure-library/ git reset --hard v20170409 cd - go run setup.go (this passes) // Separately pull closure-library cd closure-library git reset --hard v20170409 Copy closure-library to $GOPATH/src/github.com/google/battery-historian/third_party under go run setup.go
After the fallback, the successful interface
2. Android Q cannot resolve bugreport issues
As shown in the picture below, when you solve the environmental problem, there is a Submit button and you can upload the log, but you find that this interface is opened, prompting “Could not parse aggregated battery stats.”. The cause of this problem should be that after the Android system is updated, some parameters in the code have changed and the parsing fails, similar to the problem of 0.0 and 0. For related problems, see the description of GIthub BatteryHistorian 188. For the solution, see the submission of GitHub lilydjwg. The solution is to modify the local tool code as follows:
diff --git a/checkinparse/checkin_parse.go b/checkinparse/checkin_parse.go index d8d6fcb..4519281 100644 --- a/checkinparse/checkin_parse.go +++ b/checkinparse/checkin_parse.go @@ -1979,7 +1979,7 @@ func parseAppWifi(record []string, app *bspb.BatteryStats_App) ( span>string, []error) // // format: , , , tx_time... func parseControllerData(pc checkinutil.Counter, section string, record []string) (*bspb.BatteryStats_ControllerActivity, error) { - var idle, rx, pwr int64 + var idle, rx, pwr float64 rem, err := parseSlice(pc, section, record, &idle, &rx, &pwr) if err != nil { return span> nil, err @@ -1988,12 +1988,12 @@ func parseControllerData(pc checkinutil .Counter, section string, record []string return nil, fmt.Errorf(`%s didn't contain any transmit level data: "% v"`, section, record) } c := &bspb.BatteryStats_ControllerActivity{ - IdleTimeMsec: proto.Int64(idle), - RxTimeMsec : proto.Int64(rx), - PowerMah: proto.Int64(pwr ), + IdleTimeMsec: proto.Int64( int64(idle)), + RxTimeMsec: proto.Int64(int64(rx)) , + PowerMah: proto.Int64(int64 (pwr)), } for i, t := range rem { - tm, err := strconv .Atoi(t) + tm, err := strconv.ParseFloat(t, 64) if err != nil { return nil, fmt.Errorf("%s contained invalid transmit value: %v", section, err) } diff --git a/packageutils/packageutils.go b/packageutils/packageutils.go index 709274 c..32ad7c2 100644 --- a/packageutils/packageutils.go ++ span>+ b/packageutils/packageutils.go @@ - 51,7 +51,7 @@ const ( ) // abrUIDRE is a regular expression to match an abbreviated uid (ie u0a2). Based on the format printed in frameworks/base/core/java/android/os/UserHandle.java -var abrUIDRE = regexp.MustCompile("u(?P\d+)(?P[ias])(?P \d+)") +var abrUIDRE = regexp IdleTimeMsec: proto.Int64(int64(idle)), + RxTimeMsec: proto.Int64(int64(rx)), + PowerMah: proto.Int64(int64(pwr)), } for i, t := range rem { - tm, err := strconv.Atoi(t) + tm, err := strconv.ParseFloat(t, 64) if err != nil { return nil, fmt. Errorf("%s contained invalid transmit value: % v", section, err) } diff --git a/packageutils/packageutils.go b /packageutils/packageutils.go index 709274c..32ad7c2 100644 --- a/packageutils/packageutils.go +++ b/packageutils/packageutils.go @@ -51,7 +51,7 @ @ const ( ) // abrUIDRE is a regular expression to match an abbreviated uid (ie u0a2). Based on the format printed in frameworks/base/core/java/android/os/UserHandle.java -var abrUIDRE = regexp. span>MustCompile("u(?P\d+) (?P[ias])(?P\d+)") +var abrUIDRE = regexp.MustCompile ("u(?P\d+)(?P[ias]+)(?P\ d+)") // This list is not comprehensive but it will cover the most common cases. The list was curated // from the output of running both 'adb shell dumpsys activity providers' and
3. Build a local offline version of Battery Historian
According to the configuration of base.html, after uploading the bugreport, you need to visit ajax.googleapis.com, cdnjs.cloudflare.com, https://www.google.com and other resources. Some of these resources are due to the wall The reason is that it cannot be accessed. Creating an offline version is to provide these resources locally. Thanks to GitHub user gusha915 for providing the required resources. The specific operations are as follows:
- After executing go get -d -u github.com/google/battery-historian/…, replace the downloaded base.html with the battery-historiantemplatesbase.html under the original code;
- Download the cdn directory and put it into the battery-historianthird_party directory;
- do cd $GOPATH/src/github.com/google/battery-historian;
- Run go run setup.go to compile;
- Run go run cmd/battery-historian/battery-historian.go
class=”token punctuation”>.MustCompile(” u(?P\d+)(?P[ias]+)(?P\d+)”) // This list is not comprehensive but it will cover the most common cases. The list was curated // from the output of running both ‘adb shell dumpsys activity providers’ and
3. Build a local offline version of Battery Historian
According to the configuration of base.html, after uploading the bugreport, you need to visit ajax.googleapis.com, cdnjs.cloudflare.com, https://www.google.com and other resources. Some of these resources are due to the wall The reason is that it cannot be accessed. Creating an offline version is to provide these resources locally. Thanks to GitHub user gusha915 for providing the required resources. The specific operations are as follows:
- After executing go get -d -u github.com/google/battery-historian/…, replace the downloaded base.html with the battery-historiantemplatesbase.html under the original code;
- Download the cdn directory and put it into the battery-historianthird_party directory;
- do cd $GOPATH/src/github.com/google/battery-historian;
- Run go run setup.go to compile;
- Run go run cmd/battery-historian/battery-historian.go