mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Roll forward to cl/333580336
Signed-off-by: Josh Nohle <nohle@google.com>
This commit is contained in:
@@ -106,6 +106,7 @@ bool Ble::IsAdvertisingLocked(const std::string& service_id) {
|
||||
}
|
||||
|
||||
bool Ble::StartScanning(const std::string& service_id,
|
||||
const std::string& fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback callback) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
@@ -133,7 +134,8 @@ bool Ble::StartScanning(const std::string& service_id,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!medium_.StartScanning(service_id, callback)) {
|
||||
if (!medium_.StartScanning(service_id, fast_advertisement_service_uuid,
|
||||
callback)) {
|
||||
NEARBY_LOGS(INFO) << "Failed to start scan of BLE services.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class Ble {
|
||||
// range through a callback. Returns true, if scanning mode was enabled,
|
||||
// false otherwise.
|
||||
bool StartScanning(const std::string& service_id,
|
||||
const std::string& fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback callback)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace {
|
||||
constexpr absl::Duration kWaitDuration = absl::Milliseconds(1000);
|
||||
constexpr absl::string_view kServiceID{"com.google.location.nearby.apps.test"};
|
||||
constexpr absl::string_view kAdvertisementString{"\x0a\x0b\x0c\x0d"};
|
||||
constexpr absl::string_view kFastAdvertisementServiceUuid{"\xff\xfe"};
|
||||
constexpr absl::string_view kFastAdvertisementServiceUuid{"\xf3\xfe"};
|
||||
|
||||
class BleTest : public ::testing::Test {
|
||||
protected:
|
||||
@@ -61,6 +61,7 @@ TEST_F(BleTest, CanStartAdvertising) {
|
||||
|
||||
ble_b.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
@@ -95,6 +96,7 @@ TEST_F(BleTest, CanStartDiscovery) {
|
||||
|
||||
EXPECT_TRUE(ble_a.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&accept_latch](
|
||||
@@ -139,6 +141,7 @@ TEST_F(BleTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
BlePeripheral discovered_peripheral;
|
||||
ble_b.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch, &discovered_peripheral](
|
||||
|
||||
@@ -368,10 +368,10 @@ BluetoothSocket BluetoothClassic::Connect(BluetoothDevice& bluetooth_device,
|
||||
return socket;
|
||||
}
|
||||
|
||||
BluetoothDevice BluetoothClassic::FindRemoteDevice(
|
||||
BluetoothDevice BluetoothClassic::GetRemoteDevice(
|
||||
const std::string& mac_address) {
|
||||
MutexLock lock(&mutex_);
|
||||
return medium_.FindRemoteDevice(mac_address);
|
||||
return medium_.GetRemoteDevice(mac_address);
|
||||
}
|
||||
|
||||
std::string BluetoothClassic::GetMacAddress() const {
|
||||
|
||||
@@ -102,7 +102,7 @@ class BluetoothClassic {
|
||||
|
||||
std::string GetMacAddress() const ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
BluetoothDevice FindRemoteDevice(const std::string& mac_address)
|
||||
BluetoothDevice GetRemoteDevice(const std::string& mac_address)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
private:
|
||||
|
||||
@@ -233,8 +233,8 @@ bool ConnectionFlow::InitPeerConnection(WebRtcMedium& webrtc_medium) {
|
||||
Future<bool> success_future;
|
||||
webrtc_medium.CreatePeerConnection(
|
||||
&peer_connection_observer_,
|
||||
[this, &success_future](
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection) {
|
||||
[this, success_future](rtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
peer_connection) mutable {
|
||||
if (!peer_connection) {
|
||||
success_future.Set(false);
|
||||
return;
|
||||
@@ -329,8 +329,7 @@ bool ConnectionFlow::CloseLocked() {
|
||||
state_ = State::kEnded;
|
||||
|
||||
data_channel_future_.SetException({Exception::kInterrupted});
|
||||
if (peer_connection_)
|
||||
peer_connection_->Close();
|
||||
if (peer_connection_) peer_connection_->Close();
|
||||
|
||||
data_channel_observer_.reset();
|
||||
NEARBY_LOG(INFO, "Closed WebRTC connection.");
|
||||
|
||||
Reference in New Issue
Block a user