mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1003020 - Update to the latest battery level when HFP manager initializes, r=shuang
This commit is contained in:
parent
cb4cbe2613
commit
8ca90b6b5b
@ -406,6 +406,10 @@ BluetoothHfpManager::Init()
|
||||
}
|
||||
|
||||
hal::RegisterBatteryObserver(this);
|
||||
// Update to the latest battery level
|
||||
hal::BatteryInformation batteryInfo;
|
||||
hal::GetCurrentBatteryInformation(&batteryInfo);
|
||||
Notify(batteryInfo);
|
||||
|
||||
mListener = new BluetoothRilListener();
|
||||
NS_ENSURE_TRUE(mListener->Listen(true), false);
|
||||
@ -521,7 +525,7 @@ BluetoothHfpManager::Notify(const hal::BatteryInformation& aBatteryInfo)
|
||||
{
|
||||
// Range of battery level: [0, 1], double
|
||||
// Range of CIND::BATTCHG: [0, 5], int
|
||||
mBattChg = (int) ceil(aBatteryInfo.level() * 5.0);
|
||||
mBattChg = (int) round(aBatteryInfo.level() * 5.0);
|
||||
UpdateDeviceCIND();
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ BluetoothHfpManager::Notify(const hal::BatteryInformation& aBatteryInfo)
|
||||
{
|
||||
// Range of battery level: [0, 1], double
|
||||
// Range of CIND::BATTCHG: [0, 5], int
|
||||
int level = ceil(aBatteryInfo.level() * 5.0);
|
||||
int level = round(aBatteryInfo.level() * 5.0);
|
||||
if (level != sCINDItems[CINDType::BATTCHG].value) {
|
||||
sCINDItems[CINDType::BATTCHG].value = level;
|
||||
SendCommand(RESPONSE_CIEV, CINDType::BATTCHG);
|
||||
@ -425,6 +425,10 @@ BluetoothHfpManager::Init()
|
||||
}
|
||||
|
||||
hal::RegisterBatteryObserver(this);
|
||||
// Update to the latest battery level
|
||||
hal::BatteryInformation batteryInfo;
|
||||
hal::GetCurrentBatteryInformation(&batteryInfo);
|
||||
Notify(batteryInfo);
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
mListener = new BluetoothRilListener();
|
||||
|
Loading…
Reference in New Issue
Block a user