move removeActiveDevice out of mBtA2dpLock scope
Issue:
setActiveDevice(null) will be blocked for 1 second in corner case.
Analysis:
When disconnecting a2dp, setActiveDeviceInternal->removeActiveDevice
->setActiveDevice(null) will be called, and mBtA2dpLock is acquired.
At the same time, remote device is disconnected, then onConnectionStateChanged
->messageFromNative wants to acqurie mBtA2dpLock, so btif thread will
keep waiting, and be stuck. In stack, set_active_device will wait on
session_wait_cv unitl BTIF_AV_TRIGGER_HANDOFF_REQ_EVT is handled.
Because btif thread is already stuck, BTIF_AV_TRIGGER_HANDOFF_REQ_EVT
will not be handled, then set_active_device had to wait 1s until timeout.
Fix:
To fix it, move removeActiveDevice out of mBtA2dpLock scope to avoid acquring
mBtA2dpLock when calling mA2dpNativeInterface.setActiveDevice(null) in
removeActiveDevice. Besides, replace mVariableLock with a new lock
to avoid this issue, too.
Change-Id: I4714af7cea40b4f10e57cd5a1dbde3d1b24ce9e0
CRs-Fixed: 2545368
1 file changed