mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
Introduce Device Provider interface
PiperOrigin-RevId: 472964206
This commit is contained in:
committed by
Copybara-Service
parent
397964b5da
commit
aaea08204d
@@ -55,6 +55,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"advertising_options.h",
|
||||
"connection_options.h",
|
||||
"device_provider.h",
|
||||
"discovery_options.h",
|
||||
"listeners.h",
|
||||
"medium_selector.h",
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "connections/device_provider.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/service_controller.h"
|
||||
#include "connections/implementation/service_controller_router.h"
|
||||
@@ -267,6 +268,8 @@ class Core {
|
||||
void InitiateBandwidthUpgradeV2(const NearbyDevice& device,
|
||||
ResultCallback callback);
|
||||
|
||||
void RegisterDeviceProvider(const NearbyDeviceProvider& provider);
|
||||
|
||||
private:
|
||||
ClientProxy client_;
|
||||
ServiceControllerRouter* router_ = nullptr;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
|
||||
#define THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "internal/device.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
|
||||
using ::location::nearby::NearbyDevice;
|
||||
|
||||
class NearbyDeviceProvider {
|
||||
virtual ~NearbyDeviceProvider() = default;
|
||||
virtual NearbyDevice* GetLocalDevice() = 0;
|
||||
virtual std::string GetServiceId() = 0;
|
||||
};
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
|
||||
+2
-1
@@ -8,7 +8,8 @@ cc_library(
|
||||
"//presence:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"@com_google_absl//absl/status",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:connection_info",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "internal/platform/connection_info.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
@@ -36,6 +37,7 @@ class NearbyDevice {
|
||||
NearbyDevice& operator=(const NearbyDevice&) = delete;
|
||||
virtual absl::StatusOr<std::string> GetEndpointId() const = 0;
|
||||
virtual std::string GetEndpointInfo() const = 0;
|
||||
virtual absl::Span<ConnectionInfo*> GetConnectionInfos() const = 0;
|
||||
virtual Type GetType() const { return Type::kUnknownDevice; }
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ cc_library(
|
||||
defines = ["NO_WEBRTC"],
|
||||
visibility = [
|
||||
"//connections:__subpackages__",
|
||||
"//internal:__pkg__",
|
||||
"//internal/analytics:__subpackages__",
|
||||
"//internal/platform:__subpackages__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
@@ -141,6 +142,22 @@ cc_library(
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "connection_info",
|
||||
hdrs = [
|
||||
"connection_info.h",
|
||||
],
|
||||
defines = ["NO_WEBRTC"],
|
||||
visibility = [
|
||||
"//connections:__subpackages__",
|
||||
"//internal:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//internal/platform:base",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "error_code_recorder",
|
||||
srcs = [
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CONNECTION_INFO_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CONNECTION_INFO_H_
|
||||
|
||||
#include "internal/platform/byte_array.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
class ConnectionInfo {
|
||||
public:
|
||||
enum class MediumType {
|
||||
kUnknown = 0,
|
||||
kBluetooth = 1,
|
||||
};
|
||||
virtual ~ConnectionInfo() = default;
|
||||
virtual MediumType GetMediumType() const = 0;
|
||||
virtual ByteArray ToBytes() const = 0;
|
||||
};
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CONNECTION_INFO_H_
|
||||
Reference in New Issue
Block a user