Loading android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +49 −42 Original line number Diff line number Diff line Loading @@ -373,6 +373,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac return; } mHearingAidConnectedDevices.add(device); } // New connected device: select it as active if (setHearingAidActiveDevice(device)) { setA2dpActiveDevice(null, true); Loading @@ -380,7 +381,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac setLeAudioActiveDevice(null, true); } } } private void handleLeAudioConnected(BluetoothDevice device) { synchronized (mLock) { Loading Loading @@ -669,8 +669,12 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac private void handleHearingAidActiveDeviceChanged(BluetoothDevice device) { synchronized (mLock) { if (DBG) { Log.d(TAG, "handleHearingAidActiveDeviceChanged: " + device + ", mHearingAidActiveDevices=" + mHearingAidActiveDevices); Log.d( TAG, "handleHearingAidActiveDeviceChanged: " + device + ", mHearingAidActiveDevices=" + mHearingAidActiveDevices); } // Just assign locally the new value final HearingAidService hearingAidService = mFactory.getHearingAidService(); Loading @@ -684,13 +688,13 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac hearingAidService.getConnectedPeerDevices(hiSyncId)); } } } if (device != null) { setA2dpActiveDevice(null, true); setHfpActiveDevice(null); setLeAudioActiveDevice(null, true); } } } private void handleLeAudioActiveDeviceChanged(BluetoothDevice device) { synchronized (mLock) { Loading Loading @@ -849,26 +853,29 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private boolean setHfpActiveDevice(BluetoothDevice device) { synchronized (mLock) { if (DBG) { Log.d(TAG, "setHfpActiveDevice(" + device + ")"); } synchronized (mLock) { if (mPendingActiveDevice != null) { mHandler.removeCallbacksAndMessages(mPendingActiveDevice); mPendingActiveDevice = null; } } final HeadsetService headsetService = mFactory.getHeadsetService(); if (headsetService == null) { return false; } BluetoothSinkAudioPolicy audioPolicy = headsetService.getHfpCallAudioPolicy(device); if (audioPolicy != null && audioPolicy.getActiveDevicePolicyAfterConnection() if (audioPolicy != null && audioPolicy.getActiveDevicePolicyAfterConnection() == BluetoothSinkAudioPolicy.POLICY_NOT_ALLOWED) { return false; } if (!headsetService.setActiveDevice(device)) { return false; } synchronized (mLock) { mHfpActiveDevice = device; } return true; Loading Loading @@ -923,7 +930,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac Log.d(TAG, "setLeAudioActiveDevice(" + device + ")" + (device == null ? " hasFallbackDevice=" + hasFallbackDevice : "")); } synchronized (mLock) { final LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService == null) { return false; Loading @@ -939,6 +945,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac return false; } synchronized (mLock) { mLeAudioActiveDevice = device; if (device == null) { mLeHearingAidActiveDevice = null; Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +1 −1 Original line number Diff line number Diff line Loading @@ -1339,12 +1339,12 @@ public class HeadsetService extends ProfileService { * Remove the active device */ private void removeActiveDevice() { BluetoothDevice fallbackDevice = mActiveDeviceManager.getHfpFallbackDevice(); synchronized (mStateMachines) { // As per b/202602952, if we remove the active device due to a disconnection, // we need to check if another device is connected and set it active instead. // Calling this before any other active related calls has the same effect as // a classic active device switch. BluetoothDevice fallbackDevice = mActiveDeviceManager.getHfpFallbackDevice(); if (fallbackDevice != null && mActiveDevice != null && getConnectionState(mActiveDevice) != BluetoothProfile.STATE_CONNECTED) { setActiveDevice(fallbackDevice); Loading Loading
android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +49 −42 Original line number Diff line number Diff line Loading @@ -373,6 +373,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac return; } mHearingAidConnectedDevices.add(device); } // New connected device: select it as active if (setHearingAidActiveDevice(device)) { setA2dpActiveDevice(null, true); Loading @@ -380,7 +381,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac setLeAudioActiveDevice(null, true); } } } private void handleLeAudioConnected(BluetoothDevice device) { synchronized (mLock) { Loading Loading @@ -669,8 +669,12 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac private void handleHearingAidActiveDeviceChanged(BluetoothDevice device) { synchronized (mLock) { if (DBG) { Log.d(TAG, "handleHearingAidActiveDeviceChanged: " + device + ", mHearingAidActiveDevices=" + mHearingAidActiveDevices); Log.d( TAG, "handleHearingAidActiveDeviceChanged: " + device + ", mHearingAidActiveDevices=" + mHearingAidActiveDevices); } // Just assign locally the new value final HearingAidService hearingAidService = mFactory.getHearingAidService(); Loading @@ -684,13 +688,13 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac hearingAidService.getConnectedPeerDevices(hiSyncId)); } } } if (device != null) { setA2dpActiveDevice(null, true); setHfpActiveDevice(null); setLeAudioActiveDevice(null, true); } } } private void handleLeAudioActiveDeviceChanged(BluetoothDevice device) { synchronized (mLock) { Loading Loading @@ -849,26 +853,29 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private boolean setHfpActiveDevice(BluetoothDevice device) { synchronized (mLock) { if (DBG) { Log.d(TAG, "setHfpActiveDevice(" + device + ")"); } synchronized (mLock) { if (mPendingActiveDevice != null) { mHandler.removeCallbacksAndMessages(mPendingActiveDevice); mPendingActiveDevice = null; } } final HeadsetService headsetService = mFactory.getHeadsetService(); if (headsetService == null) { return false; } BluetoothSinkAudioPolicy audioPolicy = headsetService.getHfpCallAudioPolicy(device); if (audioPolicy != null && audioPolicy.getActiveDevicePolicyAfterConnection() if (audioPolicy != null && audioPolicy.getActiveDevicePolicyAfterConnection() == BluetoothSinkAudioPolicy.POLICY_NOT_ALLOWED) { return false; } if (!headsetService.setActiveDevice(device)) { return false; } synchronized (mLock) { mHfpActiveDevice = device; } return true; Loading Loading @@ -923,7 +930,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac Log.d(TAG, "setLeAudioActiveDevice(" + device + ")" + (device == null ? " hasFallbackDevice=" + hasFallbackDevice : "")); } synchronized (mLock) { final LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService == null) { return false; Loading @@ -939,6 +945,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac return false; } synchronized (mLock) { mLeAudioActiveDevice = device; if (device == null) { mLeHearingAidActiveDevice = null; Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +1 −1 Original line number Diff line number Diff line Loading @@ -1339,12 +1339,12 @@ public class HeadsetService extends ProfileService { * Remove the active device */ private void removeActiveDevice() { BluetoothDevice fallbackDevice = mActiveDeviceManager.getHfpFallbackDevice(); synchronized (mStateMachines) { // As per b/202602952, if we remove the active device due to a disconnection, // we need to check if another device is connected and set it active instead. // Calling this before any other active related calls has the same effect as // a classic active device switch. BluetoothDevice fallbackDevice = mActiveDeviceManager.getHfpFallbackDevice(); if (fallbackDevice != null && mActiveDevice != null && getConnectionState(mActiveDevice) != BluetoothProfile.STATE_CONNECTED) { setActiveDevice(fallbackDevice); Loading