speech: Fix RemoteSpeechReco race condition
stopListening schedules a Runnable referring to mDelegatingListener. mDelegatingListener can be set to null before the Runnable runs, causing NullPointerException when it does run. This CL defines a local alias for the current mDelegatingListener reference, and uses this new alias in the Runnable closure. After this CL, even if mDelegatingListener changes between stopListening and run(), run() will always use the DelegatingListener mDelegatingListener was pointing to at schedule-time rather than run-time. Bug: 193046622 Test: atest CtsVoiceRecognitionTestCases Change-Id: I98b4fabf074873ce17e4046e243fe22f9e541f91
Loading
Please register or sign in to comment