Integrate new power connnect/disconnect broadcasts

Two new broadcasts, Intent.ACTION_POWER_CONNECTED and
Intent.ACTION_POWER_CONNECTED, that are issued when the device is plugged
and unplugged from USB or AC power.  This pulls two changes from the
open-source Gerrit repo into the internal Donut codeline:

1241 fda6fae Added broadcasts for external power events.
9491 37f8ca1 Fix system service crash when booting while on battery power

The current.xml API description has also been updated to include the
new Intent fields; the new API was approved in the original OSS change.
This commit is contained in:
Christopher Tate
2009-04-09 16:03:56 -07:00
parent 4d08efb7d8
commit 06ba55476e
3 changed files with 56 additions and 0 deletions

View File

@ -247,6 +247,20 @@ class BatteryService extends Binder {
logOutlier = true;
}
// Separate broadcast is sent for power connected / not connected
// since the standard intent will not wake any applications and some
// applications may want to have smart behavior based on this.
if (mPlugType != 0 && mLastPlugType == 0) {
Intent intent = new Intent(Intent.ACTION_POWER_CONNECTED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcast(intent);
}
else if (mPlugType == 0 && mLastPlugType != 0) {
Intent intent = new Intent(Intent.ACTION_POWER_DISCONNECTED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcast(intent);
}
mLastBatteryStatus = mBatteryStatus;
mLastBatteryHealth = mBatteryHealth;
mLastBatteryPresent = mBatteryPresent;