Skip to content

Commit

Permalink
Add workaround for Nano Launch Daemons not restarting after userspace…
Browse files Browse the repository at this point in the history
… reboot
  • Loading branch information
opa334 committed Feb 21, 2024
1 parent 3b11f81 commit d863c3a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions BaseBin/launchdhook/src/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
bool firstLoad = false;
if (getenv("DOPAMINE_INITIALIZED") != 0) {
// If Dopamine was initialized before, we assume we're coming from a userspace reboot

// Stock bug: These prefs wipe themselves after a reboot (they contain a boot time and this is matched when they're loaded)
// But on userspace reboots, they apparently do not get wiped as boot time doesn't change
// We could try to change the boot time ourselves, but I'm worried of potential side effects
// So we just wipe the offending preferences ourselves
// In practice this fixes nano launch daemons not being loaded after the userspace reboot, resulting in certain apple watch features breaking
if (access("/var/mobile/Library/Preferences/com.apple.NanoRegistry.NRRootCommander.volatile.plist", W_OK)) {
remove("/var/mobile/Library/Preferences/com.apple.NanoRegistry.NRRootCommander.volatile.plist");
}
if (access("/var/mobile/Library/Preferences/com.apple.NanoRegistry.NRLaunchNotificationController.volatile.plist", W_OK)) {
remove("/var/mobile/Library/Preferences/com.apple.NanoRegistry.NRLaunchNotificationController.volatile.plist");
}
}
else {
// Here we should have been injected into a live launchd on the fly
Expand Down

0 comments on commit d863c3a

Please sign in to comment.