summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
authorAvichal Rakesh <arakesh@google.com>2021-12-21 17:10:35 -0800
committerAvichal Rakesh <arakesh@google.com>2022-01-21 13:36:06 -0800
commit666ad3a9ac1492744256e86ada9617a897c0b799 (patch)
treea10c9091778d0c8f4d48ad0b96de8b64d9cae00e /core/java/android/inputmethodservice/InputMethodService.java
parentb5956636ffd61b6f4e009c7b50372262acc55be5 (diff)
Prevent onImageAvailable from being called on stale listeners
ImageReader queues up calls to OnImageAvailableListener#onImageAvailable (one for each frame) by wrapping them in Runnables and passing the Runnables to an Executor, which in turn executes Runnables in order. Before queuing the Runnable, ImageReader reads the value of listener and passes a reference to the listener that is current at the time of queueing to the Runnable. This reference is used when calling onImageAvailable. If the listener changes between when a Runnable is queued and when the Runnable is executed, it is possible for the Runnable to call into a stale listener. This CL replaces the mutex used to guard the state of ImageReader with a StampedLock behaving as a Read-Write Lock. The Runnables wrapping calls to OnImageAvailableListener#onImageAvailable grab a read lock and calls the onImageAvailable method of the listener referenced by ImageReader at the time of Runnable's execution. Any call to modify the listener grabs the write lock. Bug: 204438677 Test: Existing CTS tests pass Change-Id: I7b11243962595e8c41912a483a80ecd8d3c3e945
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
0 files changed, 0 insertions, 0 deletions