csis: Add support for getting list of devices per group
This is needed by native modules which are using CSIS groups for some actions e.g. VC
Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: atest --host bluetooth_csis_test
Change-Id: I328cf99f8899760733e4a0ee116c8e5b3dba1ba8
diff --git a/system/bta/csis/csis_client.cc b/system/bta/csis/csis_client.cc
index d7202be..42ad5ed 100644
--- a/system/bta/csis/csis_client.cc
+++ b/system/bta/csis/csis_client.cc
@@ -400,6 +400,21 @@
if (cb) std::move(cb).Run(group_id, lock, status);
}
+ std::vector<RawAddress> GetDeviceList(int group_id) override {
+ std::vector<RawAddress> result;
+ auto csis_group = FindCsisGroup(group_id);
+
+ if (!csis_group || csis_group->IsEmpty()) return result;
+
+ auto csis_device = csis_group->GetFirstDevice();
+ while (csis_device) {
+ result.push_back(csis_device->addr);
+ csis_device = csis_group->GetNextDevice(csis_device);
+ }
+
+ return result;
+ }
+
void LockGroup(int group_id, bool lock, CsisLockCb cb) override {
if (lock)
DLOG(INFO) << __func__ << " Locking group: " << int(group_id);
diff --git a/system/bta/include/bta_csis_api.h b/system/bta/include/bta_csis_api.h
index d3ede74..fe864f5 100644
--- a/system/bta/include/bta_csis_api.h
+++ b/system/bta/include/bta_csis_api.h
@@ -46,6 +46,7 @@
const RawAddress& addr,
bluetooth::Uuid uuid = bluetooth::groups::kGenericContextUuid) = 0;
virtual void LockGroup(int group_id, bool lock, CsisLockCb cb) = 0;
+ virtual std::vector<RawAddress> GetDeviceList(int group_id) = 0;
};
} // namespace csis
} // namespace bluetooth
diff --git a/system/bta/test/common/mock_csis_client.h b/system/bta/test/common/mock_csis_client.h
index 5a6b614..33c106a 100644
--- a/system/bta/test/common/mock_csis_client.h
+++ b/system/bta/test/common/mock_csis_client.h
@@ -31,6 +31,8 @@
MOCK_METHOD((void), LockGroup,
(const int group_id, bool lock, bluetooth::csis::CsisLockCb cb),
(override));
+ MOCK_METHOD((std::vector<RawAddress>), GetDeviceList, (int group_id),
+ (override));
/* Called from static methods */
MOCK_METHOD((void), Initialize,