Sleep Guard
helper · app · VM commandClick anywhere on this card to open its code and instructions on GitHub.
Sleep Guard protects the Googlebook from losing power when the charger is unplugged or plugged in while the lid is closed and the laptop is in deep sleep. Closing the lid still puts the laptop into normal deep sleep, so battery life is not affected.
It has three parts. A small helper runs on GooglebookOS with the same permissions as adb, without root. The Sleep Guard app starts and repairs that helper automatically after every reboot, app update and Wi-Fi reconnect, and it shows the helper's status. A command in the Linux Terminal, sleep-guard, handles pairing, installing, status and logs. Once it is set up, I never have to touch it.
I would open the lid and find a black screen. Pressing a key started a full boot instead of showing the lock screen, so any open work was lost. It happened after the laptop had slept on the charger and the charger was unplugged before the lid was opened, although not every unplug caused it.
A bug report and the firmware logs showed that the embedded controller (EC), the chip that manages power, had cold-rebooted itself and cut all power while the laptop was in deep sleep (S0ix). Its reset flags read "sysjump | hard". The EC source code shows that "hard" means software ordered a cold reboot, because a crash, a watchdog reset or a power failure leaves different flags. The EC log had also recorded a "sleep hang" after an earlier charger change.
The trigger is a race. With the lid closed, GooglebookOS force-disables every wakelock, so when a charger change wakes the laptop, it falls back into deep sleep within about 60 milliseconds while the USB-C controller is still handling the change. Lenovo's EC module is closed source, so the exact sender of the reboot command could not be identified. Many other causes were checked and ruled out, including the Setup Wizard's auto-shutdown, the lid settings, an Android shutdown, the battery level, heat, the 80% charge limit and the EC watchdog.
Sleep Guard gives the hardware a moment to finish before the laptop goes back to sleep. It notices every wake that happens with the lid closed within about 5 milliseconds and checks again 15 milliseconds later that the lid really is closed. Then it briefly tells GooglebookOS that the lid is open for power purposes, which makes wakelocks work again, while it keeps the screen and the glow bar off. The hold lasts 0.3 seconds, and it stretches to a 20-second settle period when the charger has changed. After that, everything is released and normal deep sleep resumes.
It was proven live on October 10, 2026. An unplug during deep sleep was caught 87 milliseconds after the wake, a plug-in was caught 18 milliseconds after the wake, and the laptop stayed up overnight.
Safety was treated as seriously as the fix. An early version once stalled the power service for about two minutes, so the helper now reads system service output asynchronously with a deadline and a size cap. Every command has a time limit, and a watchdog releases everything and exits if the helper ever stalls. After every exit, it restores the real lid state. On a new GooglebookOS build, it runs a self-test and stands down with a notification if anything has changed, instead of guessing. It also notices when Wireless debugging moves to a new port after a Wi-Fi drop and publishes the new port, so the app can always reconnect.
Sleep Guard wins a timing race. It is not a firmware fix. Opening the lid before unplugging the charger is always completely safe.