Loading android/app/tests/unit/src/com/android/bluetooth/le_audio/LeAudioServiceTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -1034,7 +1034,7 @@ public class LeAudioServiceTest { @Test public void testGetActiveDevices() { int groupId = 1; int direction = 1; int direction = 2; int snkAudioLocation = 3; int srcAudioLocation = 4; int availableContexts = 5; Loading Loading @@ -1085,8 +1085,7 @@ public class LeAudioServiceTest { mService.messageFromNative(groupStatusChangedEvent); } private void injectAudioConfChanged(int groupId, Integer availableContexts) { int direction = 1; private void injectAudioConfChanged(int groupId, Integer availableContexts, int direction) { int snkAudioLocation = 3; int srcAudioLocation = 4; int eventType = LeAudioStackEvent.EVENT_TYPE_AUDIO_CONF_CHANGED; Loading @@ -1109,7 +1108,7 @@ public class LeAudioServiceTest { doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class)); connectTestDevice(mSingleDevice, testGroupId); injectAudioConfChanged(testGroupId, BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL); BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL, 3); injectGroupStatusChange(testGroupId, BluetoothLeAudio.GROUP_STATUS_ACTIVE); String action = BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED; Loading @@ -1131,7 +1130,7 @@ public class LeAudioServiceTest { String action = BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED; Integer contexts = BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL; injectAudioConfChanged(testGroupId, contexts); injectAudioConfChanged(testGroupId, contexts, 3); Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice)); assertThat(intent).isNull(); Loading @@ -1146,7 +1145,7 @@ public class LeAudioServiceTest { String action = BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED; injectAudioConfChanged(testGroupId, 0); injectAudioConfChanged(testGroupId, 0, 3); Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice)); assertThat(intent).isNull(); } Loading Loading @@ -1192,7 +1191,7 @@ public class LeAudioServiceTest { connectTestDevice(mSingleDevice, testGroupId); injectAudioConfChanged(testGroupId, BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL); BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL, 3); sendEventAndVerifyIntentForGroupStatusChanged(testGroupId, LeAudioStackEvent.GROUP_STATUS_ACTIVE); sendEventAndVerifyIntentForGroupStatusChanged(testGroupId, LeAudioStackEvent.GROUP_STATUS_INACTIVE); Loading Loading @@ -1285,7 +1284,7 @@ public class LeAudioServiceTest { @Test public void testLeadGroupDeviceDisconnects() { int groupId = 1; int direction = 1; int direction = 2; int snkAudioLocation = 3; int srcAudioLocation = 4; int availableContexts = 5; Loading Loading @@ -1350,7 +1349,7 @@ public class LeAudioServiceTest { @Test public void testLeadGroupDeviceReconnects() { int groupId = 1; int direction = 1; int direction = 2; int snkAudioLocation = 3; int srcAudioLocation = 4; int availableContexts = 5; Loading Loading @@ -1417,6 +1416,7 @@ public class LeAudioServiceTest { public void testVolumeCache() { int groupId = 1; int volume = 100; int direction = 2; int availableContexts = 4; doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class)); Loading @@ -1429,7 +1429,7 @@ public class LeAudioServiceTest { ArgumentCaptor.forClass(BluetoothProfileConnectionInfo.class); //Add location support. injectAudioConfChanged(groupId, availableContexts); injectAudioConfChanged(groupId, availableContexts, direction); doReturn(-1).when(mVolumeControlService).getAudioDeviceGroupVolume(groupId); //Set group and device as active. Loading system/bta/vc/vc.cc +17 −6 Original line number Diff line number Diff line Loading @@ -753,7 +753,7 @@ class VolumeControlImpl : public VolumeControl { devices_control_point_helper(op->devices_, op->opcode_, &(op->arguments_)); } void PrepareVolumeControlOperation(std::vector<RawAddress>& devices, void PrepareVolumeControlOperation(std::vector<RawAddress> devices, int group_id, bool is_autonomous, uint8_t opcode, std::vector<uint8_t>& arguments) { Loading @@ -764,11 +764,22 @@ class VolumeControlImpl : public VolumeControl { arguments.size()); if (std::find_if(ongoing_operations_.begin(), ongoing_operations_.end(), [opcode, &arguments](const VolumeOperation& op) { return (op.opcode_ == opcode) && std::equal(op.arguments_.begin(), op.arguments_.end(), arguments.begin()); [opcode, &devices, &arguments](const VolumeOperation& op) { if (op.opcode_ != opcode) return false; if (!std::equal(op.arguments_.begin(), op.arguments_.end(), arguments.begin())) return false; // Filter out all devices which have the exact operation // already scheduled devices.erase( std::remove_if(devices.begin(), devices.end(), [&op](auto d) { return find(op.devices_.begin(), op.devices_.end(), d) != op.devices_.end(); }), devices.end()); return devices.empty(); }) == ongoing_operations_.end()) { ongoing_operations_.emplace_back(latest_operation_id_++, group_id, is_autonomous, opcode, arguments, Loading system/bta/vc/vc_test.cc +17 −0 Original line number Diff line number Diff line Loading @@ -1087,6 +1087,23 @@ TEST_F(VolumeControlCsis, test_set_volume) { std::vector<uint8_t> value({0x03, 0x01, 0x02}); GetNotificationEvent(conn_id_1, test_address_1, 0x0021, value); GetNotificationEvent(conn_id_2, test_address_2, 0x0021, value); /* Verify exactly one operation with this exact value is queued for each * device */ EXPECT_CALL(gatt_queue, WriteCharacteristic(conn_id_1, 0x0024, _, GATT_WRITE, _, _)) .Times(1); EXPECT_CALL(gatt_queue, WriteCharacteristic(conn_id_2, 0x0024, _, GATT_WRITE, _, _)) .Times(1); VolumeControl::Get()->SetVolume(test_address_1, 20); VolumeControl::Get()->SetVolume(test_address_2, 20); VolumeControl::Get()->SetVolume(test_address_1, 20); VolumeControl::Get()->SetVolume(test_address_2, 20); std::vector<uint8_t> value2({20, 0x00, 0x03}); GetNotificationEvent(conn_id_1, test_address_1, 0x0021, value2); GetNotificationEvent(conn_id_2, test_address_2, 0x0021, value2); } TEST_F(VolumeControlCsis, test_set_volume_device_not_ready) { Loading Loading
android/app/tests/unit/src/com/android/bluetooth/le_audio/LeAudioServiceTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -1034,7 +1034,7 @@ public class LeAudioServiceTest { @Test public void testGetActiveDevices() { int groupId = 1; int direction = 1; int direction = 2; int snkAudioLocation = 3; int srcAudioLocation = 4; int availableContexts = 5; Loading Loading @@ -1085,8 +1085,7 @@ public class LeAudioServiceTest { mService.messageFromNative(groupStatusChangedEvent); } private void injectAudioConfChanged(int groupId, Integer availableContexts) { int direction = 1; private void injectAudioConfChanged(int groupId, Integer availableContexts, int direction) { int snkAudioLocation = 3; int srcAudioLocation = 4; int eventType = LeAudioStackEvent.EVENT_TYPE_AUDIO_CONF_CHANGED; Loading @@ -1109,7 +1108,7 @@ public class LeAudioServiceTest { doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class)); connectTestDevice(mSingleDevice, testGroupId); injectAudioConfChanged(testGroupId, BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL); BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL, 3); injectGroupStatusChange(testGroupId, BluetoothLeAudio.GROUP_STATUS_ACTIVE); String action = BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED; Loading @@ -1131,7 +1130,7 @@ public class LeAudioServiceTest { String action = BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED; Integer contexts = BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL; injectAudioConfChanged(testGroupId, contexts); injectAudioConfChanged(testGroupId, contexts, 3); Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice)); assertThat(intent).isNull(); Loading @@ -1146,7 +1145,7 @@ public class LeAudioServiceTest { String action = BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED; injectAudioConfChanged(testGroupId, 0); injectAudioConfChanged(testGroupId, 0, 3); Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice)); assertThat(intent).isNull(); } Loading Loading @@ -1192,7 +1191,7 @@ public class LeAudioServiceTest { connectTestDevice(mSingleDevice, testGroupId); injectAudioConfChanged(testGroupId, BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL); BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL, 3); sendEventAndVerifyIntentForGroupStatusChanged(testGroupId, LeAudioStackEvent.GROUP_STATUS_ACTIVE); sendEventAndVerifyIntentForGroupStatusChanged(testGroupId, LeAudioStackEvent.GROUP_STATUS_INACTIVE); Loading Loading @@ -1285,7 +1284,7 @@ public class LeAudioServiceTest { @Test public void testLeadGroupDeviceDisconnects() { int groupId = 1; int direction = 1; int direction = 2; int snkAudioLocation = 3; int srcAudioLocation = 4; int availableContexts = 5; Loading Loading @@ -1350,7 +1349,7 @@ public class LeAudioServiceTest { @Test public void testLeadGroupDeviceReconnects() { int groupId = 1; int direction = 1; int direction = 2; int snkAudioLocation = 3; int srcAudioLocation = 4; int availableContexts = 5; Loading Loading @@ -1417,6 +1416,7 @@ public class LeAudioServiceTest { public void testVolumeCache() { int groupId = 1; int volume = 100; int direction = 2; int availableContexts = 4; doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class)); Loading @@ -1429,7 +1429,7 @@ public class LeAudioServiceTest { ArgumentCaptor.forClass(BluetoothProfileConnectionInfo.class); //Add location support. injectAudioConfChanged(groupId, availableContexts); injectAudioConfChanged(groupId, availableContexts, direction); doReturn(-1).when(mVolumeControlService).getAudioDeviceGroupVolume(groupId); //Set group and device as active. Loading
system/bta/vc/vc.cc +17 −6 Original line number Diff line number Diff line Loading @@ -753,7 +753,7 @@ class VolumeControlImpl : public VolumeControl { devices_control_point_helper(op->devices_, op->opcode_, &(op->arguments_)); } void PrepareVolumeControlOperation(std::vector<RawAddress>& devices, void PrepareVolumeControlOperation(std::vector<RawAddress> devices, int group_id, bool is_autonomous, uint8_t opcode, std::vector<uint8_t>& arguments) { Loading @@ -764,11 +764,22 @@ class VolumeControlImpl : public VolumeControl { arguments.size()); if (std::find_if(ongoing_operations_.begin(), ongoing_operations_.end(), [opcode, &arguments](const VolumeOperation& op) { return (op.opcode_ == opcode) && std::equal(op.arguments_.begin(), op.arguments_.end(), arguments.begin()); [opcode, &devices, &arguments](const VolumeOperation& op) { if (op.opcode_ != opcode) return false; if (!std::equal(op.arguments_.begin(), op.arguments_.end(), arguments.begin())) return false; // Filter out all devices which have the exact operation // already scheduled devices.erase( std::remove_if(devices.begin(), devices.end(), [&op](auto d) { return find(op.devices_.begin(), op.devices_.end(), d) != op.devices_.end(); }), devices.end()); return devices.empty(); }) == ongoing_operations_.end()) { ongoing_operations_.emplace_back(latest_operation_id_++, group_id, is_autonomous, opcode, arguments, Loading
system/bta/vc/vc_test.cc +17 −0 Original line number Diff line number Diff line Loading @@ -1087,6 +1087,23 @@ TEST_F(VolumeControlCsis, test_set_volume) { std::vector<uint8_t> value({0x03, 0x01, 0x02}); GetNotificationEvent(conn_id_1, test_address_1, 0x0021, value); GetNotificationEvent(conn_id_2, test_address_2, 0x0021, value); /* Verify exactly one operation with this exact value is queued for each * device */ EXPECT_CALL(gatt_queue, WriteCharacteristic(conn_id_1, 0x0024, _, GATT_WRITE, _, _)) .Times(1); EXPECT_CALL(gatt_queue, WriteCharacteristic(conn_id_2, 0x0024, _, GATT_WRITE, _, _)) .Times(1); VolumeControl::Get()->SetVolume(test_address_1, 20); VolumeControl::Get()->SetVolume(test_address_2, 20); VolumeControl::Get()->SetVolume(test_address_1, 20); VolumeControl::Get()->SetVolume(test_address_2, 20); std::vector<uint8_t> value2({20, 0x00, 0x03}); GetNotificationEvent(conn_id_1, test_address_1, 0x0021, value2); GetNotificationEvent(conn_id_2, test_address_2, 0x0021, value2); } TEST_F(VolumeControlCsis, test_set_volume_device_not_ready) { Loading