5,596,637 Members 42,743 Now Online
XDA Developers Android and Mobile Development Forum

[App] BattMonX (Droid X Battery State Monitor via LED Status)

Tip us?
 
scary alien
Old
(Last edited by scary alien; 24th February 2011 at 03:46 AM.) Reason: added version 2.2 information
#1  
Recognized Developer - OP
Thanks Meter 86
Posts: 260
Join Date: Jun 2010
Location: Indy
Default [App] BattMonX (Droid X Battery State Monitor via LED Status)

BattMonX is a utility for the Motorola Droid X (also works for other Motorola Droid-class phones) for turning on a phone's LED indicator light (when the screen is off) to represent the battery's current state (charging, charged, discharging, or low-battery). Version 1.8 now allows a rooted Motorola Droid-class phone to have the LED on while the screen is on. This app was originally written for the Motorola Droid X whose LED indicator was not enabled during charging like many other phones do.

Additionally, for phones like the Droid X with a tri-color LED (red/green/blue), a variety of colors may be selected to differentiate the various battery states (OFF, red, green, blue, yellow, orange, deep sky blue, dark violet, dark green, and dark orange). Version 1.8 includes the color "amber" for those phones that support an amber LED indicator. Also, rooted Motorola Droid-class phones can choose "white" as a color option when used with the "LED is Always ON" experimental (and root-only) feature.

PHONE COMPATIBILITY

This app will not work on all phones. For example, the Samsung Vibrant and Captivate do not have LED indicators. Some phones only have a two-color LED (the HTC Eris and Evo 4G both have a green/amber LED; the Epic 4G supports a red/blue LED) which might allow for partial functionality from this app (especially if rooted). Additionally, its clear from testing that some phone's firmware interferes or does not fully implement the standard Android LED notification functionality identically to the Motorola Droid-class of phones.

Extensive logic has been added in version 1.7 and 1.8 in an attempt to support other phones. Version 1.8 now implements a strategy for dynamically finding a phone's battery state files (specifically the "status" and "capacity" files). Additionally, the LED notification directories are identified to determine their location and which color brightness files are supported by your phone's LED. Please contact me at scary.alien@gmail.com for instructions on how to provide debugging information so I can try to support your phone.

USAGE and NOTES

* Launch the BattMonX app and press the "Start Monitoring Battery Status" button. Monitoring will take place in the background and the app may be safely exited via the BACK or HOME keys.

* While monitoring is active/enabled, the app will check the battery state at a user-selectable polling interval and set the LED state as specified.

* To exit the BattMonX UI but continue monitoring, use the BACK or the HOME key--the app's service logic will continue monitoring the battery state in the background.

* To discontinue monitoring, recall or re-launch the app and press the "Stop Monitoring and Exit" button.

* Version 1.6 and higher now allows BattMonX to work alongside SMS text notifications. After viewing the text message or clearing the notification, BattMonX will resume battery state monitoring at the start of the next polling interval. Version 1.8 of the app implements a new strategy to make the app much more responsive (30 seconds or less) to SMS notifications.

* To have the app automatically monitor the battery state after a reboot, enable the "Set on Boot" option in the second menu page.

* Use the "Display Current Settings" menu item to see app's current state and settings.

* Use of the low-battery indicator is optional. If enabled however, it will take precedence over all other settings (i.e., as long as the current battery percentage full is less than or equal to the low-battery threshold, the low-battery action will be taken and used regardless of the other charging or discharging settings).

* This app does NOT require root; requires minimal permissions; uses very little CPU and system resources. Version 1.8 does include some new experimental features that require root such as the "LED Always On" feature to enable turning the LED on while the screen is on (not available on a stock Droid X).

* If you use a task killer, be sure to exclude the BattMonX app.

* You should also be aware that many phones turn OFF the LED when turning the screen on or off. The app should re-light the LED when/if appropriate at the top of the next polling interval. Additionally, Android will suspend non-system app processing when the screen is turned off. This might cause BattMonX to not be able to update the LED status while the screen is off since it (and all other apps) are not being given CPU cycles for processing. When the screen is turned back on or an SMS text message is received, the app should wake-up and resume updating the LED status as normal.

EXPERIMENTAL FEATURES

Version 1.8 brings some new experimental features to BattMonX:

- An "LED is always ON" (for rooted phones only) to light the LED while the screen is on (normally, at least for the Droid X) the LED is only display while the screen is off. This experimental feature bypasses the notification API and updates the LED notification's brightness files directly. If you use this feature with the set-on-boot option, be sure that you tell the SuperUser app to "remember" the "allow" setting so that the app will resume expected monitoring (otherwise, the app will automatically turn off the "LED is always ON" setting). Also, there is currently no "blink" functionality available when the "LED is always ON" setting is used.

- I have included an LED Color Tester to allow you to test your own phone's LED color display ability. Note: use the menu's "Current Settings" option to display which LED colors your phone supports that the app has auto-identified for you (scroll to the bottom in the "Miscellaneous" section). If your phone is not rooted, you'll have to suspend monitoring first and turn your screen off to see the results of your color test. If your phone is rooted and you've enabled the "LED is always ON" setting, you'll be able to see the results of your color test immediately while the screen is on.

- I've included an option "Locate Battery / LED Files" option to explicitly locate and display the battery state directory, LED notification directory, and supported LED colors. For non-Motorola Droid-class phones, this function is performed automatically after first install (and is not necessary (but harmless) for Motorola Droid-class phones).

PERMISSIONS

- BattMonX monitors for the receipt of SMS message notifications (android.permission.RECEIVE_SMS) for the purpose of stepping-aside when an SMS text arrives so that the SMS notification (i.e., blinking green LED) can be displayed. No actual SMS messages are read--the app only receives the SMS broadcast action.

- The app also receives a notification of when the phone has rebooted (android.permission.RECEIVE_BOOT_COMPLETED) for the purpose of restarting the battery state monitoring automatically after a reboot. You can enable or disable this feature in the menu (Preferences / Settings -> Set On Boot (checked or un-checked)).

- BattMonX uses the android.permission.WRITE_EXTERNAL_STORAGE to create a temporary file on the /sdcard containing the list of files in the /sys/devices/platform directory structure in order to automatically identify the battery state (status and capacity) and LED notification (<led-color>/brightness) files.

For screen shots and additional information, please visit https://sites.google.com/site/scaryalienware

Thanks again to everyone for their feedback and suggestions!

Please contact me at scary.alien@gmail.com is you have any issues, questions, comments, or suggestions. Cheers!

Screen Shots

Click image for larger version

Name:	01-main-screen.jpg
Views:	353
Size:	68.7 KB
ID:	525848 Click image for larger version

Name:	02-pref-screen1.jpg
Views:	252
Size:	56.1 KB
ID:	525849 Click image for larger version

Name:	03-pref-screen2.jpg
Views:	218
Size:	52.7 KB
ID:	525850 Click image for larger version

Name:	04-pref-screen3.jpg
Views:	194
Size:	60.1 KB
ID:	525851 Click image for larger version

Name:	05-pref-screen4.jpg
Views:	182
Size:	57.1 KB
ID:	525852 Click image for larger version

Name:	06-pref-screen5.jpg
Views:	173
Size:	77.2 KB
ID:	525853 Click image for larger version

Name:	07-led-color-tester.jpg
Views:	239
Size:	73.5 KB
ID:	525854

QR code: Click image for larger version

Name:	qr-code.jpg
Views:	558
Size:	14.2 KB
ID:	455222
 
scary alien
Old
#2  
Recognized Developer - OP
Thanks Meter 86
Posts: 260
Join Date: Jun 2010
Location: Indy
Default v1.3 just published: now supports set-on-boot feature!

Just a quick thread bump to let everyone know that I've updated the app to version 1.3 that now includes a set-on-boot / run-on-boot option.

Select this option via the menu (menu -> More -> Set on Boot -> select True or False).

Enjoy!
 
TuxDude
Old
#3  
Junior Member
Thanks Meter 5
Posts: 21
Join Date: Dec 2010
Location: Mountain View, CA
Nice app - will give it a shot
 
scary alien
Old
#4  
Recognized Developer - OP
Thanks Meter 86
Posts: 260
Join Date: Jun 2010
Location: Indy
Default version 1.4 just uploaded to the Market

All,

Just wanted to let everyone know that v1.4 is out and includes the ability to monitor for a low-battery condition.

You can set a percentage threshold at which the LED will be turned on (or not) to a selected color and optionally have it blink.

I've also added five new colors to select from for setting the LED to the various battery states.

Here's the change log:

version 1.4:

* supported optional low-battery status indicator:

- action: none, LED on, LED blink
- threshold: 10%, 20%, 30%, or 40%
- LED color

* supported new LED colors in addition to the original red, green, blue, yellow, and OFF:

- dark orange
- orange
- dark violet
- dark green
- deep sky blue


Cheers!
 
XIMAD, Inc.
Old
#5  
Junior Member
Thanks Meter 0
Posts: 14
Join Date: Dec 2010
Thanks! Good app!
 
scary alien
Old
#6  
Recognized Developer - OP
Thanks Meter 86
Posts: 260
Join Date: Jun 2010
Location: Indy
Default v1.6 just uploaded: now works w/SMS text notifications

All,

Just a quick thread-bump to let everyone know about the latest release of the app: version 1.6 now works with SMS text notifications!

So now, you should be able to run the app all of the time and still get notified when a text message comes in.

The timeliness of the seeing the SMS notification is still dependent on the polling interval you are using, but app steps aside when the SMS notification comes in and then resumes when its been acknowledged (by reading the text) or cleared (by the notification pull-down's Clear button).

Please note that the app doesn't actually control the color or blinking status of the SMS text notification, my app just allows it to come in and been seen--so I cannot change its color or behavior (sorry).

I also added the option / ability to make the LEDs blink (or stay on like before) for the charging / discharging / charged state like the functionality I added for the low-battery condition in v1.4.

Anyway, I hope everyone has a safe and happy holiday!

Enjoy the app and its recent changes--I very much appreciate everyone's feedback and support!

By the way, I am going to try to move all of the configuration stuff currently in the menus to the "shared preferences" settings (that will look like the Settings configuration menu we all know and love).
 
cowboyboats
Old
#7  
Senior Member
Thanks Meter 17
Posts: 114
Join Date: Jul 2010
I wonder if it's at all possible to notify of a possible wake lock?

Swyped from my Cyanogen Evo
 
scary alien
Old
#8  
Recognized Developer - OP
Thanks Meter 86
Posts: 260
Join Date: Jun 2010
Location: Indy
Quote:
Originally Posted by cowboyboats View Post
I wonder if it's at all possible to notify of a possible wake lock?

Swyped from my Cyanogen Evo
Wow! Thanks for melting my brain ... after reading through this (http://source.android.com/porting/po...PowerWakeLocks).

Didn't know too much about wake locks before this (or even afterwards, lol).

Interesting idea...not sure if I could monitor for these (there is no obvious broadcast action event that is sent-out for wake-locks that I could listen for).

Thanks for the suggestion...I'll keep this in mind for the future though.
 
cowboyboats
Old
#9  
Senior Member
Thanks Meter 17
Posts: 114
Join Date: Jul 2010
Sorry, I was thinking if it could notify of low battery then it might be possible to add a feature that would notify high voltage discharge while screen was off. Since roms should under volt while the screen is off. Maybe a feature our something but I may not fully understand it

Swyped from my Cyanogen Evo
 
scary alien
Old
#10  
Recognized Developer - OP
Thanks Meter 86
Posts: 260
Join Date: Jun 2010
Location: Indy
Default v1.7 just uploaded to Market (very useful fixes and improvements)

version 1.7 changes include:

- added strategy to auto-recover from Android auto-killing the app's service; should make the app much more stable and without unwanted shutdowns

- replaced multiple menu settings w/standard Settings/Preferences menu item

- dynamically determine battery status directory (I did this to see if the app would work on more phones (with mixed success); should allow for users that don't see that the app was written for the Droid X to at least see if it will work on their phone (does not appear to work on a stock HTC Evo 4G, HTC Droid Eris))

- re-instituted screen lock to portrait mode to prevent orientation change from causing FCs

- fixed integer parsing issue causing some reported crashes (probably just experienced by non-Droid X phones)

- added option for 3 minute polling-interval

- added larger range for low-battery percentage threshold

- fixed issue where LED would not blink when charging

Anyway, if you have any issues, comments, questions, etc., please contact me at scary.alien@gmail.com.

Cheers and have a great New Year!

Tags
battery monitor, droid x, led indicator, led status
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes