1 /****************************************************************************** 2 * 3 * Copyright 2019 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 #pragma once 19 20 #include "hci/classic_device.h" 21 #include "hci/device.h" 22 #include "hci/le_device.h" 23 24 namespace bluetooth::hci { 25 26 /** 27 * A device representing a DUAL device. 28 * 29 * <p>This can be a DUAL only. 30 */ 31 class DualDevice : public Device { 32 public: GetClassicDevice()33 std::shared_ptr<Device> GetClassicDevice() { 34 return classic_device_; 35 } 36 GetLeDevice()37 std::shared_ptr<Device> GetLeDevice() { 38 return le_device_; 39 } 40 41 protected: 42 friend class DeviceDatabase; DualDevice(Address address,std::shared_ptr<ClassicDevice> classic_device,std::shared_ptr<LeDevice> le_device)43 DualDevice(Address address, std::shared_ptr<ClassicDevice> classic_device, std::shared_ptr<LeDevice> le_device) 44 : Device(address, DUAL), classic_device_(std::move(classic_device)), le_device_(std::move(le_device)) { 45 classic_device_->SetDeviceType(DUAL); 46 le_device_->SetDeviceType(DUAL); 47 } 48 SetAddress(Address address)49 void SetAddress(Address address) override { 50 Device::SetAddress(address); 51 GetClassicDevice()->SetAddress(address); 52 GetLeDevice()->SetAddress(address); 53 } 54 55 private: 56 std::shared_ptr<ClassicDevice> classic_device_; 57 std::shared_ptr<LeDevice> le_device_; 58 }; 59 60 } // namespace bluetooth::hci 61