Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,771,646 Members 46,281 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
thx1200
Old
(Last edited by thx1200; 9th March 2010 at 10:53 PM.)
#1  
thx1200's Avatar
Recognized Developer - OP
Thanks Meter 49
Posts: 872
Join Date: Apr 2006
Location: Raleigh, North Carolina
Smile [APP][SVC][Mar 8, 2010] BattLineSvc V2.1 / Battery Indicator Line in Title Bar

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/Sour...ist/changesets
Attached Thumbnails
Click image for larger version

Name:	BLS1.jpg
Views:	5384
Size:	14.3 KB
ID:	287586   Click image for larger version

Name:	BLS2.jpg
Views:	3910
Size:	13.7 KB
ID:	287587   Click image for larger version

Name:	BLS3.jpg
Views:	3875
Size:	13.7 KB
ID:	287588  
Avian Waves aka thx1200
http://www.avianwaves.com

Samsung Galaxy S4 / Sprint

Android Apps: Coming soon!
Legacy Windows Mobile Apps (no longer supported): Avian Play / Mute4 / ReRemind / BattLineSvc / ZoomBarPlus / PlaySound / TouchFlo Detacher / Mobile Shell 3 Toggler / iContact AE
The Following 2 Users Say Thank You to thx1200 For This Useful Post: [ Click to Expand ]
 
thx1200
Old
(Last edited by thx1200; 29th March 2010 at 02:50 PM.)
#2  
thx1200's Avatar
Recognized Developer - OP
Thanks Meter 49
Posts: 872
Join Date: Apr 2006
Location: Raleigh, North Carolina
Default FAQ

Question: My battery life seems to be draining faster after installing BattLineSvc. Is BattLineSvc causing this?

Answer: Probably not. The current version of BattLineSvc has no active polling. This means that when there is no battery status change happening, BattLineSvc is 100% idle. In Windows Mobile, applications and services are event based. You can set up a "loop" type of system (loop over and over, constantly checking for something), but that's inefficient. Even in older versions of BattLineSvc that made use of TimerIntervalSeconds to update the battery status, the updates were done a timer. So, you see, when BattLineSvc starts, it sets itself up to listen to system events, then it explicitly goes to sleep and waits until it receives a message. This is all handled in the OS and it's the way efficient apps are written in WM.

Okay, so you are wondering, well maybe a lot of events are firing and it's causing more CPU and therefore more battery drain. BattLineSvc listens for battery events and also power change events (on to idle or idle to on). None of these fire very often, unless there is something wrong with your device or your ROM. :) Even if they did, it wouldn't matter unless they continued to fire when the device was asleep/idle. In WM, an app must request to stay awake when the device goes idle (users presses power button). BattLineSvc is set up to use unattended mode, which is the mode where WM goes into after you press power-off to turn off the screen, but before it's fully asleep. WM gives all apps requesting unattended mode 15 seconds to complete their task. If they need more time, the app must explicitly ask WM by reseting the idle counter timer. BattLineSvc never resets the idle timer! So unless another app is doing this, the device will fully sleep 15 seconds after you press the power button, which is normal WM operation.

Okay, so that's the long winded explanation. But you want answers! Well, I always would encourage you to A/B the situation by running BattLineSvc for a few days, then uninstall it and try it a few days without. I think this will persuade you in 99% of cases. Please don't post on this thread if you have done less than a week's worth of power testing. There are so many thousands of things that can cause battery drain, you can't tell with only a few hours worth of testing.

One thing that causes power drain, which is the TRUE reason most people think a new app did it, is your cellular radio. Sometimes, for random reasons (atmospheric interference, dead zones, cell tower glitchy/busy), your radio has to work harder to get a signal. In fact, sometimes you may notice your phone is warm while its idle and you know you aren't downloading or anything. That's the radio! I've had a fully charged phone go down while it was in my pocket doing nothing in half a day due to this. The next day, all is well. Zero changes on my part. It just happens. It sucks, but, well, there's nothing you can do short of turning off your cellular radio. :) Luckily its rare unless you know you are driving out of coverage area or something. Which is why apps are blamed sometimes. You install an app, then the power drains and you logically conclude it was that app. You uninstall it the next day, and all seems well. This is why you need several days of testing - to rule out these random things!

Finally, you must test from a full charge. You can't install BattLineSvc when your device is half full, then see the last half of the battery drain faster than your first half and come to any conclusions. Battery drain is not linear! It's subject to the nuances of the battery. Usually the last half of your battery will drain faster than the first half, but it all depends on the detection algorithm and the battery itself. The only true test is from full charge with exactly the same operating conditions (all other apps the same, usage the same, no background tasks like downloads/refreshes happening any different from the previous charge).

Good luck in finding your power drain and I do want to know if it is BattLineSvc, so please report it if you are having an issue, but don't post anything until you've done a full week of testing with BattLineSvc installed and BattLineSvc uninstalled.
Avian Waves aka thx1200
http://www.avianwaves.com

Samsung Galaxy S4 / Sprint

Android Apps: Coming soon!
Legacy Windows Mobile Apps (no longer supported): Avian Play / Mute4 / ReRemind / BattLineSvc / ZoomBarPlus / PlaySound / TouchFlo Detacher / Mobile Shell 3 Toggler / iContact AE
 
Stephen Selby
Old
#3  
Member
Thanks Meter 0
Posts: 98
Join Date: Dec 2009
Thank you. It seems to work well on my HD2. How can I get rid of the original battery WM6 indicator?
 
aiiro
Old
#4  
aiiro's Avatar
Senior Member
Thanks Meter 28
Posts: 310
Join Date: Mar 2008
Stephen, search for reg settings called TBOpt and ShowTitleBarClock, You'd probably get Your answer.

What I really wanted to say is that the idea is REALLY nice, although I personally dismissed all the bars and stuck with QMenu's numeric display of battery and memory on the taskbar - tho it's a bit buggy. I guess I am a numbers' freak If someone could rewrite that to a reliable, small, resource-saving service, that I would really appreciate. To date I haven't found such app...

If You need any ideas what to develop, I would be glad to present my list

Good work and respect!
 
NLS
Old
#5  
NLS's Avatar
Senior Member
Thanks Meter 37
Posts: 2,359
Join Date: May 2005
Location: Piraeus
nice job - try to implement "breaks" in the line - like SPB Pocket Plus bar
(so that you actually get a feel of steps)
also looks nicer and feels like it measures something, not like there is something wrong with the pixels at the top of the screen
NLS
*** I WANT YOUR SERVICE initiative ***
My Blog

Devices: (many in the past, still in possesion the following) HTC Touch Pro 6.5.3 NRG, HTC HD2 (RULEZ) 6.5.3 Artemis, Samsung Galaxy Note (magic).

USE FORUM SEARCH! USE GOOGLE SEARCH!

Also: THIS guy is unbelievable! (in a bad way)
 
timstephens11
Old
#6  
timstephens11's Avatar
Member
Thanks Meter 0
Posts: 79
Join Date: Aug 2006
Location: London
Thumbs up wm 6.5.5 (build 23540) Touch HD Blackstone

Works fine on said device and build, just changed height to 1 pixel.

Attached a screen shot but can't really see it that well, it's fine in reality.
Attached Thumbnails
Click image for larger version

Name:	Screen02.jpg
Views:	1004
Size:	25.9 KB
ID:	287729  
HD2
ROM - 6.5.5|ROM|WWE| Energy Series 23569
Radio - [Leo][Radio]_15.40.50.07U_2.11.50.20



Orange TYTN II (Kaiser)
ROM - [15 November 08] HyperDragon III Raphael OS
Radio - 1.65.24.36 NIKI

Orange Touch HD (Blackstone) - RECYCLED (a lazy 140 from envirophone)
 
thx1200
Old
#7  
thx1200's Avatar
Recognized Developer - OP
Thanks Meter 49
Posts: 872
Join Date: Apr 2006
Location: Raleigh, North Carolina
Quote:
Originally Posted by NLS View Post
nice job - try to implement "breaks" in the line - like SPB Pocket Plus bar
(so that you actually get a feel of steps)
also looks nicer and feels like it measures something, not like there is something wrong with the pixels at the top of the screen
:)

I probably won't be doing that, at least not soon. I have too many other tasks on my plate at the moment. After creating a config app for this service, I will probably shelve it for a while. It is open source, so feel free to add that feature and I'll roll it into the next version. :)
Avian Waves aka thx1200
http://www.avianwaves.com

Samsung Galaxy S4 / Sprint

Android Apps: Coming soon!
Legacy Windows Mobile Apps (no longer supported): Avian Play / Mute4 / ReRemind / BattLineSvc / ZoomBarPlus / PlaySound / TouchFlo Detacher / Mobile Shell 3 Toggler / iContact AE
 
arman68
Old
#8  
Senior Member
Thanks Meter 204
Posts: 256
Join Date: Sep 2006
Beautiful app. I always admire developers who make the effort to really optimize their application and minimize resource usage. Well done.

I was not able to find any information as to whether ibattery and lvmtopbat (which ibattery is based on), also run as a service. Anybody knows?
 
tito12
Old
#9  
tito12's Avatar
Senior Member
Thanks Meter 83
Posts: 1,538
Join Date: Feb 2008
Location: Tel Aviv
Quote:
Originally Posted by thx1200 View Post
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, and 6.5, but NOT 6.5.3. (Can somebody test for me?) There's no configuration app yet, so I hope you like editing the registry if you don't like the default settings. ;)
Hi thx1200

No issues so far on my device

Thank you
Htc Uk Wifi Flyer - HC 3.2.1
iPhone 4S - IOS 5.0.1 JB
Htc Touch Elfin - (retired) WM 6.5.5 - Onyx 6 rom

 
drfno1
Old
#10  
Member
Thanks Meter 4
Posts: 61
Join Date: Dec 2007
Location: Kansas
Currently running 6.5.5 with manila2d. It seems 90 seconds is not enough on my Tilt to startup correctly. If I restart the service it is great. Maybe it can be a parameter in the registry settings.

Thanks

Tags
battery, service, status, title bar, titlebar
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


MacroDroid Update Brings Android Wear Automation

A few months ago, we talked about MacroDroid. For those who don’t remember, MacroDroid … more

Droid X Receives KitKat Port, Upcoming Google Glass Firmware Improvements – XDA Developer TV

Android 4.4.3 lands on the European HTC … more

Calc+ is a Smart and Beautiful Android Calculator

As we’ve said inthe past, there are quite a few calculators available on Android. … more

Get Better Debug Data with Crash Report SDK

Developing an application is a hard and often times ungratifying task. It also requires quite a … more