Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto hibernation: make sure auto-hibernation feature only happens when hibernatemode is set to 3. (Never when mode 0 or 25). #3

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
HibernationFixup Changelog
============================

#### v1.5.0
- Auto hibernation: make sure auto-hibernate feature only happens when hibernatemode is set to 3. (Never with mode 0 or 25).

#### v1.4.9
- Add macOS 14 (Sonoma) constants

Expand Down
12 changes: 6 additions & 6 deletions HibernationFixup/kern_hbfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ IOReturn HBFX::X86PlatformPlugin_sleepPolicyHandler(void * target, IOPMSystemSle
uint32_t standby_delay = 0;
bool pmset_default_mode = false;
auto autoHibernateMode = ADDPR(hbfx_config).autoHibernateMode;
while (callbackHBFX->isStandbyEnabled(standby_delay, pmset_default_mode) &&
while (callbackHBFX->isStandbyEnabled(standby_delay, pmset_default_mode) && pmset_default_mode &&
(params->sleepType == kIOPMSleepTypeDeepIdle || params->sleepType == kIOPMSleepTypeStandby || params->sleepType == kIOPMSleepTypeNormalSleep))
{
IOPMPowerSource *power_source = callbackHBFX->getPowerSource();
Expand All @@ -378,7 +378,7 @@ IOReturn HBFX::X86PlatformPlugin_sleepPolicyHandler(void * target, IOPMSystemSle
if (callbackHBFX->sleepPhase > kIOPMSleepPhase0)
{
callbackHBFX->sleepServiceWake = false;
if (pmset_default_mode && standby_delay != 0 && !callbackHBFX->wakeCalendarSet && callbackHBFX->sleepPhase > kIOPMSleepPhase0)
if (standby_delay != 0 && !callbackHBFX->wakeCalendarSet && callbackHBFX->sleepPhase > kIOPMSleepPhase0)
callbackHBFX->explicitlyCallSetMaintenanceWakeCalendar();
}
break;
Expand All @@ -389,7 +389,7 @@ IOReturn HBFX::X86PlatformPlugin_sleepPolicyHandler(void * target, IOPMSystemSle
if (callbackHBFX->sleepPhase > kIOPMSleepPhase0)
{
callbackHBFX->sleepServiceWake = false;
if (pmset_default_mode && standby_delay != 0 && !callbackHBFX->wakeCalendarSet && callbackHBFX->sleepPhase > kIOPMSleepPhase0)
if (standby_delay != 0 && !callbackHBFX->wakeCalendarSet && callbackHBFX->sleepPhase > kIOPMSleepPhase0)
callbackHBFX->explicitlyCallSetMaintenanceWakeCalendar();
}
break;
Expand Down Expand Up @@ -425,15 +425,15 @@ IOReturn HBFX::X86PlatformPlugin_sleepPolicyHandler(void * target, IOPMSystemSle
if (callbackHBFX->sleepPhase > kIOPMSleepPhase0)
{
callbackHBFX->sleepServiceWake = false;
if (pmset_default_mode && standby_delay != 0 && !callbackHBFX->wakeCalendarSet && callbackHBFX->sleepPhase > kIOPMSleepPhase0)
if (standby_delay != 0 && !callbackHBFX->wakeCalendarSet && callbackHBFX->sleepPhase > kIOPMSleepPhase0)
callbackHBFX->explicitlyCallSetMaintenanceWakeCalendar();
}
break;
}

if (callbackHBFX->sleepPhase > kIOPMSleepPhase0)
{
if (pmset_default_mode && standby_delay != 0 && !forceHibernate && !callbackHBFX->wakeCalendarSet && !callbackHBFX->sleepServiceWake)
if (standby_delay != 0 && !forceHibernate && !callbackHBFX->wakeCalendarSet && !callbackHBFX->sleepServiceWake)
callbackHBFX->explicitlyCallSetMaintenanceWakeCalendar();
}

Expand All @@ -445,7 +445,7 @@ IOReturn HBFX::X86PlatformPlugin_sleepPolicyHandler(void * target, IOPMSystemSle
#endif

bool doNotOverrideWakeUpTime = (ADDPR(hbfx_config).autoHibernateMode & Configuration::DoNotOverrideWakeUpTime);
bool setupHibernate = (forceHibernate || !callbackHBFX->wakeCalendarSet || callbackHBFX->sleepServiceWake || (pmset_default_mode && standby_delay == 0));
bool setupHibernate = (forceHibernate || !callbackHBFX->wakeCalendarSet || callbackHBFX->sleepServiceWake || standby_delay == 0);
if (setupHibernate && doNotOverrideWakeUpTime && !forceHibernate)
{
if (vars->standbyTimer != 0)
Expand Down
Loading