From e12c39bb9cedb8b363658979872694eb55b1386e Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Wed, 6 Jun 2012 10:51:58 -0700 Subject: [PATCH] Always queue A2DP connection state message with wakelock held Messages for changes to A2DP connection state are intended to be queued in AudioService after acquiring a wake lock, which is released after the message has been handled. This was correctly done for connection messages when the system is up and running, but wasn't when the BluetoothProfile service listener gets an onServiceConnected() event, which is the case the the device boots. This change correctly uses the queueMsgUnderWakeLock() method whenever a MSG_SET_A2DP_CONNECTION_STATE is to be sent. Bug 6616292 Change-Id: Ie337a4641a89c522e2d233bccaac4e08ce324117 --- media/java/android/media/AudioService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index a2c20fd032702..5da30bd6fa4af 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -135,8 +135,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { private static final int MSG_RCDISPLAY_UPDATE = 13; private static final int MSG_SET_ALL_VOLUMES = 14; private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 15; - private static final int MSG_SET_WIRED_DEVICE_CONNECTION_STATE = 16;//handled under wakelock - private static final int MSG_SET_A2DP_CONNECTION_STATE = 17; //handled under wakelock + // messages handled under wakelock, can only be queued, i.e. sent with queueMsgUnderWakeLock(), + // and not with sendMsg(..., ..., SENDMSG_QUEUE, ...) + private static final int MSG_SET_WIRED_DEVICE_CONNECTION_STATE = 16; + private static final int MSG_SET_A2DP_CONNECTION_STATE = 17; // flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be @@ -1962,9 +1964,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { int delay = checkSendBecomingNoisyIntent( AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0); - sendMsg(mAudioHandler, + queueMsgUnderWakeLock(mAudioHandler, MSG_SET_A2DP_CONNECTION_STATE, - SENDMSG_QUEUE, state, 0, btDevice,