Skip to content
Commit 905273c7 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Cherrypicker Worker
Browse files

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
parent a2f1cf35
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment