Loading system/gd/hci/device_database.cc +6 −14 Original line number Diff line number Diff line Loading @@ -30,20 +30,16 @@ using namespace bluetooth::hci; std::shared_ptr<ClassicDevice> DeviceDatabase::CreateClassicDevice(Address address) { ClassicDevice device(address); const std::string uuid = device.GetUuid(); if (AddDeviceToMap(std::move(device))) { AddDeviceToMap(std::move(device)); return GetClassicDevice(uuid); } return std::shared_ptr<ClassicDevice>(); } std::shared_ptr<LeDevice> DeviceDatabase::CreateLeDevice(Address address) { LeDevice device(address); const std::string uuid = device.GetUuid(); if (AddDeviceToMap(std::move(device))) { AddDeviceToMap(std::move(device)); return GetLeDevice(uuid); } return std::shared_ptr<LeDevice>(); } std::shared_ptr<DualDevice> DeviceDatabase::CreateDualDevice(Address address) { auto classic = CreateClassicDevice(address); Loading @@ -51,10 +47,9 @@ std::shared_ptr<DualDevice> DeviceDatabase::CreateDualDevice(Address address) { if (classic && le) { DualDevice device(address, classic, le); std::string uuid = device.GetUuid(); if (AddDeviceToMap(std::move(device))) { AddDeviceToMap(std::move(device)); return GetDualDevice(uuid); } } LOG_WARN("Attempting to instert a DUAL device that already exists!"); return std::shared_ptr<DualDevice>(); } Loading Loading @@ -189,7 +184,6 @@ bool DeviceDatabase::AddDeviceToMap(ClassicDevice&& device) { auto it = classic_device_map_.find(device.GetUuid()); // If we have a record with the same key if (it != classic_device_map_.end()) { LOG_ERROR("Attempt to re-insert classic device '%s' object with same UUID", uuid.c_str()); // We don't want to insert and overwrite return false; } Loading Loading @@ -217,7 +211,6 @@ bool DeviceDatabase::AddDeviceToMap(LeDevice&& device) { auto it = le_device_map_.find(device.GetUuid()); // If we have a record with the same key if (it != le_device_map_.end()) { LOG_ERROR("Attempt to re-insert LE device '%s' object with same UUID", uuid.c_str()); // We don't want to insert and overwrite return false; } Loading @@ -244,7 +237,6 @@ bool DeviceDatabase::AddDeviceToMap(DualDevice&& device) { auto it = dual_device_map_.find(device.GetUuid()); // If we have a record with the same key if (it != dual_device_map_.end()) { LOG_ERROR("Attempt to re-insert dual device '%s' object with same UUID", uuid.c_str()); // We don't want to insert and overwrite return false; } Loading system/gd/hci/device_database_test.cc +4 −3 Original line number Diff line number Diff line Loading @@ -61,12 +61,13 @@ TEST_F(DeviceDatabaseTest, create_dual_device) { ASSERT_EQ(address_str, dual_device->GetUuid()); } // Shouldn't fail when creating twice. Should just get back a s_ptr the same device TEST_F(DeviceDatabaseTest, create_classic_device_twice) { auto classic_device = device_database_.CreateClassicDevice(address); ASSERT_TRUE(classic_device); ASSERT_EQ(CLASSIC, classic_device->GetDeviceType()); ASSERT_EQ(address_str, classic_device->GetUuid()); ASSERT_FALSE(device_database_.CreateClassicDevice(address)); ASSERT_TRUE(device_database_.CreateClassicDevice(address)); } TEST_F(DeviceDatabaseTest, create_le_device_twice) { Loading @@ -74,7 +75,7 @@ TEST_F(DeviceDatabaseTest, create_le_device_twice) { ASSERT_TRUE(le_device); ASSERT_EQ(LE, le_device->GetDeviceType()); ASSERT_EQ(address_str, le_device->GetUuid()); ASSERT_FALSE(device_database_.CreateLeDevice(address)); ASSERT_TRUE(device_database_.CreateLeDevice(address)); } TEST_F(DeviceDatabaseTest, create_dual_device_twice) { Loading @@ -93,7 +94,7 @@ TEST_F(DeviceDatabaseTest, create_dual_device_twice) { ASSERT_EQ(DUAL, dual_device->GetLeDevice()->GetDeviceType()); ASSERT_EQ(address_str, dual_device->GetLeDevice()->GetUuid()); ASSERT_FALSE(device_database_.CreateDualDevice(address)); ASSERT_TRUE(device_database_.CreateDualDevice(address)); } TEST_F(DeviceDatabaseTest, remove_device) { Loading system/gd/hci/le_device.h +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ namespace bluetooth::hci { /** * TODO(optedoblivion): Build out AddressType getter/setter */ enum AddressType {}; // enum AddressType {}; /** * A device representing a LE device. Loading Loading
system/gd/hci/device_database.cc +6 −14 Original line number Diff line number Diff line Loading @@ -30,20 +30,16 @@ using namespace bluetooth::hci; std::shared_ptr<ClassicDevice> DeviceDatabase::CreateClassicDevice(Address address) { ClassicDevice device(address); const std::string uuid = device.GetUuid(); if (AddDeviceToMap(std::move(device))) { AddDeviceToMap(std::move(device)); return GetClassicDevice(uuid); } return std::shared_ptr<ClassicDevice>(); } std::shared_ptr<LeDevice> DeviceDatabase::CreateLeDevice(Address address) { LeDevice device(address); const std::string uuid = device.GetUuid(); if (AddDeviceToMap(std::move(device))) { AddDeviceToMap(std::move(device)); return GetLeDevice(uuid); } return std::shared_ptr<LeDevice>(); } std::shared_ptr<DualDevice> DeviceDatabase::CreateDualDevice(Address address) { auto classic = CreateClassicDevice(address); Loading @@ -51,10 +47,9 @@ std::shared_ptr<DualDevice> DeviceDatabase::CreateDualDevice(Address address) { if (classic && le) { DualDevice device(address, classic, le); std::string uuid = device.GetUuid(); if (AddDeviceToMap(std::move(device))) { AddDeviceToMap(std::move(device)); return GetDualDevice(uuid); } } LOG_WARN("Attempting to instert a DUAL device that already exists!"); return std::shared_ptr<DualDevice>(); } Loading Loading @@ -189,7 +184,6 @@ bool DeviceDatabase::AddDeviceToMap(ClassicDevice&& device) { auto it = classic_device_map_.find(device.GetUuid()); // If we have a record with the same key if (it != classic_device_map_.end()) { LOG_ERROR("Attempt to re-insert classic device '%s' object with same UUID", uuid.c_str()); // We don't want to insert and overwrite return false; } Loading Loading @@ -217,7 +211,6 @@ bool DeviceDatabase::AddDeviceToMap(LeDevice&& device) { auto it = le_device_map_.find(device.GetUuid()); // If we have a record with the same key if (it != le_device_map_.end()) { LOG_ERROR("Attempt to re-insert LE device '%s' object with same UUID", uuid.c_str()); // We don't want to insert and overwrite return false; } Loading @@ -244,7 +237,6 @@ bool DeviceDatabase::AddDeviceToMap(DualDevice&& device) { auto it = dual_device_map_.find(device.GetUuid()); // If we have a record with the same key if (it != dual_device_map_.end()) { LOG_ERROR("Attempt to re-insert dual device '%s' object with same UUID", uuid.c_str()); // We don't want to insert and overwrite return false; } Loading
system/gd/hci/device_database_test.cc +4 −3 Original line number Diff line number Diff line Loading @@ -61,12 +61,13 @@ TEST_F(DeviceDatabaseTest, create_dual_device) { ASSERT_EQ(address_str, dual_device->GetUuid()); } // Shouldn't fail when creating twice. Should just get back a s_ptr the same device TEST_F(DeviceDatabaseTest, create_classic_device_twice) { auto classic_device = device_database_.CreateClassicDevice(address); ASSERT_TRUE(classic_device); ASSERT_EQ(CLASSIC, classic_device->GetDeviceType()); ASSERT_EQ(address_str, classic_device->GetUuid()); ASSERT_FALSE(device_database_.CreateClassicDevice(address)); ASSERT_TRUE(device_database_.CreateClassicDevice(address)); } TEST_F(DeviceDatabaseTest, create_le_device_twice) { Loading @@ -74,7 +75,7 @@ TEST_F(DeviceDatabaseTest, create_le_device_twice) { ASSERT_TRUE(le_device); ASSERT_EQ(LE, le_device->GetDeviceType()); ASSERT_EQ(address_str, le_device->GetUuid()); ASSERT_FALSE(device_database_.CreateLeDevice(address)); ASSERT_TRUE(device_database_.CreateLeDevice(address)); } TEST_F(DeviceDatabaseTest, create_dual_device_twice) { Loading @@ -93,7 +94,7 @@ TEST_F(DeviceDatabaseTest, create_dual_device_twice) { ASSERT_EQ(DUAL, dual_device->GetLeDevice()->GetDeviceType()); ASSERT_EQ(address_str, dual_device->GetLeDevice()->GetUuid()); ASSERT_FALSE(device_database_.CreateDualDevice(address)); ASSERT_TRUE(device_database_.CreateDualDevice(address)); } TEST_F(DeviceDatabaseTest, remove_device) { Loading
system/gd/hci/le_device.h +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ namespace bluetooth::hci { /** * TODO(optedoblivion): Build out AddressType getter/setter */ enum AddressType {}; // enum AddressType {}; /** * A device representing a LE device. Loading