Changeset 85259 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jul 11, 2020 11:58:17 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/darwin/HostPowerDarwin.cpp
r82968 r85259 201 201 powerSource = POWER_SOURCE_BATTERY; 202 202 203 204 /* Fetch the current capacity value of the power source */ 203 205 int curCapacity = 0; 204 int maxCapacity = 1;205 float remCapacity = 0.0f;206 207 /* Fetch the current capacity value of the power source */208 206 result = CFDictionaryGetValueIfPresent(pSource, CFSTR(kIOPSCurrentCapacityKey), &psValue); 209 207 if (result) 210 208 CFNumberGetValue((CFNumberRef)psValue, kCFNumberSInt32Type, &curCapacity); 209 211 210 /* Fetch the maximum capacity value of the power source */ 211 int maxCapacity = 1; 212 212 result = CFDictionaryGetValueIfPresent(pSource, CFSTR(kIOPSMaxCapacityKey), &psValue); 213 213 if (result) … … 215 215 216 216 /* Calculate the remaining capacity in percent */ 217 remCapacity = ((float)curCapacity/(float)maxCapacity * 100.0);217 float remCapacity = ((float)curCapacity/(float)maxCapacity * 100.0f); 218 218 219 219 /* Check for critical. 5 percent is default. */ … … 222 222 if (result) 223 223 CFNumberGetValue((CFNumberRef)psValue, kCFNumberSInt32Type, &criticalValue); 224 critical = (remCapacity < criticalValue); 224 critical = remCapacity < criticalValue; 225 225 226 /* We have to take action only if we are on battery, the 226 227 * previous state wasn't critical, the state has changed & the
Note:
See TracChangeset
for help on using the changeset viewer.