Back to the experimentSupporting notebook

Motorola G54 keyboard lock and display findings

Source: motorola-g54/findings.md · revision 6550ead3945b

Date: 2026-09-22

Outcome

The Motorola moto g54 5G is running PixelOS 16 and is rooted. The dedicated lock key on the connected HP 970/975 keyboard now locks the phone and turns the display fully off immediately. The clock and other lock-screen pixels are no longer visible after the key is used.

Device and software

Original behavior

Pressing the keyboard’s dedicated lock key generated a Meta+L chord. PixelOS handled that as KEY_GESTURE_TYPE_LOCK_SCREEN, which locked the keyguard but left the display on for the lock-screen timeout. The observed delay was about 10 seconds. During that interval Android reported the phone as locked while the display remained ON.

The same behavior was visible in the input and power state:

The phone’s physical side power button behaved differently: it immediately requested power_button sleep.

Display settings investigated

The clock was not caused by Android’s always-on display setting alone. The following settings were inspected:

The screen timeout was also found set to 2147483647 ms (effectively never), and the phone was sometimes charging with stay_on_while_plugged_in=7. Those settings explain why waiting for a normal timeout was not a useful solution, but they do not explain the keyboard lock delay: Meta+L was invoking the lock-screen gesture rather than sleep.

The device contains g54_native_aod and missedcallzero-aod Magisk modules, but both had a disable marker when inspected. Their service scripts are relevant if they are re-enabled later because they can restore Doze/AOD settings at boot.

Implemented fix

A small root daemon was installed for this exact keyboard:

The daemon:

  1. Watches only the HP 970/975 main keyboard with vendor 03f0 and product 6343.
  2. Detects the exact Meta+L sequence after both keys are released.
  3. Leaves PixelOS’s normal lock-screen action intact.
  4. Immediately invokes KEYCODE_SLEEP so the display transitions to off.
  5. Reconnects when the Bluetooth keyboard disconnects and reconnects.
  6. Ignores ordinary typing, modified chords, held-key repeats, and incomplete/cancelled chords.
  7. Uses a file lock so only one daemon instance can run.

The first prototype invoked the Android input command with inherited descriptors and Android rejected it with transaction status 512. The final version redirects the child command’s standard descriptors to /dev/null; the sleep command then returned status 0.

No framework files, generic key layouts, or global keyboard mappings were modified.

Verification

The daemon’s built-in tests passed for ordinary typing, modifier handling, chord release ordering, repeat suppression, modified chords, and cancellation.

The exact raw Meta+L sequence was replayed through the keyboard input device after installation. The observed state was:

The user then confirmed that the keyboard lock button behaved as intended.

Persistence and rollback

The launcher is in Magisk’s /data/adb/service.d, so the daemon is configured to start after boot. A reboot was not performed during this session; boot persistence is based on the installed service launcher and should be checked after the next planned reboot.

To disable the behavior without removing files, create:

/data/adb/g54-keyboard-sleep/disabled

Then stop the daemon after verifying the PID in daemon.lock belongs to this binary. Removing the launcher and daemon directory restores PixelOS’s original Meta+L behavior, subject to the usual Magisk file-removal procedure.

Important boundary

The handler is intentionally specific to the HP 970/975 keyboard. Another keyboard, a different HID identity, or a future firmware change will not be affected automatically. The keyboard’s event node number must not be hard-coded because it changes across reconnects; the daemon identifies the device by vendor, product, and name instead.