Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +22 −3 Original line number Diff line number Diff line Loading @@ -127,8 +127,8 @@ public class AudioDeviceBroker { // Delay before checking it music should be unmuted after processing an A2DP message private static final int BTA2DP_MUTE_CHECK_DELAY_MS = 200; // Delay before unmuting call after HFP device switch private static final int HFP_SWITCH_CALL_UNMUTE_DELAY_MS = 2000; // Delay before unmuting call after HFP or LE Audio device switch private static final int HS_SWITCH_CALL_UNMUTE_DELAY_MS = 2000; // Delay before attempting to restore devices again after audioserver died and a previous // restore attempt failed Loading Loading @@ -369,7 +369,7 @@ public class AudioDeviceBroker { if (deviceSwitch && isBluetoothScoActive()) { mAudioService.setCallMute(true); sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 0 /*unmute*/, HFP_SWITCH_CALL_UNMUTE_DELAY_MS); 0 /*unmute*/, HS_SWITCH_CALL_UNMUTE_DELAY_MS); } else if (btDevice == null) { sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 0 /*unmute*/, 0 /*delay */); Loading Loading @@ -1613,6 +1613,15 @@ public class AudioDeviceBroker { } /*package*/ void postBluetoothActiveDevice(BtDeviceInfo info, int delay) { if (info.mProfile == BluetoothProfile.LE_AUDIO && info.mState == BluetoothProfile.STATE_DISCONNECTED && info.mIsDeviceSwitch && isBluetoothLeAudioRequested()) { sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 1 /*mute*/, delay); sendIMsg(MSG_I_MUTE_CALL, SENDMSG_QUEUE, 0 /*unmute*/, delay + HS_SWITCH_CALL_UNMUTE_DELAY_MS); } sendLMsg(MSG_L_SET_BT_ACTIVE_DEVICE, SENDMSG_QUEUE, info, delay); } Loading Loading @@ -2676,6 +2685,7 @@ public class AudioDeviceBroker { + ((mCommunicationStrategyId == -1) ? "failure" : "success"))).printLog(ALOGW, TAG)); } AudioDeviceAttributes appliedCommunicationDevice = null; if (preferredCommunicationDevice == null) { AudioDeviceAttributes defaultDevice = getDefaultCommunicationDevice(); if (defaultDevice != null) { Loading @@ -2689,13 +2699,22 @@ public class AudioDeviceBroker { } mDeviceInventory.applyConnectedDevicesRoles(); mDeviceInventory.reapplyExternalDevicesRoles(); appliedCommunicationDevice = defaultDevice; } else { mDeviceInventory.setPreferredDevicesForStrategyInt( mCommunicationStrategyId, Arrays.asList(preferredCommunicationDevice)); mDeviceInventory.setPreferredDevicesForStrategyInt( mAccessibilityStrategyId, Arrays.asList(preferredCommunicationDevice)); appliedCommunicationDevice = preferredCommunicationDevice; } onUpdatePhoneStrategyDevice(preferredCommunicationDevice); if (appliedCommunicationDevice != null && AudioSystem.isBluetoothLeOutDevice( appliedCommunicationDevice.getInternalType())) { sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 0 /*unmute*/, 0 /*delay */); } } // Pairs of input and output devices for duplex communication devices (headsets) Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +7 −4 Original line number Diff line number Diff line Loading @@ -1043,6 +1043,7 @@ public class AudioDeviceInventory { int deviceType = BtHelper.getTypeFromProfile(btInfo.mProfile, btInfo.mIsLeOutput); boolean disconnectDevice = false; synchronized (mDevicesLock) { if (mDeviceBroker.hasScheduledA2dpConnection(btDevice, btInfo.mProfile)) { AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( Loading Loading @@ -1084,8 +1085,7 @@ public class AudioDeviceInventory { // force A2DP device disconnection in case of error so that AudioService // state is consistent with audio policy manager state setBluetoothActiveDevice(new AudioDeviceBroker.BtDeviceInfo(btInfo, BluetoothProfile.STATE_DISCONNECTED)); disconnectDevice = true; } else { AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "APM handleDeviceConfigChange success for device addr=" Loading @@ -1101,6 +1101,10 @@ public class AudioDeviceInventory { } } } if (disconnectDevice) { setBluetoothActiveDevice(new AudioDeviceBroker.BtDeviceInfo(btInfo, BluetoothProfile.STATE_DISCONNECTED)); } mmi.record(); return delayMs; } Loading Loading @@ -2171,12 +2175,11 @@ public class AudioDeviceInventory { } else { delay = 0; } if (AudioService.DEBUG_DEVICES) { Log.i(TAG, "setBluetoothActiveDevice " + info.toString() + " delay(ms): " + delay); } mDeviceBroker.postBluetoothActiveDevice(info, delay); } mDeviceBroker.postBluetoothActiveDevice(info, delay); return delay; } Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +22 −3 Original line number Diff line number Diff line Loading @@ -127,8 +127,8 @@ public class AudioDeviceBroker { // Delay before checking it music should be unmuted after processing an A2DP message private static final int BTA2DP_MUTE_CHECK_DELAY_MS = 200; // Delay before unmuting call after HFP device switch private static final int HFP_SWITCH_CALL_UNMUTE_DELAY_MS = 2000; // Delay before unmuting call after HFP or LE Audio device switch private static final int HS_SWITCH_CALL_UNMUTE_DELAY_MS = 2000; // Delay before attempting to restore devices again after audioserver died and a previous // restore attempt failed Loading Loading @@ -369,7 +369,7 @@ public class AudioDeviceBroker { if (deviceSwitch && isBluetoothScoActive()) { mAudioService.setCallMute(true); sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 0 /*unmute*/, HFP_SWITCH_CALL_UNMUTE_DELAY_MS); 0 /*unmute*/, HS_SWITCH_CALL_UNMUTE_DELAY_MS); } else if (btDevice == null) { sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 0 /*unmute*/, 0 /*delay */); Loading Loading @@ -1613,6 +1613,15 @@ public class AudioDeviceBroker { } /*package*/ void postBluetoothActiveDevice(BtDeviceInfo info, int delay) { if (info.mProfile == BluetoothProfile.LE_AUDIO && info.mState == BluetoothProfile.STATE_DISCONNECTED && info.mIsDeviceSwitch && isBluetoothLeAudioRequested()) { sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 1 /*mute*/, delay); sendIMsg(MSG_I_MUTE_CALL, SENDMSG_QUEUE, 0 /*unmute*/, delay + HS_SWITCH_CALL_UNMUTE_DELAY_MS); } sendLMsg(MSG_L_SET_BT_ACTIVE_DEVICE, SENDMSG_QUEUE, info, delay); } Loading Loading @@ -2676,6 +2685,7 @@ public class AudioDeviceBroker { + ((mCommunicationStrategyId == -1) ? "failure" : "success"))).printLog(ALOGW, TAG)); } AudioDeviceAttributes appliedCommunicationDevice = null; if (preferredCommunicationDevice == null) { AudioDeviceAttributes defaultDevice = getDefaultCommunicationDevice(); if (defaultDevice != null) { Loading @@ -2689,13 +2699,22 @@ public class AudioDeviceBroker { } mDeviceInventory.applyConnectedDevicesRoles(); mDeviceInventory.reapplyExternalDevicesRoles(); appliedCommunicationDevice = defaultDevice; } else { mDeviceInventory.setPreferredDevicesForStrategyInt( mCommunicationStrategyId, Arrays.asList(preferredCommunicationDevice)); mDeviceInventory.setPreferredDevicesForStrategyInt( mAccessibilityStrategyId, Arrays.asList(preferredCommunicationDevice)); appliedCommunicationDevice = preferredCommunicationDevice; } onUpdatePhoneStrategyDevice(preferredCommunicationDevice); if (appliedCommunicationDevice != null && AudioSystem.isBluetoothLeOutDevice( appliedCommunicationDevice.getInternalType())) { sendIMsg(MSG_I_MUTE_CALL, SENDMSG_REPLACE, 0 /*unmute*/, 0 /*delay */); } } // Pairs of input and output devices for duplex communication devices (headsets) Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +7 −4 Original line number Diff line number Diff line Loading @@ -1043,6 +1043,7 @@ public class AudioDeviceInventory { int deviceType = BtHelper.getTypeFromProfile(btInfo.mProfile, btInfo.mIsLeOutput); boolean disconnectDevice = false; synchronized (mDevicesLock) { if (mDeviceBroker.hasScheduledA2dpConnection(btDevice, btInfo.mProfile)) { AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( Loading Loading @@ -1084,8 +1085,7 @@ public class AudioDeviceInventory { // force A2DP device disconnection in case of error so that AudioService // state is consistent with audio policy manager state setBluetoothActiveDevice(new AudioDeviceBroker.BtDeviceInfo(btInfo, BluetoothProfile.STATE_DISCONNECTED)); disconnectDevice = true; } else { AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( "APM handleDeviceConfigChange success for device addr=" Loading @@ -1101,6 +1101,10 @@ public class AudioDeviceInventory { } } } if (disconnectDevice) { setBluetoothActiveDevice(new AudioDeviceBroker.BtDeviceInfo(btInfo, BluetoothProfile.STATE_DISCONNECTED)); } mmi.record(); return delayMs; } Loading Loading @@ -2171,12 +2175,11 @@ public class AudioDeviceInventory { } else { delay = 0; } if (AudioService.DEBUG_DEVICES) { Log.i(TAG, "setBluetoothActiveDevice " + info.toString() + " delay(ms): " + delay); } mDeviceBroker.postBluetoothActiveDevice(info, delay); } mDeviceBroker.postBluetoothActiveDevice(info, delay); return delay; } Loading