A base port can implement code to monitor the battery of the phone and to provide notifications when the battery power is low.
The battery monitor code is implemented in the power controller kernel extension.
Note: to implement battery monitor code, the battery monitor hardware must be accessible to the Application CPU of the phone.
Typically, your battery monitor class would derive from the DBatteryMonitor class, defined as:
class DBatteryMonitor { public: IMPORT_C DBatteryMonitor(); IMPORT_C void Register(); public: virtual TSupplyStatus MachinePowerStatus() = 0; virtual void SystemTimeChanged(TInt anOldTime, TInt aNewTime) = 0; };
Symbian platform considers that batteries can be in one of 4 possible logical states, defined by the TSupplyStatus enum. It is up to the implementor of the battery monitor component to map these logical states to points on the main battery discharge curve.
There are two pure virtual functions to be implemented:
We also suggest that the battery monitor component offer a public function prototyped as:
void SupplyInfo(TSupplyInfoV1& si);
to supply information about the state of the main battery and the backup battery (if there is one), or external power to user side components that may require it (e.g. a user-side power monitor component that is used to track the state of batteries and initiate an orderly shutdown if it reaches a critically low level), and is usually called by the EHalGroupPower handler for EPowerHalSupplyInfo in response to calling HAL::Get() with EPowerGood, EPowerBatteryStatus, EPowerBackupStatus, and EPowerExternal. Such a function would need to fill in a subset of the fields defined by TSupplyInfoV1.
virtual TSupplyStatus MachinePowerStatus() = 0;
This should read and return the logical state of the main battery or, if external power is connected, it should return EGood.
When is it called?
The function is called by peripheral drivers via a call to Kern::MachinePowerStatus() before starting lengthy operations or operations that may result in a substantial increase in power consumption.
Implementation issues
A suggested implementation would have the function reading the state of the main battery, or whether external power is connected, and mapping to one of the logical states defined by TSupplyStatus. When requested by the power manager it returns the logical state.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.