Loading src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -188,6 +188,7 @@ public class BluetoothDeviceManager { private BluetoothLeAudio mBluetoothLeAudioService; private boolean mLeAudioSetAsCommunicationDevice = false; private String mLeAudioDevice; private String mHearingAidDevice; private boolean mHearingAidSetAsCommunicationDevice = false; private BluetoothDevice mBluetoothHearingAidActiveDeviceCache; private BluetoothAdapter mBluetoothAdapter; Loading Loading @@ -444,10 +445,17 @@ public class BluetoothDeviceManager { } public void clearHearingAidCommunicationDevice() { Log.i(this, "clearHearingAidCommunicationDevice: mHearingAidSetAsCommunicationDevice = " + mHearingAidSetAsCommunicationDevice); if (!mHearingAidSetAsCommunicationDevice) { return; } mHearingAidSetAsCommunicationDevice = false; if (mHearingAidDevice != null) { mBluetoothRouteManager.onAudioLost(mHearingAidDevice); mHearingAidDevice = null; } if (mAudioManager == null) { Log.i(this, "clearHearingAidCommunicationDevice: mAudioManager is null"); return; Loading Loading @@ -551,6 +559,7 @@ public class BluetoothDeviceManager { Log.w(this, " Could not set hearingAid device"); } else { Log.i(this, " hearingAid device set"); mHearingAidDevice = hearingAid.getAddress(); mHearingAidSetAsCommunicationDevice = true; } return result; Loading src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -491,7 +491,8 @@ public class BluetoothRouteManager extends StateMachine { SomeArgs args = (SomeArgs) msg.obj; Log.continueSession(((Session) args.arg1), "BRM.pM_" + msg.what); Log.i(LOG_TAG, "Message received: %s.", MESSAGE_CODE_TO_NAME.get(msg.what)); Log.i(LOG_TAG, "%s received message: %s.", this, MESSAGE_CODE_TO_NAME.get(msg.what)); } else if (msg.what == RUN_RUNNABLE && msg.obj instanceof Runnable) { Log.i(LOG_TAG, "Running runnable for testing"); } else { Loading tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ import java.util.List; @RunWith(JUnit4.class) public class BluetoothDeviceManagerTest extends TelecomTestCase { private static final String DEVICE_ADDRESS_1 = "00:00:00:00:00:01"; @Mock BluetoothRouteManager mRouteManager; @Mock BluetoothHeadset mBluetoothHeadset; @Mock BluetoothAdapter mAdapter; Loading Loading @@ -492,6 +494,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { @Test public void testClearHearingAidCommunicationDevice() { AudioDeviceInfo mockAudioDeviceInfo = mock(AudioDeviceInfo.class); when(mockAudioDeviceInfo.getAddress()).thenReturn(DEVICE_ADDRESS_1); when(mockAudioDeviceInfo.getType()).thenReturn(AudioDeviceInfo.TYPE_HEARING_AID); List<AudioDeviceInfo> devices = new ArrayList<>(); devices.add(mockAudioDeviceInfo); Loading @@ -504,6 +507,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { mBluetoothDeviceManager.setHearingAidCommunicationDevice(); when(mockAudioManager.getCommunicationDevice()).thenReturn(mSpeakerInfo); mBluetoothDeviceManager.clearHearingAidCommunicationDevice(); verify(mRouteManager).onAudioLost(eq(DEVICE_ADDRESS_1)); assertFalse(mBluetoothDeviceManager.isHearingAidSetAsCommunicationDevice()); } Loading Loading
src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -188,6 +188,7 @@ public class BluetoothDeviceManager { private BluetoothLeAudio mBluetoothLeAudioService; private boolean mLeAudioSetAsCommunicationDevice = false; private String mLeAudioDevice; private String mHearingAidDevice; private boolean mHearingAidSetAsCommunicationDevice = false; private BluetoothDevice mBluetoothHearingAidActiveDeviceCache; private BluetoothAdapter mBluetoothAdapter; Loading Loading @@ -444,10 +445,17 @@ public class BluetoothDeviceManager { } public void clearHearingAidCommunicationDevice() { Log.i(this, "clearHearingAidCommunicationDevice: mHearingAidSetAsCommunicationDevice = " + mHearingAidSetAsCommunicationDevice); if (!mHearingAidSetAsCommunicationDevice) { return; } mHearingAidSetAsCommunicationDevice = false; if (mHearingAidDevice != null) { mBluetoothRouteManager.onAudioLost(mHearingAidDevice); mHearingAidDevice = null; } if (mAudioManager == null) { Log.i(this, "clearHearingAidCommunicationDevice: mAudioManager is null"); return; Loading Loading @@ -551,6 +559,7 @@ public class BluetoothDeviceManager { Log.w(this, " Could not set hearingAid device"); } else { Log.i(this, " hearingAid device set"); mHearingAidDevice = hearingAid.getAddress(); mHearingAidSetAsCommunicationDevice = true; } return result; Loading
src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -491,7 +491,8 @@ public class BluetoothRouteManager extends StateMachine { SomeArgs args = (SomeArgs) msg.obj; Log.continueSession(((Session) args.arg1), "BRM.pM_" + msg.what); Log.i(LOG_TAG, "Message received: %s.", MESSAGE_CODE_TO_NAME.get(msg.what)); Log.i(LOG_TAG, "%s received message: %s.", this, MESSAGE_CODE_TO_NAME.get(msg.what)); } else if (msg.what == RUN_RUNNABLE && msg.obj instanceof Runnable) { Log.i(LOG_TAG, "Running runnable for testing"); } else { Loading
tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ import java.util.List; @RunWith(JUnit4.class) public class BluetoothDeviceManagerTest extends TelecomTestCase { private static final String DEVICE_ADDRESS_1 = "00:00:00:00:00:01"; @Mock BluetoothRouteManager mRouteManager; @Mock BluetoothHeadset mBluetoothHeadset; @Mock BluetoothAdapter mAdapter; Loading Loading @@ -492,6 +494,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { @Test public void testClearHearingAidCommunicationDevice() { AudioDeviceInfo mockAudioDeviceInfo = mock(AudioDeviceInfo.class); when(mockAudioDeviceInfo.getAddress()).thenReturn(DEVICE_ADDRESS_1); when(mockAudioDeviceInfo.getType()).thenReturn(AudioDeviceInfo.TYPE_HEARING_AID); List<AudioDeviceInfo> devices = new ArrayList<>(); devices.add(mockAudioDeviceInfo); Loading @@ -504,6 +507,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { mBluetoothDeviceManager.setHearingAidCommunicationDevice(); when(mockAudioManager.getCommunicationDevice()).thenReturn(mSpeakerInfo); mBluetoothDeviceManager.clearHearingAidCommunicationDevice(); verify(mRouteManager).onAudioLost(eq(DEVICE_ADDRESS_1)); assertFalse(mBluetoothDeviceManager.isHearingAidSetAsCommunicationDevice()); } Loading