Initial Check-in for FastPair Adapter. Details can be seen in go/fast_pair_ux_platform_c++_app_flow. ServerAccess is included for implementing the interface flow via hardcoded model ID because of the non-implemented callback in scanning.

PiperOrigin-RevId: 497281054
This commit is contained in:
hai007
2022-12-22 19:10:15 -08:00
committed by Copybara-Service
parent 86f87ef88b
commit cacc7f83d1
7 changed files with 272 additions and 0 deletions
+30
View File
@@ -1,6 +1,36 @@
# 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.
licenses(["notice"])
package_group(
name = "nearby_fastpair",
packages = [
"//fastpair/...",
],
)
cc_library(
name = "fastpair_controller",
srcs = [],
hdrs = [
"fast_pair_controller.h",
],
copts = ["-Ithird_party"],
visibility = [
"//fastpair:__subpackages__",
],
deps = [
],
)
+61
View File
@@ -0,0 +1,61 @@
# 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.
load("//third_party/lexan/build_defs:lexan.bzl", "lexan")
licenses(["notice"])
lexan.cc_windows_dll(
name = "fastpair_adapter",
srcs = [
"fast_pair_controller_adapter.cc",
],
hdrs = [
"fast_pair_controller_adapter.h",
],
copts = [
"-Ithird_party",
],
defines = [
"_WIN32_WINNT=_WIN32_WINNT_WIN10",
],
tags = ["windows-dll"],
deps = [
"//fastpair:fastpair_controller",
"@com_google_absl//absl/strings",
],
)
lexan.cc_windows_dll(
name = "fastpair_dart",
srcs = [
"fast_pair_controller_adapter.cc",
"fast_pair_controller_adapter_dart.cc",
],
hdrs = [
"fast_pair_controller_adapter.h",
"fast_pair_controller_adapter_dart.h",
],
copts = [
"-Ithird_party",
],
defines = [
"_WIN32_WINNT=_WIN32_WINNT_WIN10",
],
tags = ["windows-dll"],
deps = [
"//fastpair:fastpair_controller",
"//third_party/dart_lang/v2:dart_api_dl",
"@com_google_absl//absl/strings",
],
)
@@ -0,0 +1,37 @@
// 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 "fastpair/client/windows/fast_pair_controller_adapter.h"
namespace location {
namespace nearby {
namespace fastpair {
FastPairController *InitFastPairController() {
return new FastPairController();
}
void CloseFastPairController(FastPairController *pController) {
if (pController != nullptr) delete pController;
}
void StartScanning(FastPairController *pController) {
}
void ServerAccess(FastPairController *pController) {
}
} // namespace fastpair
} // namespace nearby
} // namespace location
@@ -0,0 +1,41 @@
// 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_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_
#define THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_
#define DLL_EXPORT extern "C" __declspec(dllexport)
#include "fastpair/fast_pair_controller.h"
namespace location {
namespace nearby {
namespace fastpair {
// Initiate a default FastPairController instance.
// Return the instance handle to client
DLL_EXPORT FastPairController *__stdcall InitFastPairController();
DLL_EXPORT void __stdcall CloseFastPairController(
FastPairController *pController);
DLL_EXPORT void __stdcall StartScanning(FastPairController *pController);
DLL_EXPORT void __stdcall ServerAccess(FastPairController *pController);
} // namespace fastpair
} // namespace nearby
} // namespace location
#endif // THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_
@@ -0,0 +1,33 @@
// 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 "fastpair/client/windows/fast_pair_controller_adapter_dart.h"
#include "fastpair/client/windows/fast_pair_controller_adapter.h"
namespace location {
namespace nearby {
namespace fastpair {
void StartScanningDart(FastPairController *pController) {
StartScanning(pController);
}
void ServerAccessDart(FastPairController *pController) {
ServerAccess(pController);
}
} // namespace fastpair
} // namespace nearby
} // namespace location
@@ -0,0 +1,33 @@
// 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_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_
#define THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_
#include "third_party/dart_lang/v2/runtime/include/dart_api_dl.h"
#include "fastpair/client/windows/fast_pair_controller_adapter.h"
namespace location {
namespace nearby {
namespace fastpair {
DLL_EXPORT void __stdcall StartScanningDart(FastPairController* pController);
DLL_EXPORT void __stdcall ServerAccessDart(FastPairController* pController);
} // namespace fastpair
} // namespace nearby
} // namespace location
#endif // THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_
+37
View File
@@ -0,0 +1,37 @@
// 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_FASTPAIR_FAST_PAIR_CONTROLLER_H_
#define THIRD_PARTY_NEARBY_FASTPAIR_FAST_PAIR_CONTROLLER_H_
#include <functional>
namespace location {
namespace nearby {
namespace fastpair {
class FastPairController {
public:
~FastPairController() = default;
void StartScanning();
void ServerAccess();
};
} // namespace fastpair
} // namespace nearby
} // namespace location
#endif // THIRD_PARTY_NEARBY_FAST_PAIR_FASTPAIR_CONTROLLER_H_