mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 726612 - Gonk Battery API backend doesn't mark the device as charging when plugged to AC. r=mounir
This commit is contained in:
parent
9ab74fadea
commit
c44c953812
@ -256,6 +256,10 @@ DisableBatteryNotifications()
|
||||
void
|
||||
GetCurrentBatteryInformation(hal::BatteryInformation *aBatteryInfo)
|
||||
{
|
||||
static const int BATTERY_NOT_CHARGING = 0;
|
||||
static const int BATTERY_CHARGING_USB = 1;
|
||||
static const int BATTERY_CHARGING_AC = 2;
|
||||
|
||||
FILE *capacityFile = fopen("/sys/class/power_supply/battery/capacity", "r");
|
||||
double capacity = dom::battery::kDefaultLevel * 100;
|
||||
if (capacityFile) {
|
||||
@ -270,8 +274,17 @@ GetCurrentBatteryInformation(hal::BatteryInformation *aBatteryInfo)
|
||||
fclose(chargingFile);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (chargingSrc != BATTERY_NOT_CHARGING &&
|
||||
chargingSrc != BATTERY_CHARGING_USB &&
|
||||
chargingSrc != BATTERY_CHARGING_AC) {
|
||||
HAL_LOG(("charging_source contained unknown value: %d", chargingSrc));
|
||||
}
|
||||
#endif
|
||||
|
||||
aBatteryInfo->level() = capacity / 100;
|
||||
aBatteryInfo->charging() = chargingSrc == 1;
|
||||
aBatteryInfo->charging() = (chargingSrc == BATTERY_CHARGING_USB ||
|
||||
chargingSrc == BATTERY_CHARGING_AC);
|
||||
aBatteryInfo->remainingTime() = dom::battery::kUnknownRemainingTime;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user