HalDeviceManager avoid unnecessary re-posting of onDestroyed

Add thread check logic in HalDeviceManager to check if the current
thread under execution is the handler thread that's supposed to trigger
"onDestroyed".

If the current thread is already the intended thread, then simply
directly invoke onDestroyed synchronously.

If the current thread is not the intended thread, then post the
onDestroyed callback to the intended thread.

Bug: 199792691
Test: atest com.android.server.wifi
Change-Id: I8a9c7d3614498d2bc898c0a7e901ff35afb4f570
CRs-Fixed: 3035002
(Cherry-picked from 0db46757f4af5e3c3b9cc2c5d10645e88d26a688)
3 files changed