Loading android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +11 −0 Original line number Diff line number Diff line Loading @@ -405,6 +405,16 @@ public class HearingAidService extends ProfileService { } } /** * Get the HiSyncIdMap for testing * * @return mDeviceHiSyncIdMap */ @VisibleForTesting Map<BluetoothDevice, Long> getHiSyncIdMap() { return mDeviceHiSyncIdMap; } int getConnectionState(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); synchronized (mStateMachines) { Loading Loading @@ -658,6 +668,7 @@ public class HearingAidService extends ProfileService { if (bondState != BluetoothDevice.BOND_NONE) { return; } mDeviceHiSyncIdMap.remove(device); synchronized (mStateMachines) { HearingAidStateMachine sm = mStateMachines.get(device); if (sm == null) { Loading android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -916,6 +916,31 @@ public class HearingAidServiceTest { mService.getConnectionState(mLeftDevice)); } /** * Test that the service can update HiSyncId from native message */ @Test public void getHiSyncIdFromNative_addToMap() { getHiSyncIdFromNative(); Assert.assertTrue("hiSyncIdMap should contain mLeftDevice", mService.getHiSyncIdMap().containsKey(mLeftDevice)); Assert.assertTrue("hiSyncIdMap should contain mRightDevice", mService.getHiSyncIdMap().containsKey(mRightDevice)); Assert.assertTrue("hiSyncIdMap should contain mSingleDevice", mService.getHiSyncIdMap().containsKey(mSingleDevice)); } /** * Test that the service removes the device from HiSyncIdMap when it's unbonded */ @Test public void deviceUnbonded_removeHiSyncId() { getHiSyncIdFromNative(); mService.bondStateChanged(mLeftDevice, BluetoothDevice.BOND_NONE); Assert.assertFalse("hiSyncIdMap shouldn't contain mLeftDevice", mService.getHiSyncIdMap().containsKey(mLeftDevice)); } private void connectDevice(BluetoothDevice device) { HearingAidStackEvent connCompletedEvent; Loading Loading
android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +11 −0 Original line number Diff line number Diff line Loading @@ -405,6 +405,16 @@ public class HearingAidService extends ProfileService { } } /** * Get the HiSyncIdMap for testing * * @return mDeviceHiSyncIdMap */ @VisibleForTesting Map<BluetoothDevice, Long> getHiSyncIdMap() { return mDeviceHiSyncIdMap; } int getConnectionState(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); synchronized (mStateMachines) { Loading Loading @@ -658,6 +668,7 @@ public class HearingAidService extends ProfileService { if (bondState != BluetoothDevice.BOND_NONE) { return; } mDeviceHiSyncIdMap.remove(device); synchronized (mStateMachines) { HearingAidStateMachine sm = mStateMachines.get(device); if (sm == null) { Loading
android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -916,6 +916,31 @@ public class HearingAidServiceTest { mService.getConnectionState(mLeftDevice)); } /** * Test that the service can update HiSyncId from native message */ @Test public void getHiSyncIdFromNative_addToMap() { getHiSyncIdFromNative(); Assert.assertTrue("hiSyncIdMap should contain mLeftDevice", mService.getHiSyncIdMap().containsKey(mLeftDevice)); Assert.assertTrue("hiSyncIdMap should contain mRightDevice", mService.getHiSyncIdMap().containsKey(mRightDevice)); Assert.assertTrue("hiSyncIdMap should contain mSingleDevice", mService.getHiSyncIdMap().containsKey(mSingleDevice)); } /** * Test that the service removes the device from HiSyncIdMap when it's unbonded */ @Test public void deviceUnbonded_removeHiSyncId() { getHiSyncIdFromNative(); mService.bondStateChanged(mLeftDevice, BluetoothDevice.BOND_NONE); Assert.assertFalse("hiSyncIdMap shouldn't contain mLeftDevice", mService.getHiSyncIdMap().containsKey(mLeftDevice)); } private void connectDevice(BluetoothDevice device) { HearingAidStackEvent connCompletedEvent; Loading