Ensure callbacks are run properly on executor
NsdManager callbacks were run on a provided executor by capturing the handler message in a lambda, but the message will be recycled immediately after handleMessage returns. This means that any non-inline executor would see bogus callbacks, as they have an empty Message. Fix it by not capturing the Message in the lambda, but capturing its contents instead. This was broken when updating the class to support executors in change ID: I4c31e2d7ae601ea808b1fd64df32d116c6fff97f; before that, callbacks were all run on the NsdManager handler. Also, DelegatingDiscoveryListener is being run on the NsdManager handler thread for notifyAllServicesLost, causing onServiceLost to be run there, but other methods are run on the provided Executor, even though they access maps maintained on the handler thread, like mPerNetworkListeners. Revert DelegatingDiscoveryListener to run on the handler thread as before, and only use the provided executor to execute any app-facing callback instead. Bug: 234419509 Test: atest NsdManagerTest Change-Id: Icca64511b02dad2f725a2849d2a1e871135b3286 (cherry picked from commit 9133888e) Merged-In: Icca64511b02dad2f725a2849d2a1e871135b3286
Loading
Please register or sign in to comment