[APP][SVC][Mar 8, 2010] BattLineSvc V2.1 / Battery Indicator Line in Title Bar

Search This thread

Som30ne

Senior Member
Nov 22, 2009
244
8
I don't understand your chart. Can you elaborate?

The chart is pretty simple
Each line has the following data:
1. The date and time of the battery level sample
2. The battery level showed at that time on the status screen, afer tapping the taskbar (if a sample was missed - ??? would be shown)
3. If BattLineSVC was installed it would show ++ (if not it would show --)
4. if Co0kieMonster HomeTab was installed it would show ++ (if not --)
(if nothing was instaled - both BattLineSvc and Co0ki'sHT would show --)

As can be seen - when BattLineSvc is installed, the battery percentage drop 2-3 percent per hour.

The measurements taken for BattLineSvc were done at the same place (so there's no issue with different levels of celular reception), with all other wireless comm in the "off" position, and with the device mostly in "suspend" mode (just to take out every possible variable).
 
Last edited:

Som30ne

Senior Member
Nov 22, 2009
244
8
Well, honestly, you will see at least one post on EVERY application of somebody who claims battery loss. lol.

That said, I do take these reports seriously, but I just don't see any way BLS is causing this.

Can all of you with battery issues confirm that the Forced Update Interval is set to 0?

Yep. Forced update is set to 0.
 

Som30ne

Senior Member
Nov 22, 2009
244
8
4-5 days of life??? What device are you using? i haven't seen that kind of battery life from any smart phone before.

Considering the fact I practically use this device as a PDA, with no PhoneCalls, no SMSs, and very little internet use, I believe you can see how it lasts 4-5 days.

Internet usage however "costs" greatly in battery life -
1 hour of normal internet broesing "costs" about 30% of battery.

And just to be clear - The measurements taken for BattLineSvc were done at the same place (so there's no issue with different levels of celular reception), with all other wireless comm in the "off" position, and with the device mostly in "suspend" mode (just to take out every possible variable).
 

Som30ne

Senior Member
Nov 22, 2009
244
8
Here's the guts of BLS...

Code:
 g_mq = CreateMsgQueue(L"AvianWavesBattLineSvcPwrNotifQueue", &mqopt);
  if (g_mq)
  {
    g_pn = RequestPowerNotifications(g_mq, PBT_TRANSITION | PBT_POWERSTATUSCHANGE | PBT_POWERINFOCHANGE);
    if (g_pn)
    {
      while (WaitForSingleObject(g_mq, INFINITE) == WAIT_OBJECT_0) 
      {
        // Eat the power notification
        ReadMsgQueue(g_mq, &buf, sizeof(DWORD) * 16, &numberRead, -1, &flags);

        // Refresh the battery on any power change (we repeat several times since sometimes the battery level does not refresh in sync with the status change
        RefreshBatteryStatus();
        g_nowRepeat = 1;
        if (g_battTimerNowProc == 0)
        {
          g_battTimerNowProc = SetTimer(0, 0, 2000, battTimerNowProc);
        }
      }
    }
    g_pn = NULL;
  }

The following seems problematic to me:
Code:
while (WaitForSingleObject(g_mq, INFINITE) == WAIT_OBJECT_0)
Sleep indefinitely until the OS gives us a message on the message queue.

Considering the fact that MSN sais:
<http://msdn.microsoft.com/en-us/library/ms687032(VS.85).aspx>
The WaitForSingleObject function can wait for the following objects:

Change notification
Console input
Event
Memory resource notification
Mutex
Process
Semaphore
Thread
Waitable timer

I would have dropped that completly and would have changed:

Code:
ReadMsgQueue(g_mq, &buf, sizeof(DWORD) * 16, &numberRead, -1, &flags);
We don't care what the message is because we perform the same action on any message, so we just do a ReadMsgQueue to eat the message, but don't use the data in the buffer.

to:
while (1){
if (ReadMsgQueue(g_mq, &buf, sizeof(DWORD) * 16, &numberRead, <INFINITE>, &flags)){....

and you know what . . .
your assumption that the battery level hardware is jittering and producing thousands of messages unnecessarily might also be possible.
you know, those little volemeters and ampermeters installed in these devices might have accuracy problems, and stability problems,
and might be effected by environmental RF transmissions (and considering a phone is an RF transmitter . . .)

Maybe you should dump a "debug mode" log of all the messages with the batt level and time you received the notification,
just to check that theory.
 
Last edited:

thx1200

Inactive Recognized Developer
damn, 2000 only? set it for minimum 30000(upd: 10k..)...almost realtime is not good idea for such long line...2k is not especially needed, imo.
(just observation, nothing more).

I didn't put the code for the timer. That timer kills itself on entry if g_nowRepeat < 0, so it only iterates twice. This is done to do three measurements when the device resumes from sleep. Once immediately, and then two more two seconds apart. After that, it's done.
 

thx1200

Inactive Recognized Developer
while (1){
if (ReadMsgQueue(g_mq, &buf, sizeof(DWORD) * 16, &numberRead, <INFINITE>, &flags)){....


Good call. I see that dwTimeout can be set to INFINITE. I didn't notice that before. That might work well.

Just FYI, WaitForSingleObject is all over the place when you look for sample code with RequestPowerNotifications. That's where I got that idea from. Now that I've read the MSDN page on ReadMsgQueue, I agree with you that it's unnecessary.

I'm fairly confident it won't make a noticible difference considering the massive amount of code out there that uses it in this case, but every few cycles you can trim off the CPU, the better. :)
 

Som30ne

Senior Member
Nov 22, 2009
244
8
Also a good idea. I shall do that when I get some time to revisit this project again (maybe this weekend, maybe several weeks from now) ;-)

Im glad to see you took my remarks and Ideas seriously.
Id be looking forward for the modified (hopefully - loggable) version.
(if a loggable version will be available, I promise I would post a log of the app on my device)

Thanks in advance.
 

thx1200

Inactive Recognized Developer
Im glad to see you took my remarks and Ideas seriously.
Id be looking forward for the modified (hopefully - loggable) version.
(if a loggable version will be available, I promise I would post a log of the app on my device)

Thanks in advance.

Even when I'm confident in my code, I'm always happy to be proven wrong because it means I've learned something new. :) I don't want to be a programmer with his head in the sand because of stubborness. :)

I look forward to seeing if any of these small changes help, or, more importantly, if the log reveals anything about how BLS is behaving that we haven't considered yet.
 

mike2nl

Senior Member
Jul 24, 2009
3,965
670
64
Near Utrecht
Hi thx1200,

again a screenshot while charging the battery. Happy to use this app.
Top right is NOT 95% battery, it is CPU needed performance at this moment.
Top right second is the drain of the battery at this moment....
 
Last edited:

thx1200

Inactive Recognized Developer
Hi thx1200,

again a screenshot while charging the battery. Happy to use this app.
Top right is NOT 95% battery, it is CPU needed performance at this moment.
Top right second is the drain of the battery at this moment....

I'm sorry, I don't understand. What's going on in that picture that I should take note of?
 

SDreamer

Senior Member
Jul 20, 2009
181
1
Just wanted to add my experience so far with the app. I really like the app, but it seriously drains my battery. With the app, I'd have a days worth before charging (I use my device really lightly right now, maybe one or two phone calls lasting about 10 minutes). After uninstalling just this app, I suddenly have a couple days worth of battery (it's been two days, I'm only down to 51% since uninstalling the app). Thought I'd throw that out there. Was using the latest version that didn't poll either.
 

thx1200

Inactive Recognized Developer
Just wanted to add my experience so far with the app. I really like the app, but it seriously drains my battery. With the app, I'd have a days worth before charging (I use my device really lightly right now, maybe one or two phone calls lasting about 10 minutes). After uninstalling just this app, I suddenly have a couple days worth of battery (it's been two days, I'm only down to 51% since uninstalling the app). Thought I'd throw that out there. Was using the latest version that didn't poll either.

Man, I don't know how you guys get these multi-multi-day batter lives. But Good for you. :)

Even on a bare ROM (no installed apps), I get like 1.5 days if I don't use it at all. lol. But then again, I'm CDMA and have push email active.

Anyway, now that I'm back in town, I'm going to start having time to work on my apps again soon, so I will be able to put some logging into this app to figure out why the heck some of you are experiencing drain.

My suspicion is that the battery driver on some phones is actually blasting out tons of battery notifications when an app requests them (bug maybe), so it's constantly waking the device. But that remains to be seen! It could be that I did something stupid (I have been known!).

Out of curiosity, do you have the 1% battery level mod installed?
 

metrovice

New member
Apr 8, 2010
1
0
Does not appear to work on my Samsung i220 with Windows Mobile 6.5 Standard.

If use "Tray" instead "HHTaskBar" for the Taskbarclass it appears on the top of the screen when I hit "Start".

Still have not figured out the name for the home screen top part that shows the battery indicator, signal strength, network mode, etc...
 
Last edited:

liveseeds

New member
Aug 5, 2006
2
0
Hi! I installed the app (HTC Touch Pro 2), but nothing happened! (no battery in status bar) - do I have to 'launch' it anywhere, or should I have tried another soft reset (did that once).

ALSO - when I went into the normal battery settings it did not work (showed 0%). I uninstalled your app and restarted and the normal battery status was correct again.

Can you help advise as I like the sound of the app! (I am relatively new to this !!)
Thanks!
 

thx1200

Inactive Recognized Developer
Hi! I installed the app (HTC Touch Pro 2), but nothing happened! (no battery in status bar) - do I have to 'launch' it anywhere, or should I have tried another soft reset (did that once).

ALSO - when I went into the normal battery settings it did not work (showed 0%). I uninstalled your app and restarted and the normal battery status was correct again.

Can you help advise as I like the sound of the app! (I am relatively new to this !!)
Thanks!

That's weird. I've never seen that. Are you using a custom ROM?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Overview
    You've seen these before -- the little green line at the top of the screen that indicates the current battery level. This app is really nothing new or revolutionary. The main difference of BattLineSvc is that it's a true Windows Mobile service, so it does NOT use one of the precious few 32 slots available for processes. You can find more information about services here. This app has been tested on Windows Mobile 5, 6, 6.1, 6.5, and 6.5.3.

    CodePlex
    BattLineSvc development is hosted at Microsoft CodePlex! http://www.codeplex.com/BattLineSvc

    License
    Ms-RL

    Tip Jar
    Like this app? Want more like it or quicker updates? Tip a buck (or Euro or Pound or whatever) or two to help the author out! Click here to make a safe donation via PayPal.

    Current features
    - Shows a nice bar along the top of your screen to indicate battery status.
    - Color changes based on 'warning' and 'critical' battery levels, as well as when the device is on AC power (configurable).
    - Immediately correctly resizes when the screen orientiation changes.
    - The battery level is updated immediately when the device notifies listeners that battery status has changed (or you can specify an interval if your device isn't sending notifications.
    - Can show a bar at the bottom, left, and right sides of the battery bar (if you want it).
    - Can be offset from the left and right, if you need it.
    - Height of the bar can be changed.
    - VERY low resources used -- runs as a TRUE service and uses as close as 0% CPU as is possible by an app like this. So it's good for even older snail devices. :-D
    - Has a configuration app (requires .Net CF 3.5)
    - AppToDate support!

    Recent Changes (See CodePlex or changelog.txt for longer changelog)
    - (2.1) Fixed a bug where on system start-up, it would pop up a notification box to let you know the service started. Annoying! And fixed!
    - (2.1) Fixed the styles in the notification boxes for start/stop service.
    - Fixed bug where sometimes the line would not show up, even with the 90 second boot-up delay. This was due to the window being created too early (not actually delayed, even though the subclassing was properly delayed. Oops!
    - Boot delay was reduced to 30 seconds from system start-up; so far no issues with it starting too early!
    - Added a "right side offset" which works as the left side offset, but for the right side.
    - Added a "right line" which works the same as the left line.
    - Added a new color setting for when the battery is charging. (Default is a light gray-blue.)
    - Battery status, by default, no longer refreshes on an interval, but instead by waiting for battery notification events. This makes BattLineSvc even more efficient! The interval timer is still there in case your device does not work with events only.
    - Reduced the number of subsequent refreshes by requesting a synchronous status refresh; previously it would wait asynchronously which was less efficient since the update could take anywhere from a few milliseconds to several seconds.
    - Removed a redundant battery status checking method which monitored the registry (no longer needed because the new power event-based system works better and is more efficient).
    - Removed a few other old segments of code that were inefficient.
    - Added user notification for starting/stopping the service with the start/stop apps.
    - Added a configuration program (yay). Requires .Net CF 3.5. You can still edit the registry manually.

    Registry
    Look in HKCU\Software\Avian Waves\BattLineSvc
    Colors are best edited as hex, using the following pattern: BBGGRR (seems backwards, but it's due to the endedness of DWORDS in CE). Your registry editor may not show leading zeros either, keep that in mind.
    - TaskbarClass = (string) Don't change this unless you are 100% positive the taskbar is not named standard.
    - Height = (int) Number of pixels tall for the battery line.
    - LeftOffset = (int) Number of pixels from the left edge that the battery line starts.
    - LowPercent = (int 0-100) What percentage of battery charged is considered low (yellow).
    - CriticalPercent = (int 0-100) What percentage of battery charged is considered critical (red).
    - ShowLeftLine = (bool) Show the vertical line on the left side of the title bar where the BattLine starts.
    - ShowRightLine = (bool) Show the vertical line on the left side of the title bar where the BattLine starts.
    - ShowBottomLine = (bool) Show a line on the bottom of the battery bar
    - ColorForegroundSolidNormal = (color) For 'normal' (not low) battery charge, this is the foreground color, default is bright green.
    - ColorBackgroundSolidNormal = (color) For 'normal' (not low) battery charge, this is the background color, default is dark green.
    - ColorForegroundSolidLow = (color) For low battery charge, this is the foreground color, default is bright yellow.
    - ColorBackgroundSolidLow = (color) For low battery charge, this is the background color, default is dark yellow / brown.
    - ColorForegroundSolidCritical = (color) For critical battery charge, this is the foreground color, default is red.
    - ColorBackgroundSolidCritical = (color) For critical battery charge, this is the background color, default is dark red.
    - ColorForegroundSolidCharging = (color) For when the device is charging (on AC), this is the foreground color, default is light gray-blue.
    - ColorBackgroundSolidCharing = (color) For when the device is charging (on AC), this is the background color, default is dark gray-blue.
    - ColorLeftLine = (color) Color of the left line.
    - ColorRightLine = (color) Color of the right line.
    - ColorBottomLine = (color) Color of the bottom line.
    - TimerIntervalSeconds = (int) How often do we look to see if the battery level has changed (in seconds)? NOTE: As of V2, set this value to 0 unless BattLineSvc is not updating on your device. Zero means disabled. This settings is no longer necessary as BattLineSvc now waits for battery notification events, instead of updating on a timer.

    Download
    CAB Installer: http://battlinesvc.codeplex.com/releases
    Source Code: http://battlinesvc.codeplex.com/SourceControl/list/changesets