Fix A2DP not connecting while asleep.
This is a port of an older fix, which was probably lost in merging: https://github.com/zewt/android_frameworks_base/commit/111ed5d16f95163fb58bb87407c9ab7268e0893a This bug happens on a stock 2.3.4 Nexus S; it's not a CM-specific problem. This fix should probably go upstream at some point. Original log: > Some BlueTooth devices will initiate a HFP connection, and then leave it > to the phone to initiate A2DP. This was handled with MESSAGE_CONNECT_TO. > > However, this was sent using mHandler.sendMessageDelayed, which won't > wake the phone if it's asleep. This caused some BT devices to cleanly > connect using HFP, but to not connect A2DP until the phone is manually > woken up to allow the MESSAGE_CONNECT_TO message to be delivered. > > Replace this message with an AlarmManager alarm, which will wake the > device properly. Improves connection with Sony MEX-BT3800U. > > (Connecting is still not completely reliable; connecting sometimes still > mysteriously fails, but this helps a lot.) (The problem is now with CONNECT_OTHER_PROFILES.) In case anyone in upstream QA wants to take the initiative to buy the device for future testing, see: http://www.amazon.com/dp/B0032FOJPM . Note that in order to reproduce this problem, the phone must actually be asleep; any unrelated application holding a stray wakelock can mask this bug. This may not be the ideal way to approach this: it uses AlarmManager to schedule the connection, but the scheduled intent then queues the actual connection to the event loop. In principle, the phone may go to sleep again in the interim. It would be better to actually handle the connection from the intent handler, as the original patch did, so we can be sure a wakelock is held for the duration. It's not clear to me how to do that with the HierarchicalStateMachine, however, and I havn't yet had any problems with doing it like this; at any rate it shouldn't cause any regressions. Change-Id: I41353abd87127cd04d68b15754655c57d3928499 Signed-off-by:Glenn Maynard <glenn@zewt.org>
Loading
Please register or sign in to comment