Documentation
¶
Overview ¶
Monitor user presence via PowerManager and display state.
The AttentionService requires a callback binder and system permissions, making it inaccessible from shell context. This example achieves similar user-presence detection by querying PowerManager (IsInteractive, IsDeviceIdleMode, IsPowerSaveMode) and DisplayManager (brightness), which together indicate whether a user is actively using the device.
Build:
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o build/attention_monitor ./examples/attention_monitor/ adb push build/attention_monitor /data/local/tmp/ && adb shell /data/local/tmp/attention_monitor
Click to show internal directories.
Click to hide internal directories.