Suggestion to new shutdown handling triggered by low battery voltage

207 views
Skip to first unread message

imresunyi

unread,
May 18, 2010, 6:18:28 AM5/18/10
to android-platform, imre...@gmail.com
Hi

I am looking into Eclair and onward regarding the initialization of
shutting down the device due to low battery.
I would like to hear your opinion and if we can improve the current
shutdown handling in future.

In file "frameworks/base/services/java/com/android/server/
BatteryService.java" we have the function:

private final void shutdownIfNoPower() {
// shut down gracefully if our battery is critically low and
we are not powered.
// wait until the system has booted before attempting to
display the shutdown dialog.
if (mBatteryLevel == 0 && !isPowered() &&
ActivityManagerNative.isSystemReady()) {
Intent intent = new
Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
}

I think that initiating a shutdown when battery level reaches 0 % is
not that good from battery fuel gauging view. There might still be
some energy left in the battery when the gauging turns from 1 % to 0
%.

Example: Depending on the battery gauging SW and/or HW 0.5% might be
presented as 1 % or 0 %. If in this case it presents 0 % the battery
is not fully used before shutting down.

What would be the best is to monitor the battery voltage (in fuel
gauge SW or HW) and when the level hits the desired level the device
should initiate a shutdown that results in an intent that is handled
by the shutdownIfNoPower() function.

What about using the battery health "Dead" to initiate a shutdown?

The modified shutdownIfNoPower() could then look like:

private final void shutdownIfNoPower() {
// shut down gracefully if our battery is dead
// wait until the system has booted before attempting to
display the shutdown dialog.
if (mBatteryHealth == BatteryManager.BATTERY_HEALTH_DEAD &&
ActivityManagerNative.isSystemReady()) {
Intent intent = new
Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
}

Br
Imre

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Timmmm

unread,
May 18, 2010, 8:23:00 AM5/18/10
to android-platform
On May 18, 11:18 am, imresunyi <imre.suny...@sonyericsson.com> wrote:
> I think that initiating a shutdown when battery level reaches 0 % is
> not that good from battery fuel gauging view. There might still be
> some energy left in the battery when the gauging turns from 1 % to 0
> %.
>
> Example: Depending on the battery gauging SW and/or HW 0.5% might be
> presented as 1 % or 0 %. If in this case it presents 0 % the battery
> is not fully used before shutting down.

I don't think so, for the following reasons:

a) Battery level measurement is unlikely to be accurate to 0.5%
anyway.
b) The shutdown voltage is somewhat arbitrary, you'd just be shifting
is slightly to another arbitrary point.
c) It looks like mBatteryLevel is an integer. 0 can represent an empty
battery just as well as BATTERY_HEALTH_DEAD or anything like that.

imresunyi

unread,
May 20, 2010, 3:54:24 AM5/20/10
to android-platform


On May 18, 2:23 pm, Timmmm <tdh...@gmail.com> wrote:
> On May 18, 11:18 am, imresunyi <imre.suny...@sonyericsson.com> wrote:
>
> > I think that initiating a shutdown when battery level reaches 0 % is
> > not that good from battery fuel gauging view. There might still be
> > some energy left in the battery when the gauging turns from 1 % to 0
> > %.
>
> > Example: Depending on the battery gauging SW and/or HW 0.5% might be
> > presented as 1 % or 0 %. If in this case it presents 0 % the battery
> > is not fully used before shutting down.
>
> I don't think so, for the following reasons:
>
> a) Battery level measurement is unlikely to be accurate to 0.5%
> anyway.
> b) The shutdown voltage is somewhat arbitrary, you'd just be shifting
> is slightly to another arbitrary point.
> c) It looks like mBatteryLevel is an integer. 0 can represent an empty
> battery just as well as BATTERY_HEALTH_DEAD or anything like that.

May I give my opinion.

a) You design your SW that takes care of HW measurement errors and
triggers shutdown before HW regulators reaches undervoltage and cuts
the power hard.
b) Not if you have thought about a)
c) 0 % _should_ represent empty battery to user but not trigger
shutdown. What matters is the voltage. That is why I think it is
better to differentiate the capacity from the shutdown. Think of your
car and its fuel gauge meter: when it is on empty you know you really
are running on the fumes now and any second the engine may stop.

I am not saying that BatteryService.java should monitor the battery
voltage. That should be done by the kernel power driver designed to
your HW. When it senses the correct shutdown voltage level trigger for
example a BATTERY_HEALTH_DEAD and shut the phone off nicely.
Reply all
Reply to author
Forward
0 new messages