Bug 1426936 - When reading the battery capacity on Mac do not assume that a battery is always present; r=dhylands

MozReview-Commit-ID: ArLSxMUE66e

--HG--
extra : source : edc74a4258f9d3b7944058abfd0051bb3655476a
This commit is contained in:
Gabriele Svelto 2018-03-05 23:35:36 +01:00
parent 8fde6f2e59
commit 1c42dcf92c

View file

@ -254,9 +254,13 @@ MacPowerInformationService::HandleChange(void* aContext) {
continue;
}
// Get a battery level estimate. This key is required.
// Get a battery level estimate. This key is required but does not always
// exist.
int currentCapacity = 0;
const void* cfRef = ::CFDictionaryGetValue(currPowerSourceDesc, CFSTR(kIOPSCurrentCapacityKey));
if (!cfRef) {
continue;
}
::CFNumberGetValue((CFNumberRef)cfRef, kCFNumberSInt32Type, &currentCapacity);
// This key is also required.