Loading src/com/android/server/telecom/CallAudioRouteController.java +7 −4 Original line number Diff line number Diff line Loading @@ -958,7 +958,8 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { BluetoothDevice device = mBluetoothRoutes.get(route); // Check if in-band ringtone is enabled for the device; if it isn't, move to // inactive route. if (device != null && !mBluetoothRouteManager.isInbandRingEnabled(device)) { if (device != null && !mBluetoothRouteManager .isInbandRingEnabled(route.getType(), device)) { routeTo(false, route); } else { routeTo(true, route); Loading @@ -966,7 +967,8 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { } else { // Route is already active. BluetoothDevice device = mBluetoothRoutes.get(mCurrentRoute); if (device != null && !mBluetoothRouteManager.isInbandRingEnabled(device)) { if (device != null && !mBluetoothRouteManager .isInbandRingEnabled(mCurrentRoute.getType(), device)) { routeTo(false, mCurrentRoute); } } Loading Loading @@ -1002,8 +1004,9 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { if (bluetoothRoute != null && bluetoothDevice != null) { if (mFocusType == RINGING_FOCUS) { routeTo(mBluetoothRouteManager.isInbandRingEnabled(bluetoothDevice) && mIsActive, bluetoothRoute); routeTo(mBluetoothRouteManager .isInbandRingEnabled(bluetoothRoute.getType(), bluetoothDevice) && mIsActive, bluetoothRoute); mBluetoothAddressForRinging = bluetoothDevice.getAddress(); } else { routeTo(mIsActive, bluetoothRoute); Loading src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +28 −0 Original line number Diff line number Diff line Loading @@ -992,6 +992,34 @@ public class BluetoothDeviceManager { return isInbandRingEnabled(activeDevice); } /** * Check if inband ringing is enabled for the specified BT device. * This is intended for use by {@link CallAudioRouteController}. * @param audioRouteType The BT device type. * @param bluetoothDevice The BT device. * @return {@code true} if inband ringing is enabled, {@code false} otherwise. */ public boolean isInbandRingEnabled(@AudioRoute.AudioRouteType int audioRouteType, BluetoothDevice bluetoothDevice) { if (audioRouteType == AudioRoute.TYPE_BLUETOOTH_LE) { if (mBluetoothLeAudioService == null) { Log.i(this, "isInbandRingingEnabled: no leaudio service available."); return false; } int groupId = mBluetoothLeAudioService.getGroupId(bluetoothDevice); return mBluetoothLeAudioService.isInbandRingtoneEnabled(groupId); } else { if (getBluetoothHeadset() == null) { Log.i(this, "isInbandRingingEnabled: no headset service available."); return false; } boolean isEnabled = mBluetoothHeadset.isInbandRingingEnabled(); Log.i(this, "isInbandRingEnabled: device: %s, isEnabled: %b", bluetoothDevice, isEnabled); return isEnabled; } } public boolean isInbandRingEnabled(BluetoothDevice bluetoothDevice) { if (mBluetoothRouteManager.isCachedLeAudioDevice(bluetoothDevice)) { if (mBluetoothLeAudioService == null) { Loading src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.internal.os.SomeArgs; import com.android.internal.util.IState; import com.android.internal.util.State; import com.android.internal.util.StateMachine; import com.android.server.telecom.AudioRoute; import com.android.server.telecom.CallAudioCommunicationDeviceTracker; import com.android.server.telecom.TelecomSystem; import com.android.server.telecom.Timeouts; Loading Loading @@ -1180,6 +1181,11 @@ public class BluetoothRouteManager extends StateMachine { return mDeviceManager.isInbandRingEnabled(bluetoothDevice); } public boolean isInbandRingEnabled(@AudioRoute.AudioRouteType int audioRouteType, BluetoothDevice bluetoothDevice) { return mDeviceManager.isInbandRingEnabled(audioRouteType, bluetoothDevice); } private boolean addDevice(String address) { if (mAudioConnectingStates.containsKey(address)) { Log.i(this, "Attempting to add device %s twice.", address); Loading tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -409,7 +409,8 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { @SmallTest @Test public void testSwitchFocusForBluetoothDeviceSupportInbandRinging() { when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(true); when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO), eq(BLUETOOTH_DEVICE_1))).thenReturn(true); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, Loading Loading @@ -932,7 +933,8 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { public void testRouteFromBtSwitchInRingingSelected() { when(mFeatureFlags.ignoreAutoRouteToWatchDevice()).thenReturn(true); when(mBluetoothRouteManager.isWatch(any(BluetoothDevice.class))).thenReturn(true); when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false); when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO), eq(BLUETOOTH_DEVICE_1))).thenReturn(false); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, Loading Loading @@ -1261,7 +1263,8 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { @SmallTest public void testAbandonCallAudioFocusAfterCallEnd() { // Make sure in-band ringing is disabled so that route never becomes active when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false); when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO), eq(BLUETOOTH_DEVICE_1))).thenReturn(false); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, Loading Loading
src/com/android/server/telecom/CallAudioRouteController.java +7 −4 Original line number Diff line number Diff line Loading @@ -958,7 +958,8 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { BluetoothDevice device = mBluetoothRoutes.get(route); // Check if in-band ringtone is enabled for the device; if it isn't, move to // inactive route. if (device != null && !mBluetoothRouteManager.isInbandRingEnabled(device)) { if (device != null && !mBluetoothRouteManager .isInbandRingEnabled(route.getType(), device)) { routeTo(false, route); } else { routeTo(true, route); Loading @@ -966,7 +967,8 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { } else { // Route is already active. BluetoothDevice device = mBluetoothRoutes.get(mCurrentRoute); if (device != null && !mBluetoothRouteManager.isInbandRingEnabled(device)) { if (device != null && !mBluetoothRouteManager .isInbandRingEnabled(mCurrentRoute.getType(), device)) { routeTo(false, mCurrentRoute); } } Loading Loading @@ -1002,8 +1004,9 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { if (bluetoothRoute != null && bluetoothDevice != null) { if (mFocusType == RINGING_FOCUS) { routeTo(mBluetoothRouteManager.isInbandRingEnabled(bluetoothDevice) && mIsActive, bluetoothRoute); routeTo(mBluetoothRouteManager .isInbandRingEnabled(bluetoothRoute.getType(), bluetoothDevice) && mIsActive, bluetoothRoute); mBluetoothAddressForRinging = bluetoothDevice.getAddress(); } else { routeTo(mIsActive, bluetoothRoute); Loading
src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +28 −0 Original line number Diff line number Diff line Loading @@ -992,6 +992,34 @@ public class BluetoothDeviceManager { return isInbandRingEnabled(activeDevice); } /** * Check if inband ringing is enabled for the specified BT device. * This is intended for use by {@link CallAudioRouteController}. * @param audioRouteType The BT device type. * @param bluetoothDevice The BT device. * @return {@code true} if inband ringing is enabled, {@code false} otherwise. */ public boolean isInbandRingEnabled(@AudioRoute.AudioRouteType int audioRouteType, BluetoothDevice bluetoothDevice) { if (audioRouteType == AudioRoute.TYPE_BLUETOOTH_LE) { if (mBluetoothLeAudioService == null) { Log.i(this, "isInbandRingingEnabled: no leaudio service available."); return false; } int groupId = mBluetoothLeAudioService.getGroupId(bluetoothDevice); return mBluetoothLeAudioService.isInbandRingtoneEnabled(groupId); } else { if (getBluetoothHeadset() == null) { Log.i(this, "isInbandRingingEnabled: no headset service available."); return false; } boolean isEnabled = mBluetoothHeadset.isInbandRingingEnabled(); Log.i(this, "isInbandRingEnabled: device: %s, isEnabled: %b", bluetoothDevice, isEnabled); return isEnabled; } } public boolean isInbandRingEnabled(BluetoothDevice bluetoothDevice) { if (mBluetoothRouteManager.isCachedLeAudioDevice(bluetoothDevice)) { if (mBluetoothLeAudioService == null) { Loading
src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.internal.os.SomeArgs; import com.android.internal.util.IState; import com.android.internal.util.State; import com.android.internal.util.StateMachine; import com.android.server.telecom.AudioRoute; import com.android.server.telecom.CallAudioCommunicationDeviceTracker; import com.android.server.telecom.TelecomSystem; import com.android.server.telecom.Timeouts; Loading Loading @@ -1180,6 +1181,11 @@ public class BluetoothRouteManager extends StateMachine { return mDeviceManager.isInbandRingEnabled(bluetoothDevice); } public boolean isInbandRingEnabled(@AudioRoute.AudioRouteType int audioRouteType, BluetoothDevice bluetoothDevice) { return mDeviceManager.isInbandRingEnabled(audioRouteType, bluetoothDevice); } private boolean addDevice(String address) { if (mAudioConnectingStates.containsKey(address)) { Log.i(this, "Attempting to add device %s twice.", address); Loading
tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -409,7 +409,8 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { @SmallTest @Test public void testSwitchFocusForBluetoothDeviceSupportInbandRinging() { when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(true); when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO), eq(BLUETOOTH_DEVICE_1))).thenReturn(true); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, Loading Loading @@ -932,7 +933,8 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { public void testRouteFromBtSwitchInRingingSelected() { when(mFeatureFlags.ignoreAutoRouteToWatchDevice()).thenReturn(true); when(mBluetoothRouteManager.isWatch(any(BluetoothDevice.class))).thenReturn(true); when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false); when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO), eq(BLUETOOTH_DEVICE_1))).thenReturn(false); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, Loading Loading @@ -1261,7 +1263,8 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { @SmallTest public void testAbandonCallAudioFocusAfterCallEnd() { // Make sure in-band ringing is disabled so that route never becomes active when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false); when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO), eq(BLUETOOTH_DEVICE_1))).thenReturn(false); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, Loading