Audio service: no double message handling for A2DP device connection
This change affects the implementation of the setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent method: when the computed delay before making the device available or not available anymore is 0, perform the operation synchronously. The AudioManager method is still asynchronous, but this prevent yet another message to be processed on the AudioDeviceBroker queue. The previous implementation was causing the following message to sometimes be observed in the logs: "invalid null DeviceInfo in onBluetoothA2dpActiveDeviceChange" and was due to the following sequence of calls when an A2DP device would connect: (AM=AudioManager, AS=AudioService, ADI=AudioDeviceInventory, ADB=AudioDeviceBroker) BT service would call AM.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent AM.handleBluetoothA2dpDeviceConfigChange which was translating into the following: AM.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent AS.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent > ADB.postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent -> MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT AM.handleBluetoothA2dpDeviceConfigChange AS.handleBluetoothA2dpDeviceConfigChange > ADB.postBluetoothA2dpDeviceConfigChange ->MSG_L_A2DP_DEVICE_CONFIG_CHANGE MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT > ADI.setBluetoothA2dpDeviceConnectionState > delay = checkSendBecomingNoisyIntentInt > ADB.postA2dpSinkConnection(delay) -> MSG_IL_SET_A2DP_SINK_CONNECTION_STATE MSG_L_A2DP_DEVICE_CONFIG_CHANGE > ADI.onBluetoothA2dpActiveDeviceChange AS.AudioDeviceInventory: invalid null DeviceInfo in onBluetoothA2dpActiveDeviceChange => doesn't call AudioSystem.handleDeviceConfigChange ADB.postSetVolumeIndexOnDevice(vol, A2DP) MSG_IL_SET_A2DP_SINK_CONNECTION_STATE > ADI.onSetA2dpSinkConnectionState > ADB.postSetVolumeIndexOnDevice() > AS.postSetVolumeIndexOnDevice -> MSG... > makeA2dpDeviceAvailable: mConnectedDevices.put(...) with the new implementation we get: AM.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent AS.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent > ADB.postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent -> MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT AM.handleBluetoothA2dpDeviceConfigChange AS.handleBluetoothA2dpDeviceConfigChange > ADB.postBluetoothA2dpDeviceConfigChange ->MSG_L_A2DP_DEVICE_CONFIG_CHANGE MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT > ADI.setBluetoothA2dpDeviceConnectionState > delay = checkSendBecomingNoisyIntentInt > if delay == 0 then ADI.onSetA2dpSinkConnection() > AS.postSetVolumeIndexOnDevice -> MSG... > makeA2dpDeviceAvailable: mConnectedDevices.put(...) MSG_L_A2DP_DEVICE_CONFIG_CHANGE > ADI.onBluetoothA2dpActiveDeviceChange > AudioSystem.handleDeviceConfigChange > ADB.postSetVolumeIndexOnDevice(vol, A2DP) Bug: 132602437 Bug: 132416679 Test: connect/disconnect A2DP devices and verify "dumpsys audio" for absence of "invalid null DeviceInfo" messages Change-Id: If9afd6174f8e49273ce20912a60b2f64b19b6d94
Loading
Please register or sign in to comment