Monday, 23 April 2012

Galaxy Nexus battery drain


Just a quick post about my Galaxy Nexus. I have it for twee weeks now, and I almost started to accept the crappy battery life: unplugging it at 8:00, realizing at 20:00 that it might be a good idea to turn off the data and 3G. Meh, crappy indeed.

Yesterday I decided to try 2G only for a while, with some noticeable improvements. I started some further investigation and ended up installing Better Battery Stats. This program showed an interesting statistic: my phone refused to go in deep sleep, and a mysterious process (or service?) called BTLowPower seemed to be the little daemon that kept my phone awake day and night. I'm pretty bad at word games, so it took me some googling before I realized that it was some Bluetooth thingy. Hmm. I barely use Bluetooth. Some more googling: Bluetooth on stock Galaxy Nexus is buggy. It tends to be stuck in some phase which could best be described as: the thing tries to enable bluetooth and fails miserably.

Fast forward (got some work to do): reboot phone, if Bluetooth appears magically to be enabled, disable it. Result: no more BTLowPower!

Net result: after 7 hours, 80% battery left. And that's with data synchronization enabled and playing around with the phone (36 minutes screen time).

Boost on Visual Studio 11

Boost 1.49 is full of references to VS11, although it is still not supported by default. Some tweaks I did:

tools\build\v2\engine\build.bat
The section :Guess_Toolset has to know that VS11 exists, add the following part:
call :Clear_Error
if NOT "_%VS110COMNTOOLS%_" == "__" (
    set "BOOST_JAM_TOOLSET=vc11"
    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
    goto :eof)
 Same goes for :Config_Toolset, add the following part:
:Skip_VC10
if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc11_" goto Skip_VC11
if NOT "_%VS110COMNTOOLS%_" == "__" (
    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
    )
if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
    if "_%VCINSTALLDIR%_" == "__" (
        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
        ) )
set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
rem change it back because VC11 is not officially known.
set "BOOST_JAM_TOOLSET=msvc"
set "_known_=1"
Credits for the part above: http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html

In my case, the build system was still using the compiler from the VS10 installation and I had to tweak some more.

Open the following file:
tools\build\v2\tools\msvc.jam

I basically searched the file for occurences of 10.0 and added equivalent entries for 11.0
credits: http://article.gmane.org/gmane.comp.lib.boost.devel/228596/

That should do it. Open up a Visual Studio command prompt and bootstrap the build system.
bootstrap.bat
Check for errors, and start the build process, in my case I executed the following command:
 b2 link=static threading=multi address-model=64