aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHansong Zhang <hsz@google.com>2019-08-29 18:05:08 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-08-29 18:05:08 -0700
commit346f4f767fc391070f8ab6edbcaea571590ab340 (patch)
treee1d6b804cafef34696e77b9ad7a57fd5a2935f96
parent0c63ef1883f565e49636a162f2fd1dcdd0a8044d (diff)
parente0a997f180f98b02e10932165e5c7e3ee48a387a (diff)
downloadbt-346f4f767fc391070f8ab6edbcaea571590ab340.tar.gz
Cert: Move Read local MAC address to a special server
am: e0a997f180 Change-Id: I7ba21067dce4a9511e5ccf6fd1dffb76a4f13087
-rw-r--r--gd/Android.bp2
-rw-r--r--gd/cert/gd_cert_device.py1
-rw-r--r--gd/cert/gd_device.py1
-rw-r--r--gd/cert/grpc_root_server.cc3
-rw-r--r--gd/cert/read_only_property_server.cc57
-rw-r--r--gd/cert/read_only_property_server.h45
-rw-r--r--gd/cert/rootservice.proto7
-rw-r--r--gd/facade/grpc_root_server.cc3
-rw-r--r--gd/facade/read_only_property_server.cc57
-rw-r--r--gd/facade/read_only_property_server.h45
-rw-r--r--gd/facade/rootservice.proto7
-rw-r--r--gd/hci/cert/api.proto1
-rw-r--r--gd/hci/cert/cert.cc7
-rw-r--r--gd/hci/cert/simple_hci_test.py4
-rw-r--r--gd/hci/facade.cc7
-rw-r--r--gd/hci/facade.proto1
16 files changed, 230 insertions, 18 deletions
diff --git a/gd/Android.bp b/gd/Android.bp
index 5d0220434..cf485360f 100644
--- a/gd/Android.bp
+++ b/gd/Android.bp
@@ -131,6 +131,7 @@ cc_binary {
srcs: [
"facade/facade_main.cc",
"facade/grpc_root_server.cc",
+ "facade/read_only_property_server.cc",
"grpc/grpc_module.cc",
":BluetoothFacade_hci_hal",
":BluetoothFacade_hci_layer",
@@ -176,6 +177,7 @@ cc_binary {
srcs: [
"cert/cert_main.cc",
"cert/grpc_root_server.cc",
+ "cert/read_only_property_server.cc",
"grpc/grpc_module.cc",
":BluetoothCertSource_hci_hal",
":BluetoothCertSource_hci_layer",
diff --git a/gd/cert/gd_cert_device.py b/gd/cert/gd_cert_device.py
index 45318d96c..885a57691 100644
--- a/gd/cert/gd_cert_device.py
+++ b/gd/cert/gd_cert_device.py
@@ -66,6 +66,7 @@ class GdCertDevice(GdDeviceBase):
# Cert stubs
self.rootservice = cert_rootservice_pb2_grpc.RootCertStub(self.grpc_root_server_channel)
self.hal = hal_cert_pb2_grpc.HciHalCertStub(self.grpc_channel)
+ self.controller_read_only_property = cert_rootservice_pb2_grpc.ReadOnlyPropertyStub(self.grpc_channel)
self.hci = hci_cert_pb2_grpc.AclManagerCertStub(self.grpc_channel)
self.l2cap = l2cap_cert_pb2_grpc.L2capModuleCertStub(self.grpc_channel)
diff --git a/gd/cert/gd_device.py b/gd/cert/gd_device.py
index ab7bac89d..b1465bc5e 100644
--- a/gd/cert/gd_device.py
+++ b/gd/cert/gd_device.py
@@ -66,6 +66,7 @@ class GdDevice(GdDeviceBase):
# Facade stubs
self.rootservice = facade_rootservice_pb2_grpc.RootFacadeStub(self.grpc_root_server_channel)
self.hal = hal_facade_pb2_grpc.HciHalFacadeStub(self.grpc_channel)
+ self.controller_read_only_property = facade_rootservice_pb2_grpc.ReadOnlyPropertyStub(self.grpc_channel)
self.hci = hci_facade_pb2_grpc.AclManagerFacadeStub(self.grpc_channel)
self.hci_classic_security = hci_facade_pb2_grpc.ClassicSecurityManagerFacadeStub(self.grpc_channel)
self.l2cap = l2cap_facade_pb2_grpc.L2capModuleFacadeStub(self.grpc_channel)
diff --git a/gd/cert/grpc_root_server.cc b/gd/cert/grpc_root_server.cc
index 7ed68477c..7c32ff237 100644
--- a/gd/cert/grpc_root_server.cc
+++ b/gd/cert/grpc_root_server.cc
@@ -18,6 +18,7 @@
#include <string>
+#include "cert/read_only_property_server.h"
#include "cert/rootservice.grpc.pb.h"
#include "grpc/grpc_module.h"
#include "hal/cert/cert.h"
@@ -53,9 +54,11 @@ class RootCertService : public ::bluetooth::cert::RootCert::Service {
modules.add<::bluetooth::hal::cert::HalCertModule>();
break;
case BluetoothModule::HCI:
+ modules.add<::bluetooth::cert::ReadOnlyPropertyServerModule>();
modules.add<::bluetooth::hci::cert::AclManagerCertModule>();
break;
case BluetoothModule::L2CAP:
+ modules.add<::bluetooth::cert::ReadOnlyPropertyServerModule>();
modules.add<::bluetooth::l2cap::cert::L2capModuleCertModule>();
break;
default:
diff --git a/gd/cert/read_only_property_server.cc b/gd/cert/read_only_property_server.cc
new file mode 100644
index 000000000..d67c33e32
--- /dev/null
+++ b/gd/cert/read_only_property_server.cc
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ * http://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 "cert/read_only_property_server.h"
+#include "hci/controller.h"
+
+namespace bluetooth {
+namespace cert {
+
+class ReadOnlyPropertyService : public ReadOnlyProperty::Service {
+ public:
+ ReadOnlyPropertyService(hci::Controller* controller) : controller_(controller) {}
+ ::grpc::Status ReadLocalAddress(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
+ ::bluetooth::facade::BluetoothAddress* response) override {
+ auto address = controller_->GetControllerMacAddress().ToString();
+ response->set_address(address);
+ return ::grpc::Status::OK;
+ }
+
+ private:
+ hci::Controller* controller_;
+};
+
+void ReadOnlyPropertyServerModule::ListDependencies(ModuleList* list) {
+ GrpcFacadeModule::ListDependencies(list);
+ list->add<hci::Controller>();
+}
+void ReadOnlyPropertyServerModule::Start() {
+ GrpcFacadeModule::Start();
+ service_ = std::make_unique<ReadOnlyPropertyService>(GetDependency<hci::Controller>());
+}
+void ReadOnlyPropertyServerModule::Stop() {
+ service_.reset();
+ GrpcFacadeModule::Stop();
+}
+::grpc::Service* ReadOnlyPropertyServerModule::GetService() const {
+ return service_.get();
+}
+
+const ModuleFactory ReadOnlyPropertyServerModule::Factory =
+ ::bluetooth::ModuleFactory([]() { return new ReadOnlyPropertyServerModule(); });
+
+} // namespace cert
+} // namespace bluetooth
diff --git a/gd/cert/read_only_property_server.h b/gd/cert/read_only_property_server.h
new file mode 100644
index 000000000..e367537f4
--- /dev/null
+++ b/gd/cert/read_only_property_server.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ * http://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.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <grpc++/grpc++.h>
+
+#include "cert/rootservice.grpc.pb.h"
+#include "grpc/grpc_module.h"
+
+namespace bluetooth {
+namespace cert {
+
+class ReadOnlyPropertyService;
+
+class ReadOnlyPropertyServerModule : public ::bluetooth::grpc::GrpcFacadeModule {
+ public:
+ static const ModuleFactory Factory;
+
+ void ListDependencies(ModuleList* list) override;
+ void Start() override;
+ void Stop() override;
+ ::grpc::Service* GetService() const override;
+
+ private:
+ std::unique_ptr<ReadOnlyPropertyService> service_;
+};
+
+} // namespace cert
+} // namespace bluetooth
diff --git a/gd/cert/rootservice.proto b/gd/cert/rootservice.proto
index 02bd0785f..4472bfec8 100644
--- a/gd/cert/rootservice.proto
+++ b/gd/cert/rootservice.proto
@@ -2,6 +2,9 @@ syntax = "proto3";
package bluetooth.cert;
+import "google/protobuf/empty.proto";
+import "facade/common.proto";
+
service RootCert {
rpc StartStack(StartStackRequest) returns (StartStackResponse) {}
rpc StopStack(StopStackRequest) returns (StopStackResponse) {}
@@ -23,3 +26,7 @@ message StartStackResponse {}
message StopStackRequest {}
message StopStackResponse {}
+
+service ReadOnlyProperty {
+ rpc ReadLocalAddress(google.protobuf.Empty) returns (facade.BluetoothAddress) {}
+}
diff --git a/gd/facade/grpc_root_server.cc b/gd/facade/grpc_root_server.cc
index b11fd654e..8857ea079 100644
--- a/gd/facade/grpc_root_server.cc
+++ b/gd/facade/grpc_root_server.cc
@@ -18,6 +18,7 @@
#include <string>
+#include "facade/read_only_property_server.h"
#include "facade/rootservice.grpc.pb.h"
#include "grpc/grpc_module.h"
#include "hal/facade.h"
@@ -53,10 +54,12 @@ class RootFacadeService : public ::bluetooth::facade::RootFacade::Service {
modules.add<::bluetooth::hal::HciHalFacadeModule>();
break;
case BluetoothModule::HCI:
+ modules.add<::bluetooth::facade::ReadOnlyPropertyServerModule>();
modules.add<::bluetooth::hci::AclManagerFacadeModule>();
modules.add<::bluetooth::hci::ClassicSecurityManagerFacadeModule>();
break;
case BluetoothModule::L2CAP:
+ modules.add<::bluetooth::facade::ReadOnlyPropertyServerModule>();
modules.add<::bluetooth::l2cap::L2capModuleFacadeModule>();
break;
default:
diff --git a/gd/facade/read_only_property_server.cc b/gd/facade/read_only_property_server.cc
new file mode 100644
index 000000000..3c57b879e
--- /dev/null
+++ b/gd/facade/read_only_property_server.cc
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ * http://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 "facade/read_only_property_server.h"
+#include "hci/controller.h"
+
+namespace bluetooth {
+namespace facade {
+
+class ReadOnlyPropertyService : public ReadOnlyProperty::Service {
+ public:
+ ReadOnlyPropertyService(hci::Controller* controller) : controller_(controller) {}
+ ::grpc::Status ReadLocalAddress(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
+ ::bluetooth::facade::BluetoothAddress* response) override {
+ auto address = controller_->GetControllerMacAddress().ToString();
+ response->set_address(address);
+ return ::grpc::Status::OK;
+ }
+
+ private:
+ hci::Controller* controller_;
+};
+
+void ReadOnlyPropertyServerModule::ListDependencies(ModuleList* list) {
+ GrpcFacadeModule::ListDependencies(list);
+ list->add<hci::Controller>();
+}
+void ReadOnlyPropertyServerModule::Start() {
+ GrpcFacadeModule::Start();
+ service_ = std::make_unique<ReadOnlyPropertyService>(GetDependency<hci::Controller>());
+}
+void ReadOnlyPropertyServerModule::Stop() {
+ service_.reset();
+ GrpcFacadeModule::Stop();
+}
+::grpc::Service* ReadOnlyPropertyServerModule::GetService() const {
+ return service_.get();
+}
+
+const ModuleFactory ReadOnlyPropertyServerModule::Factory =
+ ::bluetooth::ModuleFactory([]() { return new ReadOnlyPropertyServerModule(); });
+
+} // namespace facade
+} // namespace bluetooth
diff --git a/gd/facade/read_only_property_server.h b/gd/facade/read_only_property_server.h
new file mode 100644
index 000000000..dfac42412
--- /dev/null
+++ b/gd/facade/read_only_property_server.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ * http://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.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <grpc++/grpc++.h>
+
+#include "facade/rootservice.grpc.pb.h"
+#include "grpc/grpc_module.h"
+
+namespace bluetooth {
+namespace facade {
+
+class ReadOnlyPropertyService;
+
+class ReadOnlyPropertyServerModule : public ::bluetooth::grpc::GrpcFacadeModule {
+ public:
+ static const ModuleFactory Factory;
+
+ void ListDependencies(ModuleList* list) override;
+ void Start() override;
+ void Stop() override;
+ ::grpc::Service* GetService() const override;
+
+ private:
+ std::unique_ptr<ReadOnlyPropertyService> service_;
+};
+
+} // namespace facade
+} // namespace bluetooth
diff --git a/gd/facade/rootservice.proto b/gd/facade/rootservice.proto
index 7bf45cacd..eec30ad05 100644
--- a/gd/facade/rootservice.proto
+++ b/gd/facade/rootservice.proto
@@ -2,6 +2,9 @@ syntax = "proto3";
package bluetooth.facade;
+import "google/protobuf/empty.proto";
+import "facade/common.proto";
+
service RootFacade {
rpc StartStack(StartStackRequest) returns (StartStackResponse) {}
rpc StopStack(StopStackRequest) returns (StopStackResponse) {}
@@ -23,3 +26,7 @@ message StartStackResponse {}
message StopStackRequest {}
message StopStackResponse {}
+
+service ReadOnlyProperty {
+ rpc ReadLocalAddress(google.protobuf.Empty) returns (facade.BluetoothAddress) {}
+}
diff --git a/gd/hci/cert/api.proto b/gd/hci/cert/api.proto
index 32b4bf117..cf4774335 100644
--- a/gd/hci/cert/api.proto
+++ b/gd/hci/cert/api.proto
@@ -6,7 +6,6 @@ import "google/protobuf/empty.proto";
import "facade/common.proto";
service AclManagerCert {
- rpc ReadLocalAddress(google.protobuf.Empty) returns (facade.BluetoothAddress) {}
rpc SetPageScanMode(PageScanMode) returns (google.protobuf.Empty) {}
rpc SetIncomingConnectionPolicy(IncomingConnectionPolicy) returns (google.protobuf.Empty) {}
rpc Connect(facade.BluetoothAddress) returns (google.protobuf.Empty) {}
diff --git a/gd/hci/cert/cert.cc b/gd/hci/cert/cert.cc
index 0dd36f3c7..c2f2ce93f 100644
--- a/gd/hci/cert/cert.cc
+++ b/gd/hci/cert/cert.cc
@@ -141,13 +141,6 @@ class AclManagerCertService : public AclManagerCert::Service {
using EventStream = ::bluetooth::grpc::GrpcEventStream<AclData, AclPacketView>;
- ::grpc::Status ReadLocalAddress(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
- ::bluetooth::facade::BluetoothAddress* response) override {
- auto address = controller_->GetControllerMacAddress().ToString();
- response->set_address(address);
- return ::grpc::Status::OK;
- }
-
::grpc::Status SetPageScanMode(::grpc::ServerContext* context, const ::bluetooth::hci::cert::PageScanMode* request,
::google::protobuf::Empty* response) override {
ScanEnable scan_enable = request->enabled() ? ScanEnable::PAGE_SCAN_ONLY : ScanEnable::NO_SCANS;
diff --git a/gd/hci/cert/simple_hci_test.py b/gd/hci/cert/simple_hci_test.py
index 4bfbd1b89..e59e18451 100644
--- a/gd/hci/cert/simple_hci_test.py
+++ b/gd/hci/cert/simple_hci_test.py
@@ -60,9 +60,9 @@ class SimpleHciTest(GdBaseTestClass):
hci_cert_pb2.PageScanMode(enabled=True)
)
- dut_address = self.device_under_test.hci.ReadLocalAddress(empty_pb2.Empty()).address
+ dut_address = self.device_under_test.controller_read_only_property.ReadLocalAddress(empty_pb2.Empty()).address
self.device_under_test.address = dut_address
- cert_address = self.cert_device.hci.ReadLocalAddress(empty_pb2.Empty()).address
+ cert_address = self.cert_device.controller_read_only_property.ReadLocalAddress(empty_pb2.Empty()).address
self.cert_device.address = cert_address
self.dut_connection_complete_stream = self.device_under_test.hci.connection_complete_stream
diff --git a/gd/hci/facade.cc b/gd/hci/facade.cc
index b817ea667..3bfc1ed91 100644
--- a/gd/hci/facade.cc
+++ b/gd/hci/facade.cc
@@ -51,13 +51,6 @@ class AclManagerFacadeService : public AclManagerFacade::Service, public ::bluet
using EventStream = ::bluetooth::grpc::GrpcEventStream<AclData, AclPacketView>;
- ::grpc::Status ReadLocalAddress(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
- ::bluetooth::facade::BluetoothAddress* response) override {
- auto address = controller_->GetControllerMacAddress().ToString();
- response->set_address(address);
- return ::grpc::Status::OK;
- }
-
::grpc::Status SetPageScanMode(::grpc::ServerContext* context, const ::bluetooth::hci::PageScanMode* request,
::google::protobuf::Empty* response) override {
ScanEnable scan_enable = request->enabled() ? ScanEnable::PAGE_SCAN_ONLY : ScanEnable::NO_SCANS;
diff --git a/gd/hci/facade.proto b/gd/hci/facade.proto
index 8ae211426..786884afd 100644
--- a/gd/hci/facade.proto
+++ b/gd/hci/facade.proto
@@ -6,7 +6,6 @@ import "google/protobuf/empty.proto";
import "facade/common.proto";
service AclManagerFacade {
- rpc ReadLocalAddress(google.protobuf.Empty) returns (facade.BluetoothAddress) {}
rpc SetPageScanMode(PageScanMode) returns (google.protobuf.Empty) {}
rpc Connect(facade.BluetoothAddress) returns (google.protobuf.Empty) {}
rpc Disconnect(facade.BluetoothAddress) returns (google.protobuf.Empty) {}