public final class BatteryService extends SystemService
BatteryService monitors the charging status, and charge level of the device
battery. When these values change this service broadcasts the new values
to all IntentReceivers
that are
watching the BATTERY_CHANGED
action.
The new values are stored in the Intent data and can be retrieved by
calling Intent.getExtra
with the
following keys:
"scale" - int, the maximum value for the charge level
"level" - int, charge level, from 0 through "scale" inclusive
"status" - String, the current charging status.
"health" - String, the current battery health.
"present" - boolean, true if the battery is present
"icon-small" - int, suggested small icon to use for this state
"plugged" - int, 0 if the device is not plugged in; 1 if plugged into an AC power adapter; 2 if plugged in via USB.
"voltage" - int, current battery voltage in millivolts
"temperature" - int, current battery temperature in tenths of a degree Centigrade
"technology" - String, the type of battery installed, e.g. "Li-ion"
The battery service may be called by the power manager while holding its locks so we take care to post all outcalls into the activity manager to a handler. FIXME: Ideally the power manager would perform all of its calls into the battery service asynchronously itself.
PHASE_ACTIVITY_MANAGER_READY, PHASE_BOOT_COMPLETED, PHASE_LOCK_SETTINGS_READY, PHASE_SYSTEM_SERVICES_READY, PHASE_THIRD_PARTY_APPS_CAN_START, PHASE_WAIT_FOR_DEFAULT_DISPLAY
Constructor and Description |
---|
BatteryService(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
onBootPhase(int phase)
Called on each phase of the boot process.
|
void |
onStart()
Called when the dependencies listed in the @Service class-annotation are available
and after the chosen start phase.
|
getBinderService, getContext, getLocalService, isSafeMode, onCleanupUser, onStartUser, onStopUser, onSwitchUser, onUnlockUser, publishBinderService, publishBinderService, publishLocalService
public BatteryService(Context context)
public void onStart()
SystemService
onStart
in class SystemService
public void onBootPhase(int phase)
SystemService
onBootPhase
in class SystemService
phase
- The current boot phase.