mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fixes HelloConnections that can't discover Pixel device from iPhone for Ble_v2 medium.
PiperOrigin-RevId: 517318035
This commit is contained in:
committed by
Copybara-Service
parent
debe65ce54
commit
94ff506d1e
@@ -15,28 +15,24 @@
|
||||
#include "connections/implementation/base_pcp_handler.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "securegcm/d2d_connection_context_v1.h"
|
||||
#include "securegcm/ukey2_handshake.h"
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "connections/advertising_options.h"
|
||||
#include "connections/connection_options.h"
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "connections/implementation/mediums/utils.h"
|
||||
#include "connections/implementation/offline_frames.h"
|
||||
#include "connections/implementation/proto/offline_wire_formats.pb.h"
|
||||
#include "connections/medium_selector.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "internal/platform/base64_utils.h"
|
||||
#include "internal/platform/bluetooth_utils.h"
|
||||
#include "internal/platform/logging.h"
|
||||
@@ -696,7 +692,12 @@ void BasePcpHandler::StripOutUnavailableMediums(
|
||||
allowed.bluetooth = mediums_->GetBluetoothClassic().IsAvailable();
|
||||
}
|
||||
if (allowed.ble) {
|
||||
allowed.ble = mediums_->GetBle().IsAvailable();
|
||||
if (NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::kEnableBleV2)) {
|
||||
allowed.ble = mediums_->GetBleV2().IsAvailable();
|
||||
} else {
|
||||
allowed.ble = mediums_->GetBle().IsAvailable();
|
||||
}
|
||||
}
|
||||
if (allowed.web_rtc) {
|
||||
allowed.web_rtc = mediums_->GetWebRtc().IsAvailable();
|
||||
@@ -720,7 +721,12 @@ void BasePcpHandler::StripOutUnavailableMediums(
|
||||
allowed.bluetooth = mediums_->GetBluetoothClassic().IsAvailable();
|
||||
}
|
||||
if (allowed.ble) {
|
||||
allowed.ble = mediums_->GetBle().IsAvailable();
|
||||
if (NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::kEnableBleV2)) {
|
||||
allowed.ble = mediums_->GetBleV2().IsAvailable();
|
||||
} else {
|
||||
allowed.ble = mediums_->GetBle().IsAvailable();
|
||||
}
|
||||
}
|
||||
if (allowed.web_rtc) {
|
||||
allowed.web_rtc = mediums_->GetWebRtc().IsAvailable();
|
||||
|
||||
@@ -630,7 +630,7 @@ void BleV2::ProcessFetchGattAdvertisementsRequest(
|
||||
}
|
||||
if (slot_characteristic_uuids.empty()) {
|
||||
// TODO(b/222392304): More test coverage.
|
||||
NEARBY_LOGS(WARNING) << "Edwin GATT client doesn't have characteristics.";
|
||||
NEARBY_LOGS(WARNING) << "GATT client doesn't have characteristics.";
|
||||
advertisement_read_result.RecordLastReadStatus(false);
|
||||
return;
|
||||
}
|
||||
@@ -644,7 +644,7 @@ void BleV2::ProcessFetchGattAdvertisementsRequest(
|
||||
if (!gatt_client->DiscoverServiceAndCharacteristics(
|
||||
mediums::bleutils::kCopresenceServiceUuid, characteristic_uuids)) {
|
||||
// TODO(b/222392304): More test coverage.
|
||||
NEARBY_LOGS(WARNING) << "Edwin GATT client doesn't have characteristics.";
|
||||
NEARBY_LOGS(WARNING) << "GATT client doesn't have characteristics.";
|
||||
advertisement_read_result.RecordLastReadStatus(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class BleMedium : public api::ble_v2::BleMedium {
|
||||
private:
|
||||
GNCMBleCentral *central_;
|
||||
std::string peripheral_id_;
|
||||
absl::flat_hash_map<api::ble_v2::GattCharacteristic, absl::string_view>
|
||||
absl::flat_hash_map<api::ble_v2::GattCharacteristic, const std::string>
|
||||
gatt_characteristic_values_;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "internal/platform/implementation/apple/bluetooth_adapter.h"
|
||||
#include "internal/platform/implementation/apple/utils.h"
|
||||
@@ -574,7 +575,7 @@ absl::optional<std::string> BleMedium::GattClient::ReadCharacteristic(
|
||||
if (it == gatt_characteristic_values_.end()) {
|
||||
return absl::nullopt; // NOLINT
|
||||
}
|
||||
return std::string(it->second);
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool BleMedium::GattClient::WriteCharacteristic(
|
||||
|
||||
Reference in New Issue
Block a user