diff options
| author | 2023-07-19 16:37:28 -0700 | |
|---|---|---|
| committer | 2023-07-21 16:53:59 +0000 | |
| commit | d472dc84ce789689950cccd9d932511b0f93b67c (patch) | |
| tree | 1c96499b11d0d2fd0574c86e003b336ea890e05a /libs/androidfw/ObbFile.cpp | |
| parent | 86a2352b07974f8f42e3c8a5f3295805139f5aaf (diff) | |
Allow sendMotionEvent from any thread
Before this CL, sendMotionEvent was only allowed to be called from the
looper thread. However, this was not enforced in any way. This led to
bugs where the event may not be added to the internal queue of
NativeInputEventSender yet, but the fd is already getting processed and
therefore the received event was dropped without any error.
One option to fix this is to simply raise Exception when the call
happens on the wrong thread. However, that still puts the burden on the
caller to figure out how to call it properly.
Instead, in this CL, allow this method to be called on any thread.
If it's called on the looper thread, then great - return the result
immediately.
If it's called on another thread, then create a Handler and post a
future to the looper thread. Then wait indefinitely until the action is
executed on the looper thread, and return the result in the original
thread.
Bug: 290931418
Test: atest PointerEventDispatcherTest --rerun-until-failure 1000
Change-Id: I39396a8d04e73c090e7d71feafc734075ed27867
Diffstat (limited to 'libs/androidfw/ObbFile.cpp')
0 files changed, 0 insertions, 0 deletions