Source link:

Battery Historian

Battery Historian is a tool to inspect battery related information and events on an Android device running Android 5.0 Lollipop (API level 21) and later, while the device was not plugged in. It allows application developers to visualize system and application level events on a timeline with panning and zooming functionality, easily see various aggregated statistics since the device was last fully charged, and select an application and inspect the metrics that impact battery specific to the chosen application. It also allows an A/B comparison of two bugreports, highlighting differences in key battery related metrics.

Getting Started

Using Docker

Install Docker.

Run the Battery Historian image. Choose a port number and replace <port> with that number in the commands below:

docker -- run -p <port>:9999 --port 9999 

For Linux and Mac OS X:

  • That's it, you're done! Historian will be available at http://localhost:<port>.

For Windows:

  • You may have to enable Virtualization in your BIOS.

  • Once you start Docker, it should tell you the IP address of the machine it is using. If, for example, the IP address is 123.456.78.90, Historian will be available at http://123.456.78.90:<port>.

For more information about the port forwarding, see the Docker documentation.

Building from source code

Make sure you have at least Golang version 1.8.1:

  • Follow the instructions available at for downloading and installing the Go compilers, tools, and libraries.
  • Create a workspace directory according to the instructions at
  • Ensure that GOPATH and GOBIN environment variables are appropriately set and added to your $PATH environment variable. $GOBIN should be set to $GOPATH/bin.
    • For Windows, you may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.

    • For Linux and Mac OS X, you can add the following lines to your ~/.bashrc or ~/.profile files (assuming your workspace is $HOME/work):

      export GOPATH=$HOME/work export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN 

Next, install Git from if it's not already installed.

Next, make sure Python 2.7 (NOT Python 3!) is installed. See if it isn't, and ensure that python is added to your $PATH environment variable.

Next, install Java from

Next, download the Battery Historian code and its dependencies:

$ go get -d -u 

Finally, run Battery Historian!

$ cd $GOPATH/src/  # Compile Javascript files using the Closure compiler $ go run setup.go  # Run Historian on your machine (make sure $PATH contains $GOBIN) $ go run cmd/battery-historian/battery-historian.go [--port <default:9999>] 

Remember, you must always run battery-historian from inside the $GOPATH/src/ directory:

cd $GOPATH/src/ go run cmd/battery-historian/battery-historian.go [--port <default:9999>] 

How to take a bug report

To take a bug report from your Android device, you will need to enable USB debugging under Settings > System > Developer Options. On Android 4.2 and higher, the Developer options screen is hidden by default. You can enable this by following the instructions here.

To obtain a bug report from your development device running Android 7.0 and higher:

$ adb bugreport 

For devices 6.0 and lower:

$ adb bugreport > bugreport.txt 

Start analyzing!

You are all set now. Run historian and visit http://localhost:9999 and upload the bugreport.txt file to start analyzing.



System stats:

App stats:


To reset aggregated battery stats and history:

adb shell dumpsys batterystats --reset 
Wakelock analysis

By default, Android does not record timestamps for application-specific userspace wakelock transitions even though aggregate statistics are maintained on a running basis. If you want Historian to display detailed information about each individual wakelock on the timeline, you should enable full wakelock reporting using the following command before starting your experiment:

adb shell dumpsys batterystats --enable full-wake-history 

Note that by enabling full wakelock reporting the battery history log overflows in a few hours. Use this option for short test runs (3-4 hrs).

Kernel trace analysis

To generate a trace file which logs kernel wakeup source and kernel wakelock activities:

First, connect the device to the desktop/laptop and enable kernel trace logging:

$ adb root $ adb shell  # Set the events to trace. $ echo "power:wakeup_source_activate" >> /d/tracing/set_event $ echo "power:wakeup_source_deactivate" >> /d/tracing/set_event  # The default trace size for most devices is 1MB, which is relatively low and might cause the logs to overflow. # 8MB to 10MB should be a decent size for 5-6 hours of logging.  $ echo 8192 > /d/tracing/buffer_size_kb  $ echo 1 > /d/tracing/tracing_on 

Then, use the device for intended test case.

Finally, extract the logs:

$ echo 0 > /d/tracing/tracing_on $ adb pull /d/tracing/trace <some path>  # Take a bug report at this time. $ adb bugreport > bugreport.txt 


Historian plots and relates events in real time (PST or UTC), whereas kernel trace files logs events in jiffies (seconds since boot time). In order to relate these events there is a script which approximates the jiffies to utc time. The script reads the UTC times logged in the dmesg when the system suspends and resumes. The scope of the script is limited to the amount of timestamps present in the dmesg. Since the script uses the dmesg log when the system suspends, there are different scripts for each device, with the only difference being the device-specific dmesg log it tries to find. These scripts have been integrated into the Battery Historian tool itself.

Power monitor analysis

Lines in power monitor files should have one of the following formats, and the format should be consistent throughout the entire file:

<timestamp in epoch seconds, with a fractional component> <amps> <optional_volts> 


<timestamp in epoch milliseconds> <milliamps> <optional_millivolts> 

Entries from the power monitor file will be overlaid on top of the timeline plot.

To ensure the power monitor and bug report timelines are somewhat aligned, please reset the batterystats before running any power monitor logging:

adb shell dumpsys batterystats --reset 

And take a bug report soon after stopping power monitor logging.

If using a Monsoon:

Download the AOSP Monsoon Python script from

# Run the script. $ --serialno 2294 --hz 1 --samples 100000 -timestamp | tee monsoon.out  # ...let device run a while...  $ stop 
Modifying the proto files

If you want to modify the proto files (pb/*/*.proto), first download the additional tools necessary:

Install the standard C++ implementation of protocol buffers from

Download the Go proto compiler:

$ go get -u 

The compiler plugin, protoc-gen-go, will be installed in $GOBIN, which must be in your $PATH for the protocol compiler, protoc, to find it.

Make your changes to the proto files.

Finally, regenerate the compiled Go proto output files using

Other command line tools
# System stats $ go run cmd/checkin-parse/local_checkin_parse.go --input=bugreport.txt  # Timeline analysis $ go run cmd/history-parse/local_history_parse.go --summary=totalTime --input=bugreport.txt  # Diff two bug reports $ go run cmd/checkin-delta/local_checkin_delta.go --input=bugreport_1.txt,bugreport_2.txt 


If you've found an error in this project, please file an issue:


Copyright 2016 Google, Inc.

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

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.


Official Google Actions SDK is written in Node.js. But in many situations voice interfaces like Google Home or Google Assistant will extend or replace mobile apps. If you are old fashioned Android engineer and the most of your code is already written in Java, why not reuse it and build voice extension to app on your own? And this is the main reason to build Google Actions Java SDK - enabling as much developers as possible to build their brilliant ideas for Google Assistant and Home.

Currently this is just working proof of concept of Google Actions Java SDK. It means that there is no documentation, fixed interface, (not much) unit tests and many, many others.

Google Actions Java SDK is build based on official Node.js library, but it's not a mirror copy of it. The goal is to make it fully compatible with Conversational Protocol of Assistant Platform.

Applozic Android Video Calling SDK lets you integrate video call, audio call, real time chat and in-app messaging in just few lines of code.

A versatile layout that fades its edges regardless of child view type.

WDate is a short way utility class that wraps the standard Date class, providing many useful methods without using the Calendar object.

This class aims to help developers to avoid writing boring DateUtils classes for every project.

Simplify your code to its minimum expression with this set of Kotlin extensions for Realm. Forget about all boilerplate related with Realm API and performs database operations in one line of code.

This library allows to use Material steppers inside Android applications.


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes