Skip to content

Commit

Permalink
experimental fix for battery status startup problem (issue #21) on 10.13
Browse files Browse the repository at this point in the history
  • Loading branch information
RehabMan committed Aug 28, 2017
1 parent 4181a3d commit eb8a58d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ACPIBatteryManager.xcodeproj/project.pbxproj
Expand Up @@ -254,7 +254,7 @@
LLVM_LTO = NO;
"LLVM_LTO[arch=x86_64]" = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MODULE_VERSION = 1.71;
MODULE_VERSION = 1.80;
OTHER_CFLAGS = "-fno-stack-protector";
"OTHER_LDFLAGS[arch=x86_64]" = "-dead_strip";
SDKROOT = macosx10.8;
Expand Down Expand Up @@ -284,7 +284,7 @@
LLVM_LTO = NO;
"LLVM_LTO[arch=x86_64]" = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MODULE_VERSION = 1.71;
MODULE_VERSION = 1.80;
OTHER_CFLAGS = "-fno-stack-protector";
"OTHER_LDFLAGS[arch=x86_64]" = "-dead_strip";
SDKROOT = macosx10.8;
Expand Down
4 changes: 2 additions & 2 deletions AppleSmartBatteryManager/ACPIBatteryManager-Info.plist
Expand Up @@ -58,8 +58,8 @@
<true/>
<key>Correct16bitSignedCurrentRate</key>
<true/>
<key>StartupDelay</key>
<integer>0</integer>
<key>FirstPollDelay</key>
<integer>7500</integer>
</dict>
</dict>
<key>ACPI Battery Tracker</key>
Expand Down
12 changes: 5 additions & 7 deletions AppleSmartBatteryManager/AppleSmartBattery.cpp
Expand Up @@ -287,9 +287,9 @@ bool AppleSmartBattery::loadConfiguration()
if (OSNumber* currentDischargeRateMax = OSDynamicCast(OSNumber, config->getObject(kCurrentDischargeRateMaxInfoKey)))
fCurrentDischargeRateMax = currentDischargeRateMax->unsigned32BitValue();

fStartupDelay = 0;
if (OSNumber* startupDelay = OSDynamicCast(OSNumber, config->getObject(kStartupDelay)))
fStartupDelay = startupDelay->unsigned32BitValue();
fFirstPollDelay = 7500;
if (OSNumber* firstPollDelay = OSDynamicCast(OSNumber, config->getObject(kFirstPollDelay)))
fFirstPollDelay = firstPollDelay->unsigned32BitValue();

// Configuration done, release allocated merged configuration
OSSafeRelease(merged);
Expand Down Expand Up @@ -360,11 +360,9 @@ bool AppleSmartBattery::start(IOService *provider)
fPollingInterval = kQuickPollInterval;
clearBatteryState(false);

// some DSDT implementations aren't ready to read the EC yet, so avoid false reading
IOSleep(fStartupDelay);

// Kick off the 30 second timer and do an initial poll
pollBatteryState( kNewBatteryPath );
//pollBatteryState( kNewBatteryPath );
fPollTimer->setTimeoutMS(fFirstPollDelay);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions AppleSmartBatteryManager/AppleSmartBattery.h
Expand Up @@ -147,8 +147,8 @@
// Define this in Info.plist to correct for current capacity in _BST being 16-bit signed
#define kCorrect16bitSignedCurrentRate "Correct16bitSignedCurrentRate"

// Define this in Info.plist to change the startup delay before ACPI calls are made
#define kStartupDelay "StartupDelay"
// For configuring the time before the first status poll
#define kFirstPollDelay "FirstPollDelay"

// for pollBatteryState
enum
Expand Down Expand Up @@ -199,7 +199,7 @@ class EXPORT AppleSmartBattery : public IOPMPowerSource
bool fCorrectCorruptCapacities;
bool fCorrect16bitSignedCurrentRate;
UInt32 fCurrentDischargeRateMax; // to cap reported Amperage
UInt32 fStartupDelay;
UInt32 fFirstPollDelay;

// Accessor for MaxError reading
// Percent error in MaxCapacity reading
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -78,6 +78,11 @@ http://www.tonymacx86.com/hp-probook/69472-battery-manager-fix-boot-without-batt

### Change Log:

2017-08-28 v1.80

- Fix problem of losing battery icon on 10.13 High Sierra beta. It is a new timing bug introduced in High Sierra. Delaying the first poll and battery status publish fixes it. StartupDelay configuration is removed (not used, has no effect if specified in ACPI override). New configuration item FirstPollDelay is default at 7500. Slower computers may need a longer delay (for my Lenovo u430, 3500 is too short, 4000 is long enough).


2017-08-26 v1.71

- Fix problem with Activity Monitor "Energy" tab, by changing class names to AppleSmartBatteryManager and AppleSmartBattery
Expand Down
2 changes: 1 addition & 1 deletion SSDT-ACPIBATT.dsl
Expand Up @@ -16,7 +16,7 @@ DefinitionBlock ("", "SSDT", 2, "hack", "acpibatt", 0)
"CurrentDischargeRateMax", 20000,
"CorrectCorruptCapacities", ">y",
"Correct16bitSignedCurrentRate", ">y",
"StartupDelay", 0,
"FirstPollDelay", 7500,
})
}
// EOF
2 changes: 1 addition & 1 deletion config_override.txt
Expand Up @@ -19,7 +19,7 @@ Method(RMCF)\n
"CurrentDischargeRateMax", 20000,\n
"CorrectCorruptCapacities", ">y",\n
"Correct16bitSignedCurrentRate", ">y",\n
"StartupDelay", 0,\n
"FirstPollDelay", 7500,\n
})\n
}\n
end;

0 comments on commit eb8a58d

Please sign in to comment.