mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
Cleanup
PiperOrigin-RevId: 879854458
This commit is contained in:
committed by
Copybara-Service
parent
14ad036bf2
commit
0cc01b476c
+1
-2
@@ -19,8 +19,6 @@ licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "base",
|
||||
srcs = [
|
||||
],
|
||||
hdrs = [
|
||||
"observer_list.h",
|
||||
],
|
||||
@@ -28,6 +26,7 @@ cc_library(
|
||||
"//internal/account:__subpackages__",
|
||||
"//internal/platform:__subpackages__",
|
||||
"//internal/test:__pkg__",
|
||||
"//location/nearby/sharing/lib:__subpackages__",
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
|
||||
@@ -332,7 +332,6 @@ cc_library(
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"//internal/base",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:comm",
|
||||
"//internal/platform/implementation:platform",
|
||||
"//internal/platform/implementation:wifi_utils",
|
||||
|
||||
@@ -17,69 +17,6 @@ load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "auth_status",
|
||||
hdrs = ["auth_status.h"],
|
||||
visibility = [
|
||||
"//internal/auth:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "account_info",
|
||||
hdrs = ["account_info.h"],
|
||||
visibility = [
|
||||
"//internal/auth:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "account_manager",
|
||||
hdrs = ["account_manager.h"],
|
||||
visibility = [
|
||||
"//internal/account:__pkg__",
|
||||
"//internal/platform:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
"//location/nearby/sharing/lib:__subpackages__",
|
||||
"//location/nearby/sharing/sdk/quick_share_server:__pkg__",
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":account_info",
|
||||
":signin_attempt",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "signin_attempt",
|
||||
hdrs = ["signin_attempt.h"],
|
||||
visibility = [
|
||||
"//internal/account:__pkg__",
|
||||
"//internal/auth:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
"//location/nearby/sharing/sdk/quick_share_server:__pkg__",
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":account_info",
|
||||
":auth_status",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "types",
|
||||
hdrs = [
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright 2024 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_ACCOUNT_INFO_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_ACCOUNT_INFO_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace nearby {
|
||||
|
||||
// Describes a Nearby account. The account class will have more properties
|
||||
// and methods in the future based on the new feature added.
|
||||
struct AccountInfo {
|
||||
std::string id; // The unique identify of the account.
|
||||
std::string display_name;
|
||||
std::string family_name;
|
||||
std::string given_name;
|
||||
std::string picture_url;
|
||||
std::string email;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_ACCOUNT_INFO_H_
|
||||
@@ -1,89 +0,0 @@
|
||||
// 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 PLATFORM_API_ACCOUNT_MANAGER_H_
|
||||
#define PLATFORM_API_ACCOUNT_MANAGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_info.h"
|
||||
#include "internal/platform/implementation/signin_attempt.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
// AccountManager manages the accounts are used to access Nearby backend.
|
||||
// In current design, AccountManager only support one active account.
|
||||
class AccountManager {
|
||||
public:
|
||||
using Account = AccountInfo;
|
||||
|
||||
// Observes the activity of the account manager.
|
||||
class Observer {
|
||||
public:
|
||||
virtual ~Observer() = default;
|
||||
|
||||
virtual void OnLoginSucceeded(absl::string_view account_id) = 0;
|
||||
// |credential_error| is true if the logout is due to critical auth error.
|
||||
virtual void OnLogoutSucceeded(absl::string_view account_id,
|
||||
bool credential_error) = 0;
|
||||
};
|
||||
|
||||
virtual ~AccountManager() = default;
|
||||
|
||||
// Gets current active account. If no login user, return std::nullopt.
|
||||
virtual std::optional<Account> GetCurrentAccount() = 0;
|
||||
|
||||
// Initializes the login process for a Google account from an oauth client.
|
||||
// |client_id| GCP client_id of the client
|
||||
// |client_secret| GCP client_secret of the client
|
||||
// Returns a SigninAttempt object that can be used to complete the login
|
||||
// process.
|
||||
virtual std::unique_ptr<SigninAttempt> Login(
|
||||
absl::string_view client_id, absl::string_view client_secret) = 0;
|
||||
|
||||
// Logs out current active account. |logout_callback| is called when logout is
|
||||
// completed.
|
||||
virtual void Logout(
|
||||
absl::AnyInvocable<void(absl::Status)> logout_callback) = 0;
|
||||
|
||||
// Gets access token for the active account.
|
||||
// |callback| is called with the access token or error status.
|
||||
//
|
||||
// Returns false if callback is null.
|
||||
virtual bool GetAccessToken(
|
||||
absl::AnyInvocable<void(absl::StatusOr<std::string>)> callback) = 0;
|
||||
|
||||
// Returns a pair containing the client id and client secret used in the most
|
||||
// recent Login request.
|
||||
// If no current user is logged in, returns empty string for both.
|
||||
virtual std::pair<std::string, std::string> GetOAuthClientCredential() = 0;
|
||||
|
||||
virtual void AddObserver(Observer* observer) = 0;
|
||||
virtual void RemoveObserver(Observer* observer) = 0;
|
||||
|
||||
virtual void SaveAccountPrefs(absl::string_view user_id,
|
||||
absl::string_view client_id,
|
||||
absl::string_view client_secret) = 0;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // PLATFORM_API_ACCOUNT_MANAGER_H_
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright 2024 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_AUTH_STATUS_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_AUTH_STATUS_H_
|
||||
|
||||
namespace nearby {
|
||||
|
||||
enum AuthStatus {
|
||||
AUTH_STATUS_UNSPECIFIED = 0,
|
||||
// Request completed successfully, the results should be in the correct order
|
||||
// up to the given count.
|
||||
SUCCESS = 1,
|
||||
|
||||
// Request encountered a generic error.
|
||||
GENERIC_ERROR = 2,
|
||||
|
||||
// Request as specified is not supported.
|
||||
UNSUPPORTED = 3,
|
||||
|
||||
// Request failed and should be retried soon.
|
||||
TEMPORARILY_UNAVAILABLE = 4,
|
||||
|
||||
// Request failed due to an unavailable resource.
|
||||
UNAVAILABLE_RESOURCE = 5,
|
||||
|
||||
// The request failed due to an invalid argument.
|
||||
INVALID_ARGUMENT = 6,
|
||||
|
||||
// In case the status could not be retrieved.
|
||||
UNKNOWN_STATUS = 7,
|
||||
|
||||
// Currently used as a way to signal an ETag mismatch.
|
||||
PRECONDITION_FAILED = 8,
|
||||
|
||||
// Exclusively used to report when user did not consent to required scopes.
|
||||
// Do NOT use this for another other scenarios.
|
||||
PERMISSION_DENIED = 9,
|
||||
|
||||
// The resource exists, but the requested attribute of it does not.
|
||||
MISSING_ATTRIBUTE = 10,
|
||||
|
||||
// The method was interrupted and the caller should exit the current unit of
|
||||
// work immediately.
|
||||
INTERRUPTED = 11,
|
||||
|
||||
// User signed in with an unexpected account.
|
||||
SIGNED_IN_WITH_WRONG_ACCOUNT = 12,
|
||||
|
||||
// Used when data cannot be parsed properly.
|
||||
PARSE_ERROR = 13,
|
||||
|
||||
// Used to report that the local HTTP server for receiving the authorization
|
||||
// code cannot be created.
|
||||
CANT_CREATE_AUTH_SERVER = 14,
|
||||
|
||||
// Used to report that the system browser for authenticating the user cannot
|
||||
// be open.
|
||||
CANT_OPEN_BROWSER_FOR_AUTH = 15,
|
||||
|
||||
// Used to report that the authorization code cannot be received.
|
||||
CANT_RECEIVE_AUTH_CODE = 16,
|
||||
|
||||
// Used to report that the account is blocked (e.g. CAA).
|
||||
ACCOUNT_BLOCKED = 17,
|
||||
|
||||
// Receiving the authorization code failed because it took longer than the
|
||||
// timeout.
|
||||
AUTH_CODE_TIMEOUT_EXCEEDED = 18,
|
||||
|
||||
// Used to report when user presses the cancel button during login process.
|
||||
USER_CANCELED = 19,
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_AUTH_STATUS_H_
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright 2024 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_SIGNIN_ATTEMPT_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_SIGNIN_ATTEMPT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_info.h"
|
||||
#include "internal/platform/implementation/auth_status.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
class SigninAttempt {
|
||||
public:
|
||||
SigninAttempt() = default;
|
||||
virtual ~SigninAttempt() = default;
|
||||
|
||||
// Starts a new sign-in attempt.
|
||||
// `callback` is called with the status of the request, client_id,
|
||||
// client_secret, and account_info if the request is successful. Returns the
|
||||
// auth url if the request is successful.
|
||||
virtual std::string Start(
|
||||
absl::AnyInvocable<void(AuthStatus, absl::string_view, absl::string_view,
|
||||
const AccountInfo&)>
|
||||
callback) = 0;
|
||||
|
||||
// Tears down the machinery set up to request auth tokens, including the HTTP
|
||||
// server.
|
||||
virtual void Close() = 0;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_SIGNIN_ATTEMPT_H_
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "internal/account/account_manager_impl.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "internal/proto/messaging.grpc.pb.h"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
@@ -30,7 +31,6 @@
|
||||
#include "third_party/grpc/include/grpcpp/support/client_callback.h"
|
||||
#include "third_party/grpc/include/grpcpp/support/status.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#include "internal/proto/messaging.grpc.pb.h"
|
||||
|
||||
@@ -94,7 +94,7 @@ class TachyonExpressSignalingMessenger : public api::WebRtcSignalingMessenger {
|
||||
std::unique_ptr<google::internal::communications::instantmessaging::v1::grpc::
|
||||
Messaging::StubInterface>
|
||||
messaging_stub_;
|
||||
AccountManager* const account_manager_;
|
||||
nearby::sharing::AccountManager* const account_manager_;
|
||||
std::shared_ptr<ReceiveMessagesReader> reader_ = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,36 +17,15 @@ load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "mocks",
|
||||
testonly = 1,
|
||||
hdrs = [
|
||||
"mock_account_manager.h",
|
||||
"mock_account_observer.h",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:signin_attempt",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
"@com_google_googletest//:gtest_for_library_testonly",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "test",
|
||||
srcs = [
|
||||
"fake_account_manager.cc",
|
||||
"fake_clock.cc",
|
||||
"fake_single_thread_executor.cc",
|
||||
"fake_task_runner.cc",
|
||||
"fake_timer.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"fake_account_manager.h",
|
||||
"fake_clock.h",
|
||||
"fake_device_info.h",
|
||||
"fake_http_client.h",
|
||||
@@ -60,20 +39,16 @@ cc_library(
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//internal/base",
|
||||
"//internal/base:file_path",
|
||||
"//internal/base:files",
|
||||
"//internal/network:types",
|
||||
"//internal/platform:comm",
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:signin_attempt",
|
||||
"//internal/platform/implementation:types",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/log",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
"@com_google_absl//absl/strings",
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "internal/test/fake_account_manager.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/signin_attempt.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
std::optional<AccountManager::Account> FakeAccountManager::GetCurrentAccount() {
|
||||
return account_;
|
||||
}
|
||||
|
||||
std::unique_ptr<SigninAttempt> FakeAccountManager::Login(
|
||||
absl::string_view client_id, absl::string_view client_secret) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void FakeAccountManager::Logout(
|
||||
absl::AnyInvocable<void(absl::Status)> logout_callback) {
|
||||
if (is_logout_success_) {
|
||||
std::string account_id = account_->id;
|
||||
SetAccount(std::nullopt);
|
||||
NotifyLogout(account_id, /*credential_error=*/false);
|
||||
// Invoke callback after all operations have been performed since test cases
|
||||
// may rely on the callback for synchronization.
|
||||
logout_callback(absl::OkStatus());
|
||||
return;
|
||||
}
|
||||
|
||||
logout_callback(absl::NotFoundError("No account login."));
|
||||
}
|
||||
|
||||
bool FakeAccountManager::GetAccessToken(
|
||||
absl::AnyInvocable<void(absl::StatusOr<std::string>)> callback) {
|
||||
if (!callback) {
|
||||
return false;
|
||||
}
|
||||
if (!account_.has_value()) {
|
||||
callback(absl::UnavailableError("No current user."));
|
||||
return true;
|
||||
}
|
||||
callback("FAKE_ACCESS_TOKEN");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string>
|
||||
FakeAccountManager::GetOAuthClientCredential() {
|
||||
return {"", ""};
|
||||
}
|
||||
|
||||
void FakeAccountManager::SetAccount(std::optional<Account> account) {
|
||||
account_ = account;
|
||||
}
|
||||
|
||||
void FakeAccountManager::AddObserver(Observer* observer) {
|
||||
observers_.AddObserver(observer);
|
||||
}
|
||||
|
||||
void FakeAccountManager::RemoveObserver(Observer* observer) {
|
||||
if (!observers_.HasObserver(observer)) {
|
||||
return;
|
||||
}
|
||||
observers_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
void FakeAccountManager::NotifyLogin(absl::string_view account_id) {
|
||||
for (const auto& observer : observers_.GetObservers()) {
|
||||
observer->OnLoginSucceeded(account_id);
|
||||
}
|
||||
}
|
||||
|
||||
void FakeAccountManager::NotifyLogout(absl::string_view account_id,
|
||||
bool credential_error) {
|
||||
for (const auto& observer : observers_.GetObservers()) {
|
||||
observer->OnLogoutSucceeded(account_id, credential_error);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
@@ -1,81 +0,0 @@
|
||||
// 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_TEST_FAKE_ACCOUNT_MANAGER_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_ACCOUNT_MANAGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/base/observer_list.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/signin_attempt.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
// A fake implementation of FakeAccountManager, along with a fake
|
||||
// factory, to be used in tests.
|
||||
class FakeAccountManager : public AccountManager {
|
||||
public:
|
||||
FakeAccountManager() = default;
|
||||
~FakeAccountManager() override = default;
|
||||
|
||||
std::optional<Account> GetCurrentAccount() override;
|
||||
|
||||
std::unique_ptr<SigninAttempt> Login(
|
||||
absl::string_view client_id, absl::string_view client_secret) override;
|
||||
|
||||
void Logout(absl::AnyInvocable<void(absl::Status)> logout_callback) override;
|
||||
|
||||
bool GetAccessToken(
|
||||
absl::AnyInvocable<void(absl::StatusOr<std::string>)> callback) override;
|
||||
std::pair<std::string, std::string> GetOAuthClientCredential() override;
|
||||
void AddObserver(Observer* observer) override;
|
||||
void RemoveObserver(Observer* observer) override;
|
||||
|
||||
void SaveAccountPrefs(absl::string_view user_id, absl::string_view client_id,
|
||||
absl::string_view client_secret) override {}
|
||||
|
||||
// Methods to set API response.
|
||||
void SetAccount(std::optional<Account> account);
|
||||
|
||||
void SetLogoutSuccess(bool is_logout_success) {
|
||||
is_logout_success_ = is_logout_success;
|
||||
}
|
||||
|
||||
void NotifyCredentialError() {
|
||||
NotifyLogout(account_->id, /*credential_error=*/true);
|
||||
}
|
||||
|
||||
void NotifyLogin(absl::string_view account_id);
|
||||
void NotifyLogout(absl::string_view account_id, bool credential_error);
|
||||
|
||||
private:
|
||||
// Login will fail when account_ is empty.
|
||||
std::optional<Account> account_;
|
||||
|
||||
// Logout will fail when is_logout_success_ is false;
|
||||
bool is_logout_success_ = true;
|
||||
nearby::ObserverList<Observer> observers_;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_ACCOUNT_MANAGER_H_
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright 2024 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_TEST_MOCK_ACCOUNT_MANAGER_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_TEST_MOCK_ACCOUNT_MANAGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/signin_attempt.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
class MockAccountManager : public AccountManager {
|
||||
public:
|
||||
MOCK_METHOD(std::optional<Account>, GetCurrentAccount, (), (override));
|
||||
MOCK_METHOD(std::unique_ptr<SigninAttempt>, Login,
|
||||
(absl::string_view client_id, absl::string_view client_secret),
|
||||
(override));
|
||||
MOCK_METHOD(void, Logout,
|
||||
(absl::AnyInvocable<void(absl::Status)> logout_callback),
|
||||
(override));
|
||||
MOCK_METHOD(bool, GetAccessToken,
|
||||
(absl::AnyInvocable<void(absl::StatusOr<std::string>)> callback),
|
||||
(override));
|
||||
MOCK_METHOD((std::pair<std::string, std::string>), GetOAuthClientCredential,
|
||||
(), (override));
|
||||
MOCK_METHOD(void, AddObserver, (Observer * observer), (override));
|
||||
MOCK_METHOD(void, RemoveObserver, (Observer * observer), (override));
|
||||
MOCK_METHOD(void, SaveAccountPrefs,
|
||||
(absl::string_view user_id, absl::string_view client_id,
|
||||
absl::string_view client_secret),
|
||||
(override));
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_TEST_MOCK_ACCOUNT_MANAGER_H_
|
||||
@@ -1,38 +0,0 @@
|
||||
// Copyright 2024 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_TEST_MOCK_ACCOUNT_OBSERVER_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_TEST_MOCK_ACCOUNT_OBSERVER_H_
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
class MockAccountObserver : public AccountManager::Observer {
|
||||
public:
|
||||
~MockAccountObserver() override = default;
|
||||
|
||||
MOCK_METHOD(void, OnLoginSucceeded, (absl::string_view account_id),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(void, OnLogoutSucceeded,
|
||||
(absl::string_view account_id, bool credential_error),
|
||||
(override));
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_TEST_MOCK_ACCOUNT_OBSERVER_H_
|
||||
+4
-3
@@ -382,8 +382,8 @@ cc_library(
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:types",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/rpc:grpc_async_client_factory",
|
||||
"//location/nearby/sharing/lib/rpc:sharing_rpc_client",
|
||||
"//location/nearby/sharing/lib/sync:sync_manager",
|
||||
@@ -631,9 +631,10 @@ cc_test(
|
||||
"//internal/base:files",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/platform/implementation:signin_attempt",
|
||||
"//internal/test",
|
||||
"//internal/test:mocks",
|
||||
"//location/nearby/sharing/lib/account:fake_account_manager",
|
||||
"//location/nearby/sharing/lib/account:mock_account_manager",
|
||||
"//location/nearby/sharing/lib/account:signin_attempt",
|
||||
"//location/nearby/sharing/lib/rpc:fake_nearby_share_client",
|
||||
"//sharing/analytics",
|
||||
"//sharing/certificates",
|
||||
|
||||
@@ -50,7 +50,7 @@ cc_library(
|
||||
"//internal/crypto_cros",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/rpc:sharing_rpc_client",
|
||||
"//sharing/internal/api:platform",
|
||||
"//sharing/internal/base",
|
||||
@@ -127,9 +127,9 @@ cc_test(
|
||||
"//google/nearby/identity/v1:resources_cc_proto",
|
||||
"//google/nearby/identity/v1:rpcs_cc_proto",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/account:fake_account_manager",
|
||||
"//location/nearby/sharing/lib/rpc:fake_nearby_share_client",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/internal/api:mock_sharing_platform",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "google/nearby/identity/v1/resources.pb.h"
|
||||
#include "google/nearby/identity/v1/rpcs.pb.h"
|
||||
#include "google/protobuf/timestamp.pb.h"
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "absl/algorithm/algorithm.h"
|
||||
#include "absl/base/nullability.h"
|
||||
@@ -44,7 +45,6 @@
|
||||
#include "absl/time/time.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/mac_address.h"
|
||||
#include "sharing/certificates/common.h"
|
||||
#include "sharing/certificates/constants.h"
|
||||
@@ -72,11 +72,9 @@
|
||||
#include "sharing/scheduling/nearby_share_scheduler_factory.h"
|
||||
#include "util/hash/highway_fingerprint.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace nearby::sharing {
|
||||
namespace {
|
||||
|
||||
using ::google::nearby::identity::v1::AccountInfo;
|
||||
using ::google::nearby::identity::v1::GetAccountInfoRequest;
|
||||
using ::google::nearby::identity::v1::GetAccountInfoResponse;
|
||||
using ::google::nearby::identity::v1::PerVisibilitySharedCredentials;
|
||||
@@ -889,8 +887,8 @@ bool NearbyShareCertificateManagerImpl::UpdateAccountInfoInExecutor() {
|
||||
const auto& capabilities = response->account_info().capabilities();
|
||||
bool has_titanium_capability =
|
||||
(std::find(capabilities.begin(), capabilities.end(),
|
||||
AccountInfo::CAPABILITY_TITANIUM) !=
|
||||
capabilities.end());
|
||||
google::nearby::identity::v1::AccountInfo::
|
||||
CAPABILITY_TITANIUM) != capabilities.end());
|
||||
preference_manager_.SetBoolean(PrefNames::kAdvancedProtectionEnabled,
|
||||
has_titanium_capability);
|
||||
LOG(INFO) << "GetAccountInfo succeeded, advanced protection enabled: "
|
||||
@@ -904,5 +902,4 @@ bool NearbyShareCertificateManagerImpl::UpdateAccountInfoInExecutor() {
|
||||
return get_account_info_succeeded;
|
||||
}
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "sharing/certificates/nearby_share_certificate_manager.h"
|
||||
#include "sharing/certificates/nearby_share_certificate_storage.h"
|
||||
@@ -43,8 +43,7 @@
|
||||
#include "sharing/proto/enums.pb.h"
|
||||
#include "sharing/proto/rpc_resources.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace nearby::sharing {
|
||||
|
||||
class NearbyShareScheduler;
|
||||
|
||||
@@ -221,7 +220,6 @@ class NearbyShareCertificateManagerImpl
|
||||
std::unique_ptr<TaskRunner> executor_;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_CERTIFICATES_NEARBY_SHARE_CERTIFICATE_MANAGER_IMPL_H_
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "google/nearby/identity/v1/resources.pb.h"
|
||||
#include "google/nearby/identity/v1/rpcs.pb.h"
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/account/fake_account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/fake_nearby_share_client.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
@@ -37,9 +39,7 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/mac_address.h"
|
||||
#include "internal/test/fake_account_manager.h"
|
||||
#include "sharing/certificates/constants.h"
|
||||
#include "sharing/certificates/fake_nearby_share_certificate_storage.h"
|
||||
#include "sharing/certificates/nearby_share_certificate_manager.h"
|
||||
@@ -62,10 +62,8 @@
|
||||
#include "sharing/scheduling/fake_nearby_share_scheduler_factory.h"
|
||||
#include "sharing/scheduling/nearby_share_scheduler_factory.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace nearby::sharing {
|
||||
namespace {
|
||||
using ::google::nearby::identity::v1::AccountInfo;
|
||||
using ::google::nearby::identity::v1::Device;
|
||||
using ::google::nearby::identity::v1::GetAccountInfoResponse;
|
||||
using ::google::nearby::identity::v1::PublishDeviceRequest;
|
||||
@@ -958,7 +956,7 @@ TEST_F(NearbyShareCertificateManagerImplTest,
|
||||
Initialize();
|
||||
GetAccountInfoResponse response;
|
||||
response.mutable_account_info()->mutable_capabilities()->Add(
|
||||
AccountInfo::CAPABILITY_TITANIUM);
|
||||
google::nearby::identity::v1::AccountInfo::CAPABILITY_TITANIUM);
|
||||
identity_client_.SetGetAccountInfoResponse(response);
|
||||
|
||||
account_info_update_scheduler_->InvokeRequestCallback();
|
||||
@@ -990,7 +988,7 @@ TEST_F(NearbyShareCertificateManagerImplTest,
|
||||
preference_manager_.SetBoolean(PrefNames::kAdvancedProtectionEnabled, true);
|
||||
GetAccountInfoResponse response;
|
||||
response.mutable_account_info()->mutable_capabilities()->Add(
|
||||
AccountInfo::CAPABILITY_UNSPECIFIED);
|
||||
google::nearby::identity::v1::AccountInfo::CAPABILITY_UNSPECIFIED);
|
||||
identity_client_.SetGetAccountInfoResponse(response);
|
||||
|
||||
account_info_update_scheduler_->InvokeRequestCallback();
|
||||
@@ -1015,5 +1013,4 @@ TEST_F(NearbyShareCertificateManagerImplTest,
|
||||
PrefNames::kAdvancedProtectionEnabled, /*default_value=*/false));
|
||||
}
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
@@ -42,7 +42,7 @@ cc_library(
|
||||
deps = [
|
||||
":contacts_interface",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/rpc:sharing_rpc_client",
|
||||
"//sharing/internal/public:logging",
|
||||
"//sharing/internal/public:types",
|
||||
@@ -70,9 +70,9 @@ cc_test(
|
||||
],
|
||||
deps = [
|
||||
":contacts",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/account:fake_account_manager",
|
||||
"//location/nearby/sharing/lib/rpc:fake_nearby_share_client",
|
||||
"//sharing/internal/test:nearby_test",
|
||||
"//sharing/local_device_data:test_support",
|
||||
|
||||
@@ -23,19 +23,18 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/synchronization/notification.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "sharing/contacts/nearby_share_contact_manager.h"
|
||||
#include "sharing/internal/public/context.h"
|
||||
#include "sharing/internal/public/logging.h"
|
||||
#include "sharing/proto/contact_rpc.pb.h"
|
||||
#include "sharing/proto/rpc_resources.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace nearby::sharing {
|
||||
namespace {
|
||||
|
||||
using ::nearby::sharing::proto::ContactRecord;
|
||||
@@ -148,5 +147,4 @@ void NearbyShareContactManagerImpl::GetContacts(ContactsCallback callback) {
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "absl/base/nullability.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "sharing/contacts/nearby_share_contact_manager.h"
|
||||
#include "sharing/internal/public/context.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace nearby::sharing {
|
||||
|
||||
class NearbyShareContactManagerImpl : public NearbyShareContactManager {
|
||||
public:
|
||||
@@ -45,7 +44,6 @@ class NearbyShareContactManagerImpl : public NearbyShareContactManager {
|
||||
std::unique_ptr<TaskRunner> executor_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_CONTACTS_NEARBY_SHARE_CONTACT_MANAGER_IMPL_H_
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/account/fake_account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/fake_nearby_share_client.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/test/fake_account_manager.h"
|
||||
#include "sharing/internal/test/fake_context.h"
|
||||
#include "sharing/local_device_data/fake_nearby_share_local_device_data_manager.h"
|
||||
#include "sharing/proto/contact_rpc.pb.h"
|
||||
|
||||
@@ -41,7 +41,7 @@ cc_library(
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/sync:sync_binding_prefs_cc_proto",
|
||||
"//location/nearby/sharing/lib/sync:sync_config_prefs_cc_proto",
|
||||
"//sharing/proto:share_cc_proto",
|
||||
@@ -71,7 +71,7 @@ cc_library(
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//sharing/analytics",
|
||||
"//sharing/internal/public:logging",
|
||||
"//sharing/proto:share_cc_proto",
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "sharing/internal/api/app_info.h"
|
||||
#include "sharing/internal/api/bluetooth_adapter.h"
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "sharing/internal/api/app_info.h"
|
||||
#include "sharing/internal/api/bluetooth_adapter.h"
|
||||
|
||||
@@ -31,8 +31,8 @@ cc_library(
|
||||
deps = [
|
||||
"//internal/base",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:types",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/internal/api:platform",
|
||||
"//sharing/internal/base:utf_utils",
|
||||
@@ -68,9 +68,10 @@ cc_test(
|
||||
],
|
||||
deps = [
|
||||
":local_device_data",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//location/nearby/sharing/lib/account:account_manager",
|
||||
"//location/nearby/sharing/lib/account:fake_account_manager",
|
||||
"//sharing/common",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/internal/test:nearby_test",
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/strings/substitute.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
@@ -37,8 +37,7 @@
|
||||
#include "sharing/proto/rpc_resources.pb.h"
|
||||
#include "sharing/proto/timestamp.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace nearby::sharing {
|
||||
namespace {
|
||||
using ::nearby::api::DeviceInfo;
|
||||
using ::nearby::sharing::api::PreferenceManager;
|
||||
@@ -164,5 +163,4 @@ std::string NearbyShareLocalDeviceDataManagerImpl::GetDefaultDeviceName()
|
||||
return absl::Substitute(kDefaultDeviceName, truncated_name, device_type);
|
||||
}
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
#include "sharing/local_device_data/nearby_share_local_device_data_manager.h"
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/account/fake_account_manager.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/strings/substitute.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/test/fake_account_manager.h"
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/common/nearby_share_prefs.h"
|
||||
@@ -118,7 +118,7 @@ class NearbyShareLocalDeviceDataManagerImplTest
|
||||
|
||||
protected:
|
||||
nearby::FakePreferenceManager preference_manager_;
|
||||
nearby::FakeAccountManager fake_account_manager_;
|
||||
FakeAccountManager fake_account_manager_;
|
||||
nearby::FakeDeviceInfo fake_device_info_;
|
||||
std::vector<ObserverNotification> notifications_;
|
||||
std::unique_ptr<NearbyShareLocalDeviceDataManager> manager_;
|
||||
|
||||
@@ -31,12 +31,9 @@
|
||||
#include "sharing/share_target_discovered_callback.h"
|
||||
#include "sharing/transfer_update_callback.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace nearby::sharing {
|
||||
|
||||
class AccountManager;
|
||||
|
||||
namespace sharing {
|
||||
|
||||
class NearbyNotificationDelegate;
|
||||
class NearbyShareContactManager;
|
||||
|
||||
@@ -227,7 +224,6 @@ class NearbySharingService {
|
||||
uint16_t alternate_service_uuid) = 0;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_NEARBY_SHARING_SERVICE_H_
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
@@ -48,7 +49,6 @@
|
||||
#include "internal/network/url.h"
|
||||
#include "internal/platform/clock.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "location/nearby/sharing/lib/sync/sync_manager.h"
|
||||
#include "absl/base/nullability.h"
|
||||
@@ -38,7 +39,6 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/platform/clock.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/advertisement.h"
|
||||
@@ -90,7 +90,7 @@ class NearbySharingServiceImpl
|
||||
: public NearbySharingService,
|
||||
public NearbyShareSettings::Observer,
|
||||
public NearbyShareCertificateManager::Observer,
|
||||
public ::nearby::AccountManager::Observer,
|
||||
public AccountManager::Observer,
|
||||
public NearbyFastInitiation::Observer,
|
||||
public sharing::api::BluetoothAdapter::Observer,
|
||||
public NearbyConnectionsManager::IncomingConnectionListener,
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/signin_attempt.h"
|
||||
#include "location/nearby/sharing/lib/account/fake_account_manager.h"
|
||||
#include "location/nearby/sharing/lib/account/mock_account_observer.h"
|
||||
#include "location/nearby/sharing/lib/rpc/fake_nearby_share_client.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
@@ -48,11 +51,8 @@
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/base/files.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "internal/platform/implementation/signin_attempt.h"
|
||||
#include "internal/test/fake_account_manager.h"
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "internal/test/mock_account_observer.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/advertisement_capabilities.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
@@ -1705,7 +1705,7 @@ TEST_F(NearbySharingServiceImplTest,
|
||||
ForegroundRegisterReceiveSurfaceIsAdvertisingAllContacts) {
|
||||
SetLanConnected(true);
|
||||
SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
::nearby::AccountManager::Account account;
|
||||
AccountManager::Account account;
|
||||
account.id = kTestAccountId;
|
||||
account_manager().SetAccount(account);
|
||||
local_device_data_manager()->SetDeviceName(kDeviceName);
|
||||
@@ -1759,7 +1759,7 @@ TEST_F(NearbySharingServiceImplTest,
|
||||
BackgroundRegisterReceiveSurfaceIsAdvertisingSelectedContacts) {
|
||||
SetLanConnected(true);
|
||||
SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_SELECTED_CONTACTS);
|
||||
::nearby::AccountManager::Account account;
|
||||
AccountManager::Account account;
|
||||
account.id = kTestAccountId;
|
||||
account_manager().SetAccount(account);
|
||||
SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
@@ -4883,7 +4883,7 @@ TEST_F(NearbySharingServiceImplTest, RemoveIncomingPayloads) {
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest, NotifyLogoutSucceededWithCredentialError) {
|
||||
TestObserver observer(service_.get());
|
||||
::nearby::AccountManager::Account account;
|
||||
AccountManager::Account account;
|
||||
account.id = kTestAccountId;
|
||||
account_manager().SetAccount(account);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user