Skip to content

Keep screen awake during active computer use - #46

Merged
Miyamura80 merged 2 commits into
mainfrom
claude/android-screen-timeout-computer-use-qti51o
Sep 16, 2026
Merged

Miyamura80 merged 2 commits into
mainfrom
claude/android-screen-timeout-computer-use-qti51o

Conversation

@Miyamura80

@Miyamura80 Miyamura80 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The phone screen dimming or sleeping mid-session interrupts computer use: AndroidComputerSource refuses to act once the screen is off, so a normal device screen timeout cuts sessions short.

This holds the display awake while computer use is active by adding FLAG_KEEP_SCREEN_ON to the computer-use border overlay window (which is already re-armed on every observe/control call). It needs no WAKE_LOCK permission and makes no device-wide timeout change, and it releases on its own once the agent goes quiet.

FLAG_KEEP_SCREEN_ON only keeps an already-on screen awake; it cannot wake a screen that is already off, which is consistent with the existing screen-off guard. Starting a session on a sleeping phone is intentionally out of scope.

Changes

  • Add FLAG_KEEP_SCREEN_ON to the border overlay window in ComputerUseBorderOverlay.
  • Keep the animated frame's short linger (~1.5s, unchanged UX) but keep the window attached ~60s to bridge gaps between commands (model latency, network), then detach and release the screen.
  • Move the frame-linger timing into LiquidMetalBorderView (poke(mode) self-limits and quiesces on its own), so the overlay owns a single concern and a single timer. onDraw paints nothing while idle, so the window stays attached with no GPU work.
  • Document KEEP_AWAKE_MILLIS as an idle timeout (not a session length) and its failure mode: a gap longer than it between two actions lets the screen sleep. There is no explicit session-end signal to key off, since computer use is a stream of discrete observe/control calls.

Testing

  • Build passes (./gradlew assembleDebug)
  • Unit tests pass (./gradlew testDebugUnitTest)
  • Lint passes (./gradlew lintDebug)

Note: no Android SDK in the authoring sandbox, so these are left for CI (the "Build & unit test" job) to verify. No unit-test-shaped logic changed; the change is Android View/WindowManager wiring.

Related Issues

Closes #

🤖 Generated with Claude Code

https://claude.ai/code/session_01K3vMrbcQhiGuMZdUdg8hHg


Generated by Claude Code


Summary by cubic

Prevents a normal screen timeout from interrupting computer-use sessions by keeping the display awake while the border overlay is attached.

  • AndroidComputerSource already refuses to act once the screen is off, so a device screen timeout used to cut sessions short.
  • The overlay window now sets FLAG_KEEP_SCREEN_ON and stays attached for 60s after the last command; the animated frame still disappears after ~1.5s as before.
  • It needs no WAKE_LOCK permission, changes no device-wide timeout, and can only keep an already-on screen awake—it cannot wake a sleeping screen.
  • A gap longer than 60s between two actions can still let the screen sleep.

Written for commit b49aa52. Summary will update on new commits.

Review in cubic

The screen dimming or sleeping mid-session interrupts computer use: today
AndroidComputerSource refuses to act once the screen is off, so a normal
device screen timeout cuts sessions short.

Add FLAG_KEEP_SCREEN_ON to the computer-use border overlay window, which is
already re-armed on every observe/control call. This holds the display awake
for as long as the window is attached, with no WAKE_LOCK permission and no
device-wide timeout change, and releases on its own once the agent goes quiet.

Decouple two lifetimes so behaviour stays clean:
- The animated frame still hides ~1.5s after the last command (unchanged UX).
- The window itself lingers ~60s to bridge the gaps between commands (model
  latency, network) so the screen does not dim between actions, then detaches.

While idle the view paints nothing, so no GPU work happens; the window simply
stays attached to hold the screen on. FLAG_KEEP_SCREEN_ON only keeps an
already-on screen awake, consistent with the existing screen-off guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K3vMrbcQhiGuMZdUdg8hHg
Address code-review feedback on the keep-screen-on change. Fold the frame's
linger timing into LiquidMetalBorderView so the overlay owns a single concern
and a single timer:

- The view self-limits: poke(mode) refreshes an animate-until deadline and the
  frame loop quiesces on its own once pokes stop, clearing to transparent. The
  animation time base is still set only when starting from idle, so repeated
  pokes extend the frame with no visual jump.
- ComputerUseBorderOverlay drops the second timer, the hideFrame() pass-through,
  and its copy of the frame-linger constant. It now only schedules window removal
  (the keep-awake lifetime), and signal() reduces to attach + poke + reschedule.
- setMode is now private (poke is the only entry point); startAnimating is gone.
- Document KEEP_AWAKE_MILLIS as an idle timeout, not a session length, and state
  its failure mode: a gap longer than it between two actions lets the screen
  sleep mid-session. There is no explicit session-end signal to key off (computer
  use is a stream of discrete observe/control calls), so the idle timeout stands.

No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K3vMrbcQhiGuMZdUdg8hHg
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@Miyamura80
Miyamura80 merged commit 812d06b into main Sep 16, 2026
3 checks passed
@github-actions
github-actions Bot deleted the claude/android-screen-timeout-computer-use-qti51o branch September 16, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants