Repository navigation
Exit pass-through mode on the main thread - #160
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
timer that ran out kept its thread until the next time the mode came
on and the old timer was garbage collected.
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.
and left the first one running, so the mode could still end 4 seconds
after it first came on.
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.