Battery capacity not updated

704 views
Skip to first unread message

Arun R Murthy

unread,
Apr 5, 2010, 6:46:33 AM4/5/10
to android-porting
Hi All,
I am using andoird eclair and not able to see the battery capacity
getting updated while charging/discharging.
Wherein when I try to cat the battery capacity from the sysfs I am
able to see the change.
The only event that updates the battery capacity, voltage, etc in the
application is the plug/unplug of the
AC/USB charger.
Please let me know on this.

Thanks and Regards,
Arun R Murthy
-------------------

ZhangJieJing

unread,
Apr 12, 2010, 10:23:13 PM4/12/10
to Arun Raghavendra Murthy, android-porting
CC the list.

Hi,

the BatteryService is working like this:

cd /sys/class/power_supply

for each dir:
if have a file named type:
  if type == Battery
     read capicty ...etc
  if type == AC
     read online 
  if type == USB
    read online

If you mean it not updated on unplug & plug charger, you should first check the type of your power_supply driver.

---
Best regards,
Zhang Jiejing


2010/4/12 Arun Raghavendra Murthy <rmurth...@gmail.com>
Hi,
  In that case it is working for me.
On the event of power supply changed the battery capacity is getting updated.
On plugging the AC charger capacity gets updated and on removal of AC charger capacity gets updated. But in the mean time i.t between charging plug and unplug it is not getting updated though i see a change in the sysfs.
 
Thanks and Regards,
Arun R Murthy
---------------------

On Mon, Apr 12, 2010 at 7:55 AM, ZhangJieJing <kzj...@gmail.com> wrote:
Hi,

you don't need send separatedly battery capacity, android framework only monitor POWER_SUPPLY_CHANGED uevent, if it received the uevent, it will read the sys fs under /sys/class/power_supply/* files to get the voltage, current, capacity, etc, 
you may need see file frameworks/base/services/jni/com_android_server_BatteryService.cpp to see the detail.

---
Best regards,
Zhang Jiejing


2010/4/12 Arun Raghavendra Murthy <rmurth...@gmail.com>

Hi,
   The power_supply_changed() will handle if there is any change in power supply i.e plug/unplug of AC/USB.
I have a work which keeps monitoring my battery parameters i.e battery voltage, current, capacity.

Also I notice that all POWER_SUPPLY_PROP_* are registered as uevents in the power supply core driver.
So is it necessary for me to send an uevent separately for battery capacity.?


Thanks and Regards,
Arun R Murthy
--------------------

On Thu, Apr 8, 2010 at 8:36 PM, ZhangJieJing <kzj...@gmail.com> wrote:
Hi, 

you need check your battery driver, the update of battery capacity is drive by uevent send by driver(via power_supply_changed() func), your driver may need have a delayed work or timer function to send this event every timeout, such as 1 minute. 

you can reference file:  drivers/power/tosa_battery.c about this.
---
Best regards,
Zhang Jiejing


2010/4/5 Arun R Murthy <rmurth...@gmail.com>

--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

To unsubscribe, reply using "remove me" as the subject.




--
Arun R Murthy






--
Arun R Murthy



ZhangJieJing

unread,
Apr 13, 2010, 3:44:59 AM4/13/10
to Arun Raghavendra Murthy, android-porting
Hi,

what I know is battery capacity update is triggered by POWER_SUPPLY_UEVENT, 
1, please ensure this UEVENT is sent, 
  you can change init.rc 's loglevel to 9 to get the uevent dump.
2, what this command output:
# ls /sys/class/power_supply

I think the plug/unplug make the battery capacity update is because it will send a POWER_SUPPLY_CHANGED uevnet, and on discharging, you don't let your driver send the uevent in a time(eg. 60s).

if it's true, you should add a timer or delayed_work in your battery driver to do this job.

---
Best regards,
Zhang Jiejing


2010/4/13 Arun Raghavendra Murthy <rmurth...@gmail.com>
Hi,
  The battery capacity is getting updated while plug/unplug of charger.
But not getting updated while discharging.
 
The BatteryService class is very much able to read the battery capacity, ac - online, usb - online, etc.
 
The problem that I am facing is the battery capacity is getting updated only on plug/unplug of charger.
In the mean time its not updated. But if I read the capacity through the sysfs I see the updated capacity.
 
What I guess is in android only there should be some application that should read the battery capacity
from sysfs at time intervals "t" and update the same.
 
Please let me know on this.
 
Thanks and Regards,
Arun R Murthy
--------------------
 
Thanks and Regards,
Arun R Murthy
--------------------

Arun Raghavendra Murthy

unread,
Apr 12, 2010, 11:50:41 PM4/12/10
to ZhangJieJing, android-porting
Hi,
  The battery capacity is getting updated while plug/unplug of charger.
But not getting updated while discharging.
 
The BatteryService class is very much able to read the battery capacity, ac - online, usb - online, etc.
 
The problem that I am facing is the battery capacity is getting updated only on plug/unplug of charger.
In the mean time its not updated. But if I read the capacity through the sysfs I see the updated capacity.
 
What I guess is in android only there should be some application that should read the battery capacity
from sysfs at time intervals "t" and update the same.
 
Please let me know on this.
 
Thanks and Regards,
Arun R Murthy
--------------------
 
Thanks and Regards,
Arun R Murthy
--------------------

On Tue, Apr 13, 2010 at 7:53 AM, ZhangJieJing <kzj...@gmail.com> wrote:

Arun Raghavendra Murthy

unread,
Apr 14, 2010, 11:34:02 AM4/14/10
to ZhangJieJing, android-porting
Hi,
  On POWER_SUPPLY_CHANGED uevent, battery capacity is updated.
Lets say I plugged in AC charger @ time 't'.
Now an uvevnt occurs and battery capacity is updated in android.

In time t+20, battery has charged and the capacity must have increased to some higher level.
I can notice this by reading sysfs. But the same in not updated in android.

Not @ time t+30, I unplug the AC charger, again an uvevnt is observed and capacity is updated in android.

Hope I am clear.


Thanks and Regards,
Arun R Murthy
---------------------

Deva R

unread,
Apr 14, 2010, 2:27:16 PM4/14/10
to rmurth...@gmail.com, ZhangJieJing, android-porting
Hi,

Periodic update of battery level should be done by battery charger interface driver., (usually present in ./driver/power/<battery>.c)..

the battery charger driver has a minor state machine and usually
- services charger plug, unplug event and publishes presence or absence of battery
- have a periodic timer to read status of battery charge level.,

you can refer sample BCI driver implementation
http://linux.omap.com/pub/kernel/3430sdp/patches-applicable-over-linux-omap-2.6.git/twl4030_bci_battery_20080305.patch
and more at ./drivers/power/<> in kernel..

can you check your battery charger interface driver, if it has periodic status update feature?
Reply all
Reply to author
Forward
0 new messages