[HD2 Android SD Development] EngineerMind:
65ma drain possible explanation

Being a hardware and software engineer, this is what I am thinking the problem is from my trial and error testing...

Since the common trait of this battery drain issue is "63ma" (or very close to it), it leads me to believe that it is the same "module" inside the HD2 that is drawing this current (since the amount of current is almost exactly the same even when it appears to be caused by different things like gps, wifi, lights, bluetooth, ect).

So, I am thinking that this "module" is the "radio" in the HD2, and that the "radio" module controls a lot of related "features" like wifi, gps, bluetooth, and maybe even the leds.

And I am thinking that when the radio is in the "awake" state, it draws this 63ma, and when it's FULLY asleep/standby it draws only a few ma. I am also thinking that if the OS requests ANY activity of either the wifi, BT, gps or the cell radio, then that will "wake-up" the radio and cause it to start using 65ma of current. And ONLY when ALL requests from ANY/ALL features of the radio are set to "standby", will the radio actually go into standby and drop the current to a few ma. However, if even just one feature/section of the radio is still in a "wake" state (such as just the Bluetooth feature is active, but nothing else is), then the WHOLE radio stays awake, causing the high drain. Thus, ALL aspects/features of the radio need to be set in a standby state for the radio to truly power down fully into a standby mode.

The one issue I have found with my "Energy" ROM for my HD2 is that if I turn on bluetooth while in Windows Mobile mode, then run android (which has the bluetooth feature set to "off" under android), the android OS will simply assume the BT radio is off when it boots up because that's how I configured BT the last time I was in android. Thus, it doesn't bother to send a "turn off BT" to the radio module because it thinks it's already off (because it assume it must be off because the device was just "Powered on" in it's eyes).

But the problem (with at least my rom) is that when WM passes control over to android, it doesn't shut down bluetooth, so the bluetooth part of the radio will stay "awake" because it was last told to turn ON by WM, and was never told subsequently to go into "standby" mode from either WM or android. Thus, the 65ma draw.

But, there is a quick fix for this particular "out-of-sync" issue - while in android, I just have to turn bluetooth on, then off which will force android to send the "go to sleep" command to the bluetooth radio, and thus allow the radio to fully go to sleep and now the OS and the bt feature are now in sync. As you can see, this "out-of-sync" issue of what the OS thinks the state of the radio is vs. the actual state the radio is in, can easily cause the radio to stay awake because if the android OS thinks the radio should already be sleeping, it won't bother to send a "sleep" command to it.

And you can see that this out-of-sync problem could manifest itself in all sorts of crazy conclusions by users as to the cause because they will say "but I have bluetooth set to OFF in android so it can't be that" when in fact it actually is a bluetooth issue because the parent WM rom didn't properly shut down BT fully (which I think it is suppose to do when Haret.exe says "close all resources", which I read Haret should do from other posts I read).

Additionally, there is a side issue of a bug in the BT driver as brainmaster mentioned (thank you brainmaster because I did not see that in anyone else's post) which seems to prevent android from telling the bluetooth radio to properly "go into standyby". It can tell the BT feature to shut off, but apparently it can't tell it to go into "standby" mode. Thus if you turn on the BT feature in android, it will use 65ma in standby because the driver can't successfully tell the BT radio to go into "standby", it can only tell it to turn "fully on" or "fully off". So until the BT driver is fixed, I can't use bluetooth unless I am willing to let my phone use 65ma when in standby.

With my Energy (parent) rom, the only issue I found was related to the hand-off when bluetooth is enabled in WM (which created this "out-of-sync" issue). But other hand-off/out-of-sync issues could exist in other roms, thus causing this power drain issue to happen with some users and not others, and for the cause to be different between users.

In summary, if even one part of the radio module is left on, then it will keep the radio powered on and prevent it from going into standby mode and thus draw a lot of current.

So, the only way to find out what the cause is for your particular parent rom version (and possibly your radio version) is to turn off all the radio features, reboot the phone, then toggle all the features on, then off, then first make sure you have 3-6ma when in standby. Only when you have achieved this 3-6ma condition, can you then start enabling one feature at a time until you find a feature that, when enabled, will keep the radio ON when the phone goes into standby mode.

Keep in mind that the culprit could be cause by two different things (or a combination of both):

1) An Out-of-Sync condition between what the OS thinks the state of a radio feature is vs. the actual state it is in (thus is doesnt bother to send a standby message for that feature when android boots up). In this case manually turning on that feature in android then completely turning it off will get them back in sync and should temporarily fix any feature caused by this particular out-of-sync condition.

2) A driver that is unable to place feature in "standby" state. Regardless if a particular feature (like wifi) has the out-of-sync issue or not, if you use a particular feature, then you need the driver to be able to place that feature into a "standby" condition, besides just the "turn completely off" or "turn completely on" conditions. This "standby" mode is needed because you want to use that feature, but you also want it to go into "standby" when your phone goes into standby, and then have this feature wake back up when your phone wakes up. However, some drivers make not be 100% compatible with a feature or your parent ROM, such as the bluetooth driver which can't properly tell the BT radio to go into a "standby" mode, resulting in the radio staying awake when your phone is in standby. But this would only be a problem for people who who BT - for users who don't need the BT feature, then they will simply keep BT completely off, so there is no need for a "Standby" command to be sent to BT.

Well, I hope the above info will help shed some light on the issue, if in fact my theory of what the problem is, is actually correct.

-John