[Magnifier-60] Fix race condition after #dismiss
The CL fixes a race condition introduced by
I2799229bee7acfbd6236089487a5766f46605366, which caused apps to crash
when, for example, the following happened:
1. #show(xc, yc, xm, ym) is called on the main thread, and the
arguments are stored in mPrevShow[Source/Window]Coords
2. #show(xc, yc, xm', ym') is called on the main thread (note that only
the window position is different from the previous call), and we
post a job to the pixel copy handler thread to only update the
expected position of mWindow (without doing pixel copy)
3. the job starts and checks that mWindow != currentWindowInstance is
false
4. #dismiss() is called on the main thread, mWindow is set to null
5. the position update job at step 3 continues, grabs mLock but now mWindow is null
and the crash happens
Bug: 113272299
Test: manual testing
Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest
Change-Id: Ibc815888f4eeaf077fa1a9ddfb1d4d401382623a
1 file changed