Skip to content

Exit pass-through mode on the main thread - #160

Merged
trypsynth merged 1 commit into
trypsynth:masterfrom
zywek123:passthrough-timer
Oct 12, 2026
Merged

trypsynth merged 1 commit into
trypsynth:masterfrom
zywek123:passthrough-timer

Conversation

@zywek123

Copy link
Copy Markdown
Contributor

Pass-through mode hands the next touch straight to the app, and turns
itself off if no touch starts within 4 seconds. PassThroughModeActor
timed that with a java.util.Timer:

  • Each time the mode came on, the timer started a thread of its own. A
    timer that ran out kept its thread until the next time the mode came
    on and the old timer was garbage collected.
  • The exit ran on that thread. It set the pass-through region, played
    the earcon through the feedback pipeline and turned the mode off,
    while the main thread could be turning the mode on or off, locking it
    for the braille keyboard, or changing direct touch's region.
  • Turning the mode on while it was already on started a second timer
    and left the first one running, so the mode could still end 4 seconds
    after it first came on.
  • Turning the mode off without a touch, as when the screen rotates, left
    the timer running, so up to 4 seconds later it set the region again,
    over the circle menu's if that had opened since.

The exit now runs from a Handler on the main thread, where the rest of
PassThroughModeActor already runs, as the pipeline's actors and
TalkBackService call it there. Turning the mode on drops an exit still
pending and posts a new one, so the 4 seconds start over. Turning the
mode off, a touch that starts, the braille keyboard's lock and
onDestroy() remove it, whether or not the mode is on, as removing an
exit that isn't pending does nothing.

PassThroughModeActorTest runs the actor with the pass-through region and
the feedback pipeline recorded, on a paused main looper: the mode ends
on the main thread 4 seconds after it came on, turning it on again
starts the 4 seconds over, turning it off leaves the region alone
afterwards, and a touch that starts keeps the mode on. Without the
change, the first two tests fail, and without dropping the exit when
the mode turns off, the third one does.

Not tried on a device.

  Pass-through mode turns itself off when no touch starts within 4 seconds, and it timed that with a java.util.Timer. Each time the mode came on, the timer started a thread of its own, and one that ran out kept it until the timer was
  garbage collected. The exit ran on that thread: it set the pass-through region, played the earcon and turned the mode off while the main thread could be doing the same. Turning the mode on again while it was on started a second timer
  and left the first one running, so the mode could still end 4 seconds after it first came on. Turning the mode off without a touch, as when the screen rotates, left the timer running too, so up to 4 seconds later it set the region
  again, over the circle menu's if that had opened since. The exit now runs on the main thread, turning the mode on again starts the 4 seconds over, and turning it off drops an exit still pending.
@trypsynth
trypsynth merged commit fc7db97 into trypsynth:master Oct 12, 2026
2 checks passed
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.

3 participants