Tag Archives: Google

Finding Wakelocks in Android 7 using Google’s Battery Historian

One of my favorite apps prior to my upgrade to Android 7 (Nougat) was GSam Battery Monitor (the paid version is fully worth it). Unfortunately, Android 7 no longer allows apps like GSam Battery Monitor to track individual application battery usage, CPU usage, or wakelocks. That sucks*.

In Android 7 with Doze, you should see periods of marginal battery usage. The more apps you have, the more background services/sync operations/location broadcasts are running and you’ll see plateaus in battery usage be more slanted. Up until a few weeks ago, battery usage would basically flatline between screen time. I set out to figure out what was causing this. I found a thread on Reddit discussing Battery Historian, so I decided to check it out. This post is somewhat of a review of this tool.

Battery Historian analyzes bug report files and presents the information in an interactive graph with categorized breakdowns of battery usage. Battery Historian is a web application written in Go, and doesn’t appear to have an official release (binary or hosted). This means it’s basically limited to power users to evaluate. Since it’s licensed under Apache 2.0, I compiled and hosted this for my own use at https://historian.jimschubert.us/. Before using my hosted instance of Battery Historian, please heed Google’s warning about bug report files:

Bug reports contain data from the system’s various log files, including personal and private information. Only share bug reports with apps and people you trust.

Running Battery Historian locally isn’t too difficult. I definitely recommend going this route if you’re more of a power user; you don’t need programming experience, only comfort on the command line.

Once you’ve taken a bug report on your device and uploaded it to Battery Historian, you’re presented with a graph of all activity found in the bug report.


The declining black line is the same battery usage visualization you’d see in your Battery Usage application or widget. Other groups of battery draining events are presented as horizontal time-oriented lines; some are either on or off (screen), some show gradients for battery draining in the category (temperature), while others display different colors for different states of the event (Mobile signal strength).

Scroll below the graph and you’ll find a breakdown of system statistics. After a little sorting and investigation, I found that JuiceSSH had locked WiFi for 1.5 hours when I hadn’t used the application for over a week:


After selecting the JuiceSSH app in the left dropdown, this takes you to the App Stats tab which presents some interesting battery usage statistics:

Wakelock Name      | Full Time | Full Count | Partial Time | Partial Count | Window Time | Window Count
JuiceSSH CloudSync |           | 0          | 8m 0s 50ms   | 1             |             | 0           
*alarm*            |           | 0          | 684ms        | 1             |             | 0           
Service Name                            | Time spent started | # starts | # launches
com.sonelli.juicessh.services.CloudSync | 2h 28m 15s 789ms   | 1        | 1         
Process info:
Time spent running actively in the foreground       | 0ms             
Time spent with a service running in the foreground | 0ms             
Time spent on top                                   | 0ms             
Time spent on top while the device was sleeping     | 0ms             
Time spent running actively in the background       | 1h 33m 10s 343ms
Time spent cached                                   | 38ms            

Looks like, in my case, JuiceSSH Cloud Sync had 8 minutes worth of wakelocks, 2.5 hours of a service running in which 1.5 hours of that was actively running in the background. JuiceSSH unfortunately doesn’t have configuration options for Cloud Sync, so I’ve disabled it. I’ve noticed an improvement since disabling JuiceSSH Cloud Sync.

Although I was a little miffed that the Android 7 update borked GSam’s ability to report on per-application usage, I found Battery Historian to be a really insightful tool. From and Android Development perspective it would be a nice utility to evaluate your application’s effect on the system through normal use. It may be a little overkill from a user or power user’s perspective, though. My Nexus 5X was getting about 18 hours of pretty heavy usage (including my son watching YouTube videos). After disabling JuiceSSH Cloud Sync, I’m seeing about 20 hours of battery out of the same usage. Does that really matter if you’re like me and you charge your phone every night? 👻

* I’ve read that GSam Battery Monitor with root still works as expected on Nougat.

Install nodejs under ChromeOS (CR-48)

Why would I want to do this?

I’m a software developer. I love javascript. I love node.js. I love the direction Google is taking web development, user interaction, and the web in general. Installing node.js opens up a lot of possibilities for me on my CR-48. I don’t know if this will work on anything other than the CR-48, considering the machine has to be in developer mode for these instructions.

If you don’t have a chromebook yet, or you don’t know what they are… where have you been? But seriously, visit http://www.google.com/chromebook/ and check them out.

Before I start, let me first say that following these instructions may void your warranty if you have one, open your machine up to vulnerabilities, or replace existing files and cause instability. If you don’t know how to revert or fix any issues that may occur, don’t continue. I offer no sort of warranty, support, or anything else. Consider this a ‘hack’ of sorts.

I found a blog post detailing how to install an archive package and ruby on rails in ChromeOS. I followed part of these instructions and I have modified them to fit my needs.


  • You must have a Chromebook, possibly only the CR-48
  • You must be in ‘developer mode
  • You must have a writable rootfs (see above link for developer mode)


Downloading and installing xz

  1. Download the xz package
  2. Enter crosh or VT-2 (CTRL+ALT+T or CTRL+ALT+→)
  3. If VT-2, login to the shell
  4. Run on the terminal: cd /home/chronos/user/Downloads
  5. Run on the terminal: tar -zxf xz-*.tar.gz
  6. Run on the terminal: cd usr
  7. Run on the terminal: cp * /usr/

Now that xz is installed in /usr/bin (verify by running on the command line: which xz), you will be able to extract certain files that are necessary for nodejs and possibly any other package you’d like.

Download and install nodejs and openssl.
The site claims openssl is optional, but node wouldn’t open without it

  1. Download nodejs
  2. Download openssl
  3. Enter the terminal again and navigate to /home/chronos/user/Downloads
  4. Run on the terminal: xz -d node*.xz
  5. Run on the terminal: tar -zxfv openssl*.tar.gz
  6. Run on the terminal: cd usr
  7. Run on the terminal: cp * /usr/

Now you should have a working install of nodejs. You can use npm, for instance, to install express and jade.
node.js and express running on ChromeOS

Running additional Google Chrome profiles in Linux

Google Chrome supports running multiple profiles.

In newer versions of Google Chrome, you’ll be able to enable profiles by navigating to chrome://flags and enabling Multiple Profiles. Restart the browser, and you’ll have a switcher and multiple profiles which can be activated in different windows. This allows you to sync to different gmail accounts. For instance, if you have a personal account and a work or school account, each with different bookmarks… you can run two or three different profiles and have access to all of your data.

If you’re using an older version of Chrome or Chromium and you don’t have the Multiple Profiles option, you can use the switch


when opening the browser and the profile for your session will be pulled from the given folder instead of the Default folder. The folder specified should be created automatically. To be safe, I like to create the folder before providing it as an argument.

As explained here, the default directory is located at:

Google Chrome: ~/.config/google-chrome/Default
Chromium: ~/.config/chromium/Default

Open a terminal and create a new directory for your second profile. For instance:

mkdir ~/.config/google-chrome/work

Then, open Google Chrome with the switch:

google-chrome --user-data-dir='~/.config/google-chrome/work'  &

If this is a profile you’ll be using often, you can also create a menu entry under Applications -> Internet (‘Chrome|Work’, maybe?).

Linking to a Google Doc .doc as .pdf

I recently decided to update my resume, which forced me to revisit an issue I originally faced when posting my resume to my site: I am writing it as a doc file in Google Docs but I want to link to it as a PDF and have my updates visible immediately.

I know this is a selfish thing to want, and I settled for the quick and easy solution of copying the PDF to my host and pointing to the local file. After updating my resume today, I thought, “I’m sure someone has already encountered this.” A quick search on Google took me to a Google knol article in which the other provides a link which will convert the Google Doc (provided by a document id) to a desired format. This link causes the PDF to download immediately, but when passed to the document viewer, it works as expected. Perfect!

Here is the article citation:

Google Docs Guide 2. Google Docs Help: Howto Link Straight To A Public Docs Pdf Or Other Supported File [Internet]. Version 2. Knol. 2008 Oct 8. Available from: http://knol.google.com/k/google-docs-guide-2/google-docs-help-howto-link-straight-to/2vcnhxffa8r42/20.

And the link template described in the article:


Check out my resume for an example.