Loading android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java +13 −0 Original line number Diff line number Diff line Loading @@ -493,6 +493,19 @@ public class CsipSetCoordinatorService extends ProfileService { return null; } synchronized (mGroupIdToUuidMap) { if (!mGroupIdToUuidMap.containsKey(groupId)) { try { callback.onGroupLockSet(groupId, BluetoothStatusCodes.ERROR_CSIP_INVALID_GROUP_ID, false); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return null; } } UUID uuid = UUID.randomUUID(); synchronized (mLocks) { if (mLocks.containsKey(groupId)) { Loading android/app/tests/unit/src/com/android/bluetooth/csip/CsipSetCoordinatorServiceTest.java +34 −14 Original line number Diff line number Diff line Loading @@ -250,35 +250,45 @@ public class CsipSetCoordinatorServiceTest { */ @Test public void testGroupLockSetNative() { int group = 0x02; int group_id = 0x01; int group_size = 0x01; long uuidLsb = 0x01; long uuidMsb = 0x01; UUID uuid = new UUID(uuidMsb, uuidLsb); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) .onDeviceAvailable(any(byte[].class), anyInt(), anyInt(), anyLong(), anyLong()); mCsipSetCoordinatorNativeInterface.onDeviceAvailable( getByteAddress(mTestDevice), group_id, group_size, uuidLsb, uuidMsb); UUID lock_uuid = mService.lockGroup(group, mCsipSetCoordinatorLockCallback); UUID lock_uuid = mService.lockGroup(group_id, mCsipSetCoordinatorLockCallback); Assert.assertNotNull(lock_uuid); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(true)); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(true)); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) .onGroupLockChanged(anyInt(), anyBoolean(), anyInt()); mCsipSetCoordinatorNativeInterface.onGroupLockChanged( group, true, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); group_id, true, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); try { verify(mCsipSetCoordinatorLockCallback, times(1)) .onGroupLockSet(group, BluetoothStatusCodes.SUCCESS, .onGroupLockSet(group_id, BluetoothStatusCodes.SUCCESS, true); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mService.unlockGroup(lock_uuid); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(false)); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(false)); mCsipSetCoordinatorNativeInterface.onGroupLockChanged( group, false, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); group_id, false, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); try { verify(mCsipSetCoordinatorLockCallback, times(1)) .onGroupLockSet(group, BluetoothStatusCodes.SUCCESS, .onGroupLockSet(group_id, BluetoothStatusCodes.SUCCESS, false); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading @@ -291,14 +301,24 @@ public class CsipSetCoordinatorServiceTest { */ @Test public void testGroupExclusiveLockSet() { int group = 0x02; int group_id = 0x01; int group_size = 0x01; long uuidLsb = 0x01; long uuidMsb = 0x01; UUID uuid = new UUID(uuidMsb, uuidLsb); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) .onDeviceAvailable(any(byte[].class), anyInt(), anyInt(), anyLong(), anyLong()); mCsipSetCoordinatorNativeInterface.onDeviceAvailable( getByteAddress(mTestDevice), group_id, group_size, uuidLsb, uuidMsb); UUID lock_uuid = mService.lockGroup(group, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(true)); UUID lock_uuid = mService.lockGroup(group_id, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(true)); Assert.assertNotNull(lock_uuid); lock_uuid = mService.lockGroup(group, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(true)); lock_uuid = mService.lockGroup(group_id, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(true)); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) Loading @@ -306,7 +326,7 @@ public class CsipSetCoordinatorServiceTest { try { verify(mCsipSetCoordinatorLockCallback, times(1)) .onGroupLockSet(group, .onGroupLockSet(group_id, BluetoothStatusCodes.ERROR_CSIP_GROUP_LOCKED_BY_OTHER, true); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading Loading
android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java +13 −0 Original line number Diff line number Diff line Loading @@ -493,6 +493,19 @@ public class CsipSetCoordinatorService extends ProfileService { return null; } synchronized (mGroupIdToUuidMap) { if (!mGroupIdToUuidMap.containsKey(groupId)) { try { callback.onGroupLockSet(groupId, BluetoothStatusCodes.ERROR_CSIP_INVALID_GROUP_ID, false); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return null; } } UUID uuid = UUID.randomUUID(); synchronized (mLocks) { if (mLocks.containsKey(groupId)) { Loading
android/app/tests/unit/src/com/android/bluetooth/csip/CsipSetCoordinatorServiceTest.java +34 −14 Original line number Diff line number Diff line Loading @@ -250,35 +250,45 @@ public class CsipSetCoordinatorServiceTest { */ @Test public void testGroupLockSetNative() { int group = 0x02; int group_id = 0x01; int group_size = 0x01; long uuidLsb = 0x01; long uuidMsb = 0x01; UUID uuid = new UUID(uuidMsb, uuidLsb); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) .onDeviceAvailable(any(byte[].class), anyInt(), anyInt(), anyLong(), anyLong()); mCsipSetCoordinatorNativeInterface.onDeviceAvailable( getByteAddress(mTestDevice), group_id, group_size, uuidLsb, uuidMsb); UUID lock_uuid = mService.lockGroup(group, mCsipSetCoordinatorLockCallback); UUID lock_uuid = mService.lockGroup(group_id, mCsipSetCoordinatorLockCallback); Assert.assertNotNull(lock_uuid); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(true)); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(true)); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) .onGroupLockChanged(anyInt(), anyBoolean(), anyInt()); mCsipSetCoordinatorNativeInterface.onGroupLockChanged( group, true, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); group_id, true, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); try { verify(mCsipSetCoordinatorLockCallback, times(1)) .onGroupLockSet(group, BluetoothStatusCodes.SUCCESS, .onGroupLockSet(group_id, BluetoothStatusCodes.SUCCESS, true); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mService.unlockGroup(lock_uuid); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(false)); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(false)); mCsipSetCoordinatorNativeInterface.onGroupLockChanged( group, false, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); group_id, false, IBluetoothCsipSetCoordinator.CSIS_GROUP_LOCK_SUCCESS); try { verify(mCsipSetCoordinatorLockCallback, times(1)) .onGroupLockSet(group, BluetoothStatusCodes.SUCCESS, .onGroupLockSet(group_id, BluetoothStatusCodes.SUCCESS, false); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading @@ -291,14 +301,24 @@ public class CsipSetCoordinatorServiceTest { */ @Test public void testGroupExclusiveLockSet() { int group = 0x02; int group_id = 0x01; int group_size = 0x01; long uuidLsb = 0x01; long uuidMsb = 0x01; UUID uuid = new UUID(uuidMsb, uuidLsb); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) .onDeviceAvailable(any(byte[].class), anyInt(), anyInt(), anyLong(), anyLong()); mCsipSetCoordinatorNativeInterface.onDeviceAvailable( getByteAddress(mTestDevice), group_id, group_size, uuidLsb, uuidMsb); UUID lock_uuid = mService.lockGroup(group, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(true)); UUID lock_uuid = mService.lockGroup(group_id, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(true)); Assert.assertNotNull(lock_uuid); lock_uuid = mService.lockGroup(group, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group), eq(true)); lock_uuid = mService.lockGroup(group_id, mCsipSetCoordinatorLockCallback); verify(mCsipSetCoordinatorNativeInterface, times(1)).groupLockSet(eq(group_id), eq(true)); doCallRealMethod() .when(mCsipSetCoordinatorNativeInterface) Loading @@ -306,7 +326,7 @@ public class CsipSetCoordinatorServiceTest { try { verify(mCsipSetCoordinatorLockCallback, times(1)) .onGroupLockSet(group, .onGroupLockSet(group_id, BluetoothStatusCodes.ERROR_CSIP_GROUP_LOCKED_BY_OTHER, true); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading