Roll forward to cl/328359974

Change-Id: Id081e9ee4e78fc51e01992c1f2db3b9e32b3e776
This commit is contained in:
Alexey Polyudov
2020-08-25 11:37:16 -07:00
parent ae277748ce
commit abc1cbf267
114 changed files with 5241 additions and 1245 deletions
+11 -6
View File
@@ -48,9 +48,7 @@ bool BluetoothSocket::IsClosed() const {
return closed_;
}
bool BluetoothSocket::IsConnectedLocked() const {
return input_ != nullptr;
}
bool BluetoothSocket::IsConnectedLocked() const { return input_ != nullptr; }
InputStream& BluetoothSocket::GetInputStream() {
auto* remote_socket = GetRemoteSocket();
@@ -177,13 +175,13 @@ Exception BluetoothServerSocket::DoClose() {
BluetoothClassicMedium::BluetoothClassicMedium(api::BluetoothAdapter& adapter)
// TODO(apolyudov): implement and use downcast<> with static assertions.
: adapter_(static_cast<BluetoothAdapter*>(&adapter)) {
adapter_->SetMedium(this);
adapter_->SetBluetoothClassicMedium(this);
auto& env = MediumEnvironment::Instance();
env.RegisterBluetoothMedium(*this, GetAdapter());
}
BluetoothClassicMedium::~BluetoothClassicMedium() {
adapter_->SetMedium(nullptr);
adapter_->SetBluetoothClassicMedium(nullptr);
auto& env = MediumEnvironment::Instance();
env.UnregisterBluetoothMedium(*this);
}
@@ -207,7 +205,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
this, &GetAdapter(), &GetAdapter().GetDevice());
// First, find an instance of remote medium, that exposed this device.
auto& adapter = static_cast<BluetoothDevice&>(remote_device).GetAdapter();
auto* medium = static_cast<BluetoothClassicMedium*>(adapter.GetMedium());
auto* medium =
static_cast<BluetoothClassicMedium*>(adapter.GetBluetoothClassicMedium());
if (!medium) return {}; // Adapter is not bound to medium. Bail out.
@@ -255,6 +254,12 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
return socket;
}
api::BluetoothDevice* BluetoothClassicMedium::FindRemoteDevice(
const std::string& mac_address) {
auto& env = MediumEnvironment::Instance();
return env.FindBluetoothDevice(mac_address);
}
} // namespace g3
} // namespace nearby
} // namespace location