Initial header files showing class dependency and ownership.

No detailed function signatures nor impl included yet.

PiperOrigin-RevId: 460300058
This commit is contained in:
hais
2022-07-11 14:26:26 -07:00
committed by Copybara-Service
parent 1a9e4a2aff
commit b6f817274e
18 changed files with 767 additions and 0 deletions
+3
View File
@@ -30,6 +30,7 @@ cc_library(
"bluetooth_utils.h",
"byte_array.h",
"callable.h",
"credential.h",
"exception.h",
"feature_flags.h",
"input_stream.h",
@@ -343,6 +344,7 @@ cc_library(
"ble_v2.h",
"bluetooth_adapter.h",
"bluetooth_classic.h",
"credential_storage.h",
"wifi.h",
"wifi_hotspot.h",
"wifi_lan.h",
@@ -356,6 +358,7 @@ cc_library(
"//internal/analytics:__subpackages__",
"//internal/platform:__pkg__",
"//internal/platform/implementation:__subpackages__",
"//third_party/nearby/presence:__subpackages__",
],
deps = [
":logging",
+131
View File
@@ -0,0 +1,131 @@
// Copyright 2020 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_CREDENTIAL_H_
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CREDENTIAL_H_
#include <set>
#include <string>
#include <vector>
namespace location {
namespace nearby {
enum class TrustType {
kUnspecified = 0,
// The same user itself.
kPrivate = 1,
// The user selects the contact from its contact list.
kTrusted = 2,
// For offline credentials and without dependence on Gaia account
kProvisioned = 3,
// For offline public identities and without dependence on Gaia account
kPublic = 4,
};
enum class DeviceType {
kUnspecified = 0,
kPhone = 1,
kTablet = 2,
kDisplay = 3,
kLaptop = 4,
kTV = 5,
kWatch = 6,
};
struct DeviceMetadata {
// Stable device identifier that does not rotate for a few months.
std::string stable_device_id;
// The account name which created the certificate.
std::string account_name;
// The name of the local device when the certificate is created.
std::string device_name;
// The icon url of the user whose device created the certificate.
std::string icon_url;
// The Bluetooth MAC address of the device which created the certificate.
std::string bluetooth_mac_address;
DeviceType device_type;
};
struct PrivateCredential {
TrustType trust_type;
// The unique id of (and hashed based on) a pair of secret
// key (PrivateCredential.verification_key) and X509Certificate's public
// key (PublicCredential.verification_key).
std::vector<uint8_t> secret_id;
// The aes key to encrypt personal fields in public certificates.
// A bytes representation of a Secret Key owned by contact, to decrypt the
// encrypted DeviceMetadata bytes stored within the advertisement.
std::vector<uint8_t> authenticity_key;
// Bytes representation of a public key of X509Certificate, used in
// handshake during contact verification phase.
std::vector<uint8_t> verification_key;
// The time in millis from epoch when this credential becomes effective.
int start_time;
// The time in millis from epoch when this credential expires.
int end_time;
// The set of 2-byte salts already used to encrypt the metadata key.
std::set<std::vector<uint8_t>> consumed_salts;
// The aes key to encrypt DeviceMetadata in public credential.
std::vector<uint8_t> metadata_encryption_key;
DeviceMetadata device_metadata;
};
struct PublicCredential {
TrustType trust_type;
// The unique id of (and hashed based on) a pair of secret
// key (PrivateCredential.verification_key) and X509Certificate's public
// key (PublicCredential.verification_key).
std::vector<uint8_t> secret_id;
// Bytes representation of a Secret Key owned by contact, to decrypt the
// metadata_key stored within the advertisement.
std::vector<uint8_t> authenticity_key;
// Bytes representation of a public key of X509Certificate, used in
// handshake during contact verification phase.
std::vector<uint8_t> verification_key;
// The time in millis from epoch when this credential becomes effective.
int start_time;
// The time in millis from epoch when this credential expires.
int end_time;
// The encrypted DeviceMetadata in bytes, contains personal information of the
// device/user who created this certificate. Needs to be decrypted into bytes,
// and converted back to DeviceMetadata instance to access fields.
std::vector<uint8_t> encrypted_metadata_bytes;
// The tag for verifying metadata_encryption_key.
std::vector<uint8_t> metadata_encryption_key_tag;
};
} // namespace nearby
} // namespace location
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CREDENTIAL_H_
+39
View File
@@ -0,0 +1,39 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_CREDENTIAL_STORAGE_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_CREDENTIAL_STORAGE_H_
#include "internal/platform/implementation/credential_storage.h"
namespace location {
namespace nearby {
/*
* The instance of CredentialStorage is owned by {@code CredentialManager}.
* It's a wrapper on top of implementation/credential_storage.h to providing
* credential storage operations for Nearby logic layer to invoke.
*/
class CredentialStorage {
public:
CredentialStorage() = default;
~CredentialStorage() = default;
private:
api::CredentialStorage credential_storage_;
};
} // namespace nearby
} // namespace location
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_CREDENTIAL_STORAGE_H_
+1
View File
@@ -57,6 +57,7 @@ cc_library(
"ble_v2.h",
"bluetooth_adapter.h",
"bluetooth_classic.h",
"credential_storage.h",
"server_sync.h",
"wifi.h",
"wifi_hotspot.h",
@@ -0,0 +1,89 @@
// Copyright 2020 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_IMPLEMENTATION_CREDENTIAL_STORAGE_H_
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_CREDENTIAL_STORAGE_H_
#include <functional>
#include <set>
#include <string>
#include <vector>
#include "internal/platform/credential.h"
#include "internal/platform/exception.h"
namespace location {
namespace nearby {
namespace api {
enum class CredentialOperationStatus {
kFailed = 0,
kSucceeded = 1,
};
struct CredentialSelector {
std::string account_name;
TrustType trust_type;
};
struct SaveCredentialCallback {
std::function<void(CredentialOperationStatus)> credentials_saved_cb;
};
struct GetPrivateCredentialCallback {
std::function<void(ExceptionOr<std::vector<PrivateCredential>>)>
credentials_fetched_cb;
};
struct GetPublicCredentialCallback {
std::function<void(ExceptionOr<std::vector<PublicCredential>>)>
credentials_fetched_cb;
};
/*
* This class specifies the virtual functions for native platforms to implement.
*/
class CredentialStorage {
public:
CredentialStorage() = default;
virtual ~CredentialStorage() = default;
// Used for
// 1. Save/update private creds after (re)generate credentials invoked by
// manager app. (public_credentials will be empty for this case); Or
// 2. Update remote public creds after manager app downloaded a new batch of
// remote public creds and save to local storage. (private_credentials will
// be empty for this case).
// account_name will be used as the key in both options, and both would
// overwrite the previous credentials if there already exists credentials for
// that given account_name.
virtual void SaveCredentials(
std::string account_name,
std::vector<PrivateCredential> private_credentials,
std::vector<PublicCredential> public_credentials,
SaveCredentialCallback callback);
// Used to fetch private creds when broadcasting.
virtual void GetPrivateCredentials(CredentialSelector credential_selector,
GetPrivateCredentialCallback callback);
// Used to fetch remote public creds when scanning.
virtual void GetPublicCredentials(CredentialSelector credential_selector,
GetPublicCredentialCallback callback);
};
} // namespace api
} // namespace nearby
} // namespace location
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_CREDENTIAL_STORAGE_H_
+4
View File
@@ -20,12 +20,14 @@ cc_library(
],
hdrs = [
"presence_client.h",
"presence_service.h",
],
visibility = [
"//third_party/nearby:__subpackages__",
],
deps = [
":types",
"//third_party/nearby/presence/implementation:internal", # build_cleaner: keep
],
)
@@ -146,10 +148,12 @@ cc_test(
size = "small",
srcs = [
"presence_client_test.cc",
"presence_service_test.cc",
],
shard_count = 6,
deps = [
":presence",
"//internal/platform/implementation/g3",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_googletest//:gtest_main",
],
+35
View File
@@ -0,0 +1,35 @@
# Copyright 2020 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.
licenses(["notice"])
cc_library(
name = "internal",
srcs = [],
hdrs = [
"broadcast_manager.h",
"credential_manager.h",
"mock_service_controller.h",
"scan_manager.h",
"service_controller.h",
"service_controller_impl.h",
],
visibility = [
"//third_party/nearby/presence:__subpackages__",
],
deps = [
"//internal/platform:base",
"//internal/platform:comm",
"//third_party/nearby/presence/implementation/mediums",
],
)
@@ -0,0 +1,43 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_BROADCAST_MANAGER_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_BROADCAST_MANAGER_H_
#include "third_party/nearby/presence/implementation/credential_manager.h"
#include "third_party/nearby/presence/implementation/mediums/mediums.h"
namespace nearby {
namespace presence {
/*
* The instance of BroadcastManager is owned by {@code ServiceControllerImpl}.
* Helping service controller to manage broadcast requests and callbacks.
*/
class BroadcastManager {
public:
BroadcastManager(Mediums& mediums, CredentialManager& credential_manager) {
mediums_ = &mediums, credential_manager_ = &credential_manager;
}
~BroadcastManager() = default;
private:
Mediums* mediums_;
CredentialManager* credential_manager_;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_BROADCAST_MANAGER_H_
@@ -0,0 +1,82 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_CREDENTIAL_MANAGER_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_CREDENTIAL_MANAGER_H_
#include <functional>
#include <string>
#include <vector>
#include "internal/platform/credential.h"
#include "internal/platform/credential_storage.h"
namespace nearby {
namespace presence {
struct GenerateCredentialsCallback {
std::function<void(std::vector<location::nearby::PublicCredential>)>
credentials_generated_cb;
};
struct UpdateRemotePublicCredentialsCallback {
std::function<void(location::nearby::api::CredentialOperationStatus)>
credentials_updated_cb;
};
/*
* The instance of CredentialManager is owned by {@code ServiceControllerImpl}.
* Helping service controller to manage local credentials and coordinate with
* downloaded remote credentials.
*/
class CredentialManager {
public:
CredentialManager() = default;
~CredentialManager() = default;
// Used to (re)generate users private and public credentials.
// The generated private credentials will be saved to creds storage.
// The generated public credentials will be returned inside the
// credentials_generated_cb for manager app to upload to web.
// The users own public credentials wont be saved on local credential
// storage.
void GenerateCredentials(
location::nearby::DeviceMetadata device_metadata,
std::vector<location::nearby::TrustType> trust_types,
GenerateCredentialsCallback credentials_generated_cb);
// Update remote public credentials.
void UpdateRemotePublicCredentials(
std::string account_name,
std::vector<location::nearby::PublicCredential> remote_public_creds,
UpdateRemotePublicCredentialsCallback credentials_updated_cb);
// Used to fetch private creds when broadcasting.
void GetPrivateCredentials(
location::nearby::api::CredentialSelector credential_selector,
location::nearby::api::GetPrivateCredentialCallback callback);
// Used to fetch remote public creds when scanning.
void GetPublicCredentials(
location::nearby::api::CredentialSelector credential_selector,
location::nearby::api::GetPublicCredentialCallback callback);
private:
location::nearby::CredentialStorage* credential_storage_;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_CREDENTIAL_MANAGER_H_
+30
View File
@@ -0,0 +1,30 @@
# Copyright 2020 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.
licenses(["notice"])
cc_library(
name = "mediums",
srcs = [],
hdrs = [
"ble.h",
"mediums.h",
],
visibility = [
"//third_party/nearby/presence/implementation:__subpackages__",
],
deps = [
"//internal/platform:base",
"//internal/platform:comm",
],
)
+41
View File
@@ -0,0 +1,41 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_MEDIUMS_BLE_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_BLE_H_
#include "internal/platform/ble_v2.h"
namespace nearby {
namespace presence {
/*
* This Ble class utilizes platform/ble_v2 BleV2Medium, provides ble functions
* for presence logic layer to invoke.
* This class would have states like if ble is available or not, if it's doing
* broadcast/scan.
*/
class Ble {
public:
Ble() = default;
~Ble() = default;
// TODO(hais): add expected function set.
private:
location::nearby::BleV2Medium medium_;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_BLE_H_
+42
View File
@@ -0,0 +1,42 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_MEDIUMS_MEDIUMS_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_MEDIUMS_H_
#include "third_party/nearby/presence/implementation/mediums/ble.h"
namespace nearby {
namespace presence {
/*
* This class owns medium instance like Ble and etc. And the instance of
* this class will be owned in {@code ServiceControllerImpl}.
*/
class Mediums {
public:
Mediums() = default;
~Mediums() = default;
// Returns a handle to the Ble medium.
Ble& GetBle();
private:
Ble ble_;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_MEDIUMS_H_
@@ -0,0 +1,37 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_MOCK_SERVICE_CONTROLLER_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MOCK_SERVICE_CONTROLLER_H_
#include "third_party/nearby/presence/implementation/service_controller.h"
namespace nearby {
namespace presence {
/*
* This class is for unit test, mocking {@code ServiceController} functions.
*/
class MockServiceController : public ServiceController {
public:
MockServiceController() = default;
~MockServiceController() override = default;
private:
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MOCK_SERVICE_CONTROLLER_H_
+43
View File
@@ -0,0 +1,43 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_SCAN_MANAGER_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SCAN_MANAGER_H_
#include "third_party/nearby/presence/implementation/credential_manager.h"
#include "third_party/nearby/presence/implementation/mediums/mediums.h"
namespace nearby {
namespace presence {
/*
* The instance of ScanManager is owned by {@code ServiceControllerImpl}.
* Helping service controller to manage scan requests and callbacks.
*/
class ScanManager {
public:
ScanManager(Mediums& mediums, CredentialManager& credential_manager) {
mediums_ = &mediums, credential_manager_ = &credential_manager;
}
~ScanManager() = default;
private:
Mediums* mediums_;
CredentialManager* credential_manager_;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SCAN_MANAGER_H_
@@ -0,0 +1,34 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_H_
namespace nearby {
namespace presence {
/*
* This class is owned in {@code PresenceService}. It specifies the function
* signatures. {@code ServiceControllerImpl} and {@code MockServiceController}
* inherit this class and provides real implementation and mock impl for tests.
*/
class ServiceController {
public:
virtual ~ServiceController() = default;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_H_
@@ -0,0 +1,42 @@
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_IMPL_H_
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_IMPL_H_
#include "third_party/nearby/presence/implementation/credential_manager.h"
#include "third_party/nearby/presence/implementation/mediums/mediums.h"
#include "third_party/nearby/presence/implementation/service_controller.h"
/*
* This class implements {@code ServiceController} functions. Owns mediums and
* other managers instances.
*/
namespace nearby {
namespace presence {
class ServiceControllerImpl : public ServiceController {
public:
ServiceControllerImpl() = default;
~ServiceControllerImpl() override = default;
private:
Mediums mediums_; // NOLINT: further impl will use it.
CredentialManager credential_manager_; // NOLINT: further impl will use it.
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_IMPL_H_
+42
View File
@@ -0,0 +1,42 @@
// Copyright 2020 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_PRESENCE_PRESENCE_SERVICE_H_
#define THIRD_PARTY_NEARBY_PRESENCE_PRESENCE_SERVICE_H_
#include <memory>
#include "third_party/nearby/presence/implementation/service_controller.h"
namespace nearby {
namespace presence {
/*
* PresenceService hosts presence functions by routing invokes to the unique
* {@code ServiceController}. PresenceService should be initialized once and
* only once in the process that hosting presence functions.
*/
class PresenceService {
public:
PresenceService() = default;
~PresenceService() = default;
private:
std::unique_ptr<ServiceController> service_controller_;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_PRESENCE_SERVICE_H_
+29
View File
@@ -0,0 +1,29 @@
// Copyright 2020 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.
#include "third_party/nearby/presence/presence_service.h"
#include "gtest/gtest.h"
namespace nearby {
namespace presence {
namespace {
TEST(PresenceServiceTest, DefaultConstructorWorks) {
PresenceService presence_service;
}
} // namespace
} // namespace presence
} // namespace nearby