diff options
author | 2022-01-10 09:20:33 -0800 | |
---|---|---|
committer | 2022-02-04 22:16:31 +0000 | |
commit | e9bb55a0f74afa5a2544409eefc5239a31b1a1bf (patch) | |
tree | f8997c32e12fb95cafd025e70a3ec94c648798a9 | |
parent | c5167e99e74c5368a05c38bf3e292a3598a12215 (diff) |
Fix local GD cert runner
* Local GD cert test runner stopped working after mobly migration
* Fix it by using p/m/B/system as root instead of gd
* Change namespace strings in every test and facade files
* Move interface protos to blueberry namespaces
Test: system/gd/cert/run --clean
Test: system/gd/cert/run --device
Test: system/gd/cert/run
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines
Tag: #refactor
Change-Id: Ib1bd0b9e2e43264bdb9eb0e5bd8173d2015d87cf
86 files changed, 816 insertions, 792 deletions
diff --git a/system/Android.bp b/system/Android.bp new file mode 100644 index 0000000000..6b06881f7b --- /dev/null +++ b/system/Android.bp @@ -0,0 +1,173 @@ +filegroup { + name: "BlueberryFacadeProto", + srcs: [ + "blueberry/facade/common.proto", + "blueberry/facade/rootservice.proto", + "blueberry/facade/hal/hal_facade.proto", + "blueberry/facade/hci/hci_facade.proto", + "blueberry/facade/hci/acl_manager_facade.proto", + "blueberry/facade/hci/controller_facade.proto", + "blueberry/facade/hci/le_acl_manager_facade.proto", + "blueberry/facade/hci/le_advertising_manager_facade.proto", + "blueberry/facade/hci/le_initiator_address_facade.proto", + "blueberry/facade/hci/le_scanning_manager_facade.proto", + "blueberry/facade/iso/facade.proto", + "blueberry/facade/neighbor/facade.proto", + "blueberry/facade/l2cap/classic/facade.proto", + "blueberry/facade/l2cap/le/facade.proto", + "blueberry/facade/security/facade.proto", + "blueberry/facade/shim/facade.proto", + "blueberry/facade/topshim/facade.proto", + ], +} + +genrule { + name: "BlueberryFacadeGeneratedStub_h", + tools: [ + "aprotoc", + "protoc-gen-grpc-cpp-plugin", + ], + cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)", + srcs: [ + ":BlueberryFacadeProto", + ], + out: [ + "blueberry/facade/common.grpc.pb.h", + "blueberry/facade/common.pb.h", + "blueberry/facade/rootservice.grpc.pb.h", + "blueberry/facade/rootservice.pb.h", + "blueberry/facade/hal/hal_facade.grpc.pb.h", + "blueberry/facade/hal/hal_facade.pb.h", + "blueberry/facade/hci/hci_facade.grpc.pb.h", + "blueberry/facade/hci/hci_facade.pb.h", + "blueberry/facade/hci/acl_manager_facade.grpc.pb.h", + "blueberry/facade/hci/acl_manager_facade.pb.h", + "blueberry/facade/hci/controller_facade.grpc.pb.h", + "blueberry/facade/hci/controller_facade.pb.h", + "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.h", + "blueberry/facade/hci/le_acl_manager_facade.pb.h", + "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.h", + "blueberry/facade/hci/le_advertising_manager_facade.pb.h", + "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.h", + "blueberry/facade/hci/le_initiator_address_facade.pb.h", + "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.h", + "blueberry/facade/hci/le_scanning_manager_facade.pb.h", + "blueberry/facade/iso/facade.grpc.pb.h", + "blueberry/facade/iso/facade.pb.h", + "blueberry/facade/l2cap/classic/facade.grpc.pb.h", + "blueberry/facade/l2cap/classic/facade.pb.h", + "blueberry/facade/l2cap/le/facade.grpc.pb.h", + "blueberry/facade/l2cap/le/facade.pb.h", + "blueberry/facade/neighbor/facade.grpc.pb.h", + "blueberry/facade/neighbor/facade.pb.h", + "blueberry/facade/security/facade.grpc.pb.h", + "blueberry/facade/security/facade.pb.h", + "blueberry/facade/shim/facade.grpc.pb.h", + "blueberry/facade/shim/facade.pb.h", + ], +} + +genrule { + name: "BlueberryFacadeGeneratedStub_cc", + tools: [ + "aprotoc", + "protoc-gen-grpc-cpp-plugin", + ], + cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)", + srcs: [ + ":BlueberryFacadeProto", + ], + out: [ + "blueberry/facade/common.grpc.pb.cc", + "blueberry/facade/common.pb.cc", + "blueberry/facade/rootservice.grpc.pb.cc", + "blueberry/facade/rootservice.pb.cc", + "blueberry/facade/hal/hal_facade.grpc.pb.cc", + "blueberry/facade/hal/hal_facade.pb.cc", + "blueberry/facade/hci/hci_facade.grpc.pb.cc", + "blueberry/facade/hci/hci_facade.pb.cc", + "blueberry/facade/hci/acl_manager_facade.grpc.pb.cc", + "blueberry/facade/hci/acl_manager_facade.pb.cc", + "blueberry/facade/hci/controller_facade.grpc.pb.cc", + "blueberry/facade/hci/controller_facade.pb.cc", + "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.cc", + "blueberry/facade/hci/le_acl_manager_facade.pb.cc", + "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.cc", + "blueberry/facade/hci/le_advertising_manager_facade.pb.cc", + "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.cc", + "blueberry/facade/hci/le_initiator_address_facade.pb.cc", + "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.cc", + "blueberry/facade/hci/le_scanning_manager_facade.pb.cc", + "blueberry/facade/iso/facade.grpc.pb.cc", + "blueberry/facade/iso/facade.pb.cc", + "blueberry/facade/l2cap/classic/facade.grpc.pb.cc", + "blueberry/facade/l2cap/classic/facade.pb.cc", + "blueberry/facade/l2cap/le/facade.grpc.pb.cc", + "blueberry/facade/l2cap/le/facade.pb.cc", + "blueberry/facade/neighbor/facade.grpc.pb.cc", + "blueberry/facade/neighbor/facade.pb.cc", + "blueberry/facade/security/facade.grpc.pb.cc", + "blueberry/facade/security/facade.pb.cc", + "blueberry/facade/shim/facade.grpc.pb.cc", + "blueberry/facade/shim/facade.pb.cc", + ], +} + +genrule { + name: "BlueberryFacadeAndCertGeneratedStub_py", + tools: [ + "aprotoc", + "protoc-gen-grpc-python-plugin", + "soong_zip", + ], + cmd: "mkdir -p $(genDir)/files && " + + "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) $(in) --grpc_out=$(genDir)/files --python_out=$(genDir)/files && " + + "find $(genDir)/files -type d -exec touch {}/__init__.py \\; &&" + + "$(location soong_zip) -C $(genDir)/files -D $(genDir)/files -o $(out)", + srcs: [ + ":BlueberryFacadeProto", + ], + out: ["blueberry_facade_generated_py.zip"], +} + +rust_protobuf { + name: "libbt_facade_proto", + crate_name: "bt_facade_proto", + protos: ["blueberry/facade/common.proto"], + grpc_protos: [ + "blueberry/facade/hci/controller_facade.proto", + "blueberry/facade/hci/hci_facade.proto", + "blueberry/facade/hal/hal_facade.proto", + "blueberry/facade/rootservice.proto", + ], + source_stem: "facade", + host_supported: true, + apex_available: [ + "//apex_available:platform", + "com.android.bluetooth", + ], + min_sdk_version: "30", +} + +rust_protobuf { + name: "libbt_topshim_facade_protobuf", + crate_name: "bt_topshim_facade_protobuf", + source_stem: "topshim_facade", + host_supported: true, + grpc_protos: ["blueberry/facade/topshim/facade.proto"], +} + +genrule { + name: "libbt_topshim_facade_py_proto", + tools: [ + "aprotoc", + "protoc-gen-grpc-python-plugin", + "soong_zip", + ], + cmd: "$(location aprotoc) --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) -Ipackages/modules/Bluetooth/system $(in) --grpc_out=$(genDir) --python_out=$(genDir)", + srcs: ["blueberry/facade/topshim/facade.proto"], + out: [ + "blueberry/facade/topshim/facade_pb2.py", + "blueberry/facade/topshim/facade_pb2_grpc.py" + ], +}
\ No newline at end of file diff --git a/system/gd/Android.mk b/system/Android.mk index dd9bb9aeac..bbd1a3eef4 100644 --- a/system/gd/Android.mk +++ b/system/Android.mk @@ -1,8 +1,12 @@ LOCAL_PATH := $(call my-dir) #LINT.IfChange +LOCAL_bluetooth_project_dir := $(LOCAL_PATH) + LOCAL_cert_test_sources := \ - setup.py + $(call all-named-files-under,*.py,blueberry) \ + $(call all-named-files-under,*.yaml,blueberry) \ + setup.py LOCAL_cert_test_sources := \ $(filter-out gd_cert_venv% venv%, $(LOCAL_cert_test_sources)) LOCAL_cert_test_sources := \ @@ -49,12 +53,13 @@ LOCAL_target_libraries := \ $(TARGET_OUT_SHARED_LIBRARIES)/libgrpc++.so \ $(TARGET_OUT_SHARED_LIBRARIES)/libgrpc_wrap.so \ $(TARGET_OUT_SHARED_LIBRARIES)/libstatslog_bt.so -#LINT.ThenChange(cert/run) +#LINT.ThenChange(gd/cert/run) bluetooth_cert_src_and_bin_zip := \ $(call intermediates-dir-for,PACKAGING,bluetooth_cert_src_and_bin,HOST)/bluetooth_cert_src_and_bin.zip # Assume 64-bit OS +$(bluetooth_cert_src_and_bin_zip): PRIVATE_bluetooth_project_dir := $(LOCAL_bluetooth_project_dir) $(bluetooth_cert_src_and_bin_zip): PRIVATE_cert_test_sources := $(LOCAL_cert_test_sources) $(bluetooth_cert_src_and_bin_zip): PRIVATE_host_executables := $(LOCAL_host_executables) $(bluetooth_cert_src_and_bin_zip): PRIVATE_host_python_extension_libraries := $(LOCAL_host_python_extension_libraries) @@ -65,7 +70,7 @@ $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \ $(LOCAL_host_executables) $(LOCAL_host_libraries) $(LOCAL_host_python_extension_libraries) \ $(LOCAL_target_executables) $(LOCAL_target_libraries) $(hide) $(SOONG_ZIP) -d -o $@ \ - -C packages/modules/Bluetooth/system/gd $(addprefix -f ,$(PRIVATE_cert_test_sources)) \ + -C $(PRIVATE_bluetooth_project_dir) $(addprefix -f ,$(PRIVATE_cert_test_sources)) \ -C $(HOST_OUT_EXECUTABLES) $(addprefix -f ,$(PRIVATE_host_executables)) \ -C $(HOST_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_host_python_extension_libraries)) \ -P lib64 \ @@ -75,28 +80,28 @@ $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \ -C $(TARGET_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_target_libraries)) # TODO: Find a better way to locate output from SOONG genrule() -LOCAL_cert_generated_py_zip := \ - $(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothFacadeAndCertGeneratedStub_py/gen/bluetooth_cert_generated_py.zip +LOCAL_facade_generated_py_zip := \ + $(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/BlueberryFacadeAndCertGeneratedStub_py/gen/blueberry_facade_generated_py.zip bluetooth_cert_tests_py_package_zip := \ $(call intermediates-dir-for,PACKAGING,bluetooth_cert_tests_py_package,HOST)/bluetooth_cert_tests.zip +$(bluetooth_cert_tests_py_package_zip): PRIVATE_bluetooth_project_dir := $(LOCAL_bluetooth_project_dir) $(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_src_and_bin_zip := $(bluetooth_cert_src_and_bin_zip) -$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_generated_py_zip := $(LOCAL_cert_generated_py_zip) +$(bluetooth_cert_tests_py_package_zip): PRIVATE_facade_generated_py_zip := $(LOCAL_facade_generated_py_zip) $(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) \ $(bluetooth_cert_src_and_bin_zip) $(bluetooth_cert_generated_py_zip) @echo "Packaging Bluetooth Cert Tests into $@" @rm -rf $(dir $@)bluetooth_cert_tests @mkdir -p $(dir $@)bluetooth_cert_tests $(hide) unzip -o -q $(PRIVATE_cert_src_and_bin_zip) -d $(dir $@)bluetooth_cert_tests - $(hide) unzip -o -q $(PRIVATE_cert_generated_py_zip) -d $(dir $@)bluetooth_cert_tests - # Make all subdirectory of gd Python pacakages except lib64 and target + $(hide) unzip -o -q $(PRIVATE_facade_generated_py_zip) -d $(dir $@)bluetooth_cert_tests + # Make all subdirectory Python packages except lib64 and target $(hide) for f in `find $(dir $@)bluetooth_cert_tests -type d -name "*" \ -not -path "$(dir $@)bluetooth_cert_tests/target*" \ -not -path "$(dir $@)bluetooth_cert_tests/lib64*"` \ ; do (touch -a $$f/__init__.py) ; done $(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@)bluetooth_cert_tests -D $(dir $@)bluetooth_cert_tests \ - -P blueberry -C packages/modules/Bluetooth/system/blueberry -D packages/modules/Bluetooth/system/blueberry \ -P llvm_binutils -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) \ -f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov \ -f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata \ diff --git a/system/gd/facade/common.proto b/system/blueberry/facade/common.proto index c0215ed9a8..42c6aaa3f7 100644 --- a/system/gd/facade/common.proto +++ b/system/blueberry/facade/common.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package bluetooth.facade; +package blueberry.facade; message Data { bytes payload = 1; diff --git a/system/blueberry/facade/hal/hal_facade.proto b/system/blueberry/facade/hal/hal_facade.proto new file mode 100644 index 0000000000..d09d0e4923 --- /dev/null +++ b/system/blueberry/facade/hal/hal_facade.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package blueberry.facade.hal; + +import "google/protobuf/empty.proto"; +import "blueberry/facade/common.proto"; + +service HciHalFacade { + rpc SendCommand(blueberry.facade.Data) returns (google.protobuf.Empty) {} + rpc StreamEvents(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} + + rpc SendAcl(blueberry.facade.Data) returns (google.protobuf.Empty) {} + rpc StreamAcl(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} + + rpc SendSco(blueberry.facade.Data) returns (google.protobuf.Empty) {} + rpc StreamSco(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} + + rpc SendIso(blueberry.facade.Data) returns (google.protobuf.Empty) {} + rpc StreamIso(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} +} diff --git a/system/gd/hci/facade/acl_manager_facade.proto b/system/blueberry/facade/hci/acl_manager_facade.proto index 890a1836a8..69f408a34d 100644 --- a/system/gd/hci/facade/acl_manager_facade.proto +++ b/system/blueberry/facade/hci/acl_manager_facade.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package bluetooth.hci; +package blueberry.facade.hci; import "google/protobuf/empty.proto"; diff --git a/system/gd/hci/facade/controller_facade.proto b/system/blueberry/facade/hci/controller_facade.proto index 94eb5d888f..5b14afa6b1 100644 --- a/system/gd/hci/facade/controller_facade.proto +++ b/system/blueberry/facade/hci/controller_facade.proto @@ -1,11 +1,12 @@ syntax = "proto3"; -package bluetooth.hci; +package blueberry.facade.hci; import "google/protobuf/empty.proto"; +import "blueberry/facade/common.proto"; service ControllerFacade { - rpc GetMacAddress(google.protobuf.Empty) returns (AddressMsg) {} + rpc GetMacAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddress) {} rpc WriteLocalName(NameMsg) returns (google.protobuf.Empty) {} rpc GetLocalName(google.protobuf.Empty) returns (NameMsg) {} rpc IsSupportedCommand(OpCodeMsg) returns (SupportedMsg) {} @@ -77,10 +78,6 @@ service ControllerFacade { rpc SupportsBlePathLossMonitoring(google.protobuf.Empty) returns (SupportedMsg) {} } -message AddressMsg { - bytes address = 1; -} - message NameMsg { bytes name = 1; } diff --git a/system/blueberry/facade/hci/hci_facade.proto b/system/blueberry/facade/hci/hci_facade.proto new file mode 100644 index 0000000000..253708ce2f --- /dev/null +++ b/system/blueberry/facade/hci/hci_facade.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package blueberry.facade.hci; + +import "google/protobuf/empty.proto"; +import "blueberry/facade/common.proto"; + +service HciFacade { + rpc SendCommand(blueberry.facade.Data) returns (google.protobuf.Empty) {} + + rpc RequestEvent(EventRequest) returns (google.protobuf.Empty) {} + rpc StreamEvents(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} + + rpc RequestLeSubevent(EventRequest) returns (google.protobuf.Empty) {} + rpc StreamLeSubevents(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} + + rpc SendAcl(blueberry.facade.Data) returns (google.protobuf.Empty) {} + rpc StreamAcl(google.protobuf.Empty) returns (stream blueberry.facade.Data) {} +} + +message EventRequest { + uint32 code = 1; +} diff --git a/system/gd/hci/facade/le_acl_manager_facade.proto b/system/blueberry/facade/hci/le_acl_manager_facade.proto index 20bb6c27f4..8eac08a448 100644 --- a/system/gd/hci/facade/le_acl_manager_facade.proto +++ b/system/blueberry/facade/hci/le_acl_manager_facade.proto @@ -1,15 +1,15 @@ syntax = "proto3"; -package bluetooth.hci; +package blueberry.facade.hci; import "google/protobuf/empty.proto"; -import "facade/common.proto"; +import "blueberry/facade/common.proto"; service LeAclManagerFacade { - rpc CreateConnection(bluetooth.facade.BluetoothAddressWithType) returns (stream LeConnectionEvent) {} - rpc CreateBackgroundAndDirectConnection(bluetooth.facade.BluetoothAddressWithType) + rpc CreateConnection(blueberry.facade.BluetoothAddressWithType) returns (stream LeConnectionEvent) {} + rpc CreateBackgroundAndDirectConnection(blueberry.facade.BluetoothAddressWithType) returns (stream LeConnectionEvent) {} - rpc CancelConnection(bluetooth.facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} + rpc CancelConnection(blueberry.facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc Disconnect(LeHandleMsg) returns (google.protobuf.Empty) {} rpc ConnectionCommand(LeConnectionCommandMsg) returns (google.protobuf.Empty) {} rpc SendAclData(LeAclData) returns (google.protobuf.Empty) {} diff --git a/system/gd/hci/facade/le_advertising_manager_facade.proto b/system/blueberry/facade/hci/le_advertising_manager_facade.proto index d76af95b53..9e59ef7afb 100644 --- a/system/gd/hci/facade/le_advertising_manager_facade.proto +++ b/system/blueberry/facade/hci/le_advertising_manager_facade.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package bluetooth.hci.facade; +package blueberry.facade.hci; import "google/protobuf/empty.proto"; -import "facade/common.proto"; +import "blueberry/facade/common.proto"; service LeAdvertisingManagerFacade { rpc CreateAdvertiser(CreateAdvertiserRequest) returns (CreateAdvertiserResponse) {} @@ -62,9 +62,9 @@ message AdvertisingConfig { // Unit: number of Bluetooth slots in 0.125 ms increment int32 interval_max = 5; AdvertisingEventType advertising_type = 6; - bluetooth.facade.BluetoothOwnAddressTypeEnum own_address_type = 7; - bluetooth.facade.BluetoothPeerAddressTypeEnum peer_address_type = 8; - bluetooth.facade.BluetoothAddress peer_address = 9; + blueberry.facade.BluetoothOwnAddressTypeEnum own_address_type = 7; + blueberry.facade.BluetoothPeerAddressTypeEnum peer_address_type = 8; + blueberry.facade.BluetoothAddress peer_address = 9; int32 channel_map = 10; AdvertisingFilterPolicy filter_policy = 11; int32 tx_power = 12; @@ -175,5 +175,5 @@ message AdvertisingCallbackMsg { message AddressMsg { AdvertisingCallbackMsgType message_type = 1; uint32 advertiser_id = 2; - bluetooth.facade.BluetoothAddressWithType address = 3; + blueberry.facade.BluetoothAddressWithType address = 3; } diff --git a/system/gd/hci/facade/le_initiator_address_facade.proto b/system/blueberry/facade/hci/le_initiator_address_facade.proto index 50aeea249f..354e464a1f 100644 --- a/system/gd/hci/facade/le_initiator_address_facade.proto +++ b/system/blueberry/facade/hci/le_initiator_address_facade.proto @@ -1,14 +1,14 @@ syntax = "proto3"; -package bluetooth.hci; +package blueberry.facade.hci; import "google/protobuf/empty.proto"; -import "facade/common.proto"; +import "blueberry/facade/common.proto"; service LeInitiatorAddressFacade { rpc SetPrivacyPolicyForInitiatorAddress(PrivacyPolicy) returns (google.protobuf.Empty) {} - rpc GetCurrentInitiatorAddress(google.protobuf.Empty) returns (bluetooth.facade.BluetoothAddressWithType) {} - rpc GetAnotherAddress(google.protobuf.Empty) returns (bluetooth.facade.BluetoothAddressWithType) {} + rpc GetCurrentInitiatorAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {} + rpc GetAnotherAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {} } enum AddressPolicy { @@ -21,7 +21,7 @@ enum AddressPolicy { message PrivacyPolicy { AddressPolicy address_policy = 1; - facade.BluetoothAddressWithType address_with_type = 2; + blueberry.facade.BluetoothAddressWithType address_with_type = 2; bytes rotation_irk = 3; uint64 minimum_rotation_time = 4; uint64 maximum_rotation_time = 5; diff --git a/system/gd/hci/facade/le_scanning_manager_facade.proto b/system/blueberry/facade/hci/le_scanning_manager_facade.proto index 588ef56831..8d73b1c7d8 100644 --- a/system/gd/hci/facade/le_scanning_manager_facade.proto +++ b/system/blueberry/facade/hci/le_scanning_manager_facade.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package bluetooth.hci.facade; +package blueberry.facade.hci; import "google/protobuf/empty.proto"; diff --git a/system/gd/iso/facade.proto b/system/blueberry/facade/iso/facade.proto index 28f9d27bcd..41b4c1f46e 100644 --- a/system/gd/iso/facade.proto +++ b/system/blueberry/facade/iso/facade.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -package bluetooth.iso; +package blueberry.facade.iso; import "google/protobuf/empty.proto"; -import "facade/common.proto"; service IsoModuleFacade { rpc LeSetCigParameters(LeSetCigParametersRequest) returns (google.protobuf.Empty) {} diff --git a/system/gd/l2cap/classic/facade.proto b/system/blueberry/facade/l2cap/classic/facade.proto index 73c204fa77..1017d507da 100644 --- a/system/gd/l2cap/classic/facade.proto +++ b/system/blueberry/facade/l2cap/classic/facade.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package bluetooth.l2cap.classic; +package blueberry.facade.l2cap.classic; import "google/protobuf/empty.proto"; -import "facade/common.proto"; +import "blueberry/facade/common.proto"; service L2capClassicModuleFacade { rpc FetchConnectionComplete(google.protobuf.Empty) returns (stream ConnectionCompleteEvent) { @@ -22,12 +22,12 @@ service L2capClassicModuleFacade { // Get the buffer size of channel queue end for L2CAP user (how many packets we can buffer // before L2CAP user dequeues. } - rpc InitiateConnectionForSecurity(facade.BluetoothAddress) returns (google.protobuf.Empty) {} + rpc InitiateConnectionForSecurity(blueberry.facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc FetchSecurityConnectionEvents(google.protobuf.Empty) returns (stream LinkSecurityInterfaceCallbackEvent) {} - rpc SecurityLinkEnsureAuthenticated(facade.BluetoothAddress) returns (google.protobuf.Empty) {} - rpc SecurityLinkHold(facade.BluetoothAddress) returns (google.protobuf.Empty) {} - rpc SecurityLinkDisconnect(facade.BluetoothAddress) returns (google.protobuf.Empty) {} - rpc SecurityLinkRelease(facade.BluetoothAddress) returns (google.protobuf.Empty) {} + rpc SecurityLinkEnsureAuthenticated(blueberry.facade.BluetoothAddress) returns (google.protobuf.Empty) {} + rpc SecurityLinkHold(blueberry.facade.BluetoothAddress) returns (google.protobuf.Empty) {} + rpc SecurityLinkDisconnect(blueberry.facade.BluetoothAddress) returns (google.protobuf.Empty) {} + rpc SecurityLinkRelease(blueberry.facade.BluetoothAddress) returns (google.protobuf.Empty) {} } enum LinkSecurityInterfaceCallbackEventType { @@ -40,7 +40,7 @@ enum LinkSecurityInterfaceCallbackEventType { } message LinkSecurityInterfaceCallbackEvent { - facade.BluetoothAddress address = 1; + blueberry.facade.BluetoothAddress address = 1; LinkSecurityInterfaceCallbackEventType event_type = 2; } @@ -49,11 +49,11 @@ message RegisterChannelRequest { } message ConnectionCompleteEvent { - facade.BluetoothAddress remote = 1; + blueberry.facade.BluetoothAddress remote = 1; } message ConnectionCloseEvent { - facade.BluetoothAddress remote = 1; + blueberry.facade.BluetoothAddress remote = 1; uint32 reason = 2; } @@ -64,7 +64,7 @@ enum RetransmissionFlowControlMode { } message OpenChannelRequest { - facade.BluetoothAddress remote = 1; + blueberry.facade.BluetoothAddress remote = 1; uint32 psm = 2; RetransmissionFlowControlMode mode = 3; } @@ -108,7 +108,7 @@ message SetEnableDynamicChannelRequest { } message DynamicChannelPacket { - facade.BluetoothAddress remote = 1; + blueberry.facade.BluetoothAddress remote = 1; uint32 psm = 2; bytes payload = 3; } diff --git a/system/gd/l2cap/le/facade.proto b/system/blueberry/facade/l2cap/le/facade.proto index b9b4841dd0..842fde3a6a 100644 --- a/system/gd/l2cap/le/facade.proto +++ b/system/blueberry/facade/l2cap/le/facade.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package bluetooth.l2cap.le; +package blueberry.facade.l2cap.le; import "google/protobuf/empty.proto"; -import "facade/common.proto"; +import "blueberry/facade/common.proto"; service L2capLeModuleFacade { rpc FetchL2capData(google.protobuf.Empty) returns (stream L2capPacket) {} @@ -31,7 +31,7 @@ message DynamicChannelOpenEvent { } message OpenDynamicChannelRequest { - facade.BluetoothAddressWithType remote = 1; + blueberry.facade.BluetoothAddressWithType remote = 1; uint32 psm = 2; } @@ -40,7 +40,7 @@ message OpenDynamicChannelResponse { } message CloseDynamicChannelRequest { - facade.BluetoothAddressWithType remote = 1; + blueberry.facade.BluetoothAddressWithType remote = 1; uint32 psm = 2; } @@ -59,7 +59,7 @@ message SetEnableDynamicChannelRequest { } message DynamicChannelPacket { - facade.BluetoothAddressWithType remote = 1; + blueberry.facade.BluetoothAddressWithType remote = 1; uint32 psm = 2; bytes payload = 3; } @@ -70,7 +70,7 @@ message SetEnableFixedChannelRequest { } message FixedChannelPacket { - facade.BluetoothAddressWithType remote = 1; + blueberry.facade.BluetoothAddressWithType remote = 1; uint32 cid = 2; bytes payload = 3; } diff --git a/system/gd/neighbor/facade/facade.proto b/system/blueberry/facade/neighbor/facade.proto index a149547e7a..d6aef6bd19 100644 --- a/system/gd/neighbor/facade/facade.proto +++ b/system/blueberry/facade/neighbor/facade.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package bluetooth.neighbor; +package blueberry.facade.neighbor; import "google/protobuf/empty.proto"; diff --git a/system/gd/facade/rootservice.proto b/system/blueberry/facade/rootservice.proto index 6f2efcb1e8..0b9b164218 100644 --- a/system/gd/facade/rootservice.proto +++ b/system/blueberry/facade/rootservice.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package bluetooth.facade; +package blueberry.facade; import "google/protobuf/empty.proto"; -import "facade/common.proto"; +import "blueberry/facade/common.proto"; service RootFacade { rpc StartStack(StartStackRequest) returns (StartStackResponse) {} @@ -30,5 +30,5 @@ message StopStackRequest {} message StopStackResponse {} service ReadOnlyProperty { - rpc ReadLocalAddress(google.protobuf.Empty) returns (facade.BluetoothAddress) {} + rpc ReadLocalAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddress) {} } diff --git a/system/gd/security/facade.proto b/system/blueberry/facade/security/facade.proto index 008fdb632f..abdcd72280 100644 --- a/system/gd/security/facade.proto +++ b/system/blueberry/facade/security/facade.proto @@ -1,20 +1,20 @@ syntax = "proto3"; -package bluetooth.security; +package blueberry.facade.security; import "google/protobuf/empty.proto"; -import "facade/common.proto"; -import "l2cap/classic/facade.proto"; -import "hci/facade/le_initiator_address_facade.proto"; +import "blueberry/facade/common.proto"; +import "blueberry/facade/l2cap/classic/facade.proto"; +import "blueberry/facade/hci/le_initiator_address_facade.proto"; service SecurityModuleFacade { - rpc CreateBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} + rpc CreateBond(blueberry.facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc CreateBondOutOfBand(OobDataBondMessage) returns (google.protobuf.Empty) {} rpc GetOutOfBandData(google.protobuf.Empty) returns (google.protobuf.Empty) {} rpc FetchGetOutOfBandDataEvents(google.protobuf.Empty) returns (stream OobDataBondMessage) {} - rpc CreateBondLe(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} - rpc CancelBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} - rpc RemoveBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} + rpc CreateBondLe(blueberry.facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} + rpc CancelBond(blueberry.facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} + rpc RemoveBond(blueberry.facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc SetIoCapability(IoCapabilityMessage) returns (google.protobuf.Empty) {} rpc SetAuthenticationRequirements(AuthenticationRequirementsMessage) returns (google.protobuf.Empty) {} rpc SetLeIoCapability(LeIoCapabilityMessage) returns (google.protobuf.Empty) {} @@ -34,13 +34,13 @@ service SecurityModuleFacade { } message OobDataMessage { - facade.BluetoothAddressWithType address = 1; + blueberry.facade.BluetoothAddressWithType address = 1; bytes confirmation_value = 2; bytes random_value = 3; } message OobDataBondMessage { - facade.BluetoothAddressWithType address = 1; + blueberry.facade.BluetoothAddressWithType address = 1; OobDataMessage p192_data = 2; OobDataMessage p256_data = 3; } @@ -57,7 +57,7 @@ enum UiMsgType { message UiMsg { UiMsgType message_type = 1; - facade.BluetoothAddressWithType peer = 2; + blueberry.facade.BluetoothAddressWithType peer = 2; uint32 numeric_value = 3; uint32 unique_id = 4; } @@ -71,7 +71,7 @@ enum UiCallbackType { message UiCallbackMsg { UiCallbackType message_type = 1; - facade.BluetoothAddressWithType address = 2; + blueberry.facade.BluetoothAddressWithType address = 2; bool boolean = 3; uint32 numeric_value = 4; uint32 unique_id = 5; @@ -86,7 +86,7 @@ enum BondMsgType { message BondMsg { BondMsgType message_type = 1; - facade.BluetoothAddressWithType peer = 2; + blueberry.facade.BluetoothAddressWithType peer = 2; uint32 reason = 3; } @@ -94,7 +94,7 @@ enum HelperMsgType { DEVICE_DISCONNECTED = 0; } message SecurityHelperMsg { HelperMsgType message_type = 1; - facade.BluetoothAddressWithType peer = 2; + blueberry.facade.BluetoothAddressWithType peer = 2; } enum IoCapabilities { @@ -166,8 +166,8 @@ message OobDataPresentMessage { } message SecurityPolicyMessage { - facade.BluetoothAddressWithType address = 1; - l2cap.classic.ClassicSecurityPolicy policy = 2; + blueberry.facade.BluetoothAddressWithType address = 1; + blueberry.facade.l2cap.classic.ClassicSecurityPolicy policy = 2; } message EnforceSecurityPolicyMsg { @@ -175,5 +175,5 @@ message EnforceSecurityPolicyMsg { } message DisconnectMsg { - facade.BluetoothAddressWithType address = 1; + blueberry.facade.BluetoothAddressWithType address = 1; } diff --git a/system/gd/shim/facade/facade.proto b/system/blueberry/facade/shim/facade.proto index 18c034016f..9d9604b7c9 100644 --- a/system/gd/shim/facade/facade.proto +++ b/system/blueberry/facade/shim/facade.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package bluetooth.shim.facade; +package blueberry.facade.shim; import "google/protobuf/empty.proto"; diff --git a/system/gd/rust/topshim/facade/facade.proto b/system/blueberry/facade/topshim/facade.proto index 94f7eba365..0414b77b44 100644 --- a/system/gd/rust/topshim/facade/facade.proto +++ b/system/blueberry/facade/topshim/facade.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package bluetooth.topshim; +package blueberry.facade.topshim; service AdapterService { rpc FetchEvents(FetchEventsRequest) returns (stream FetchEventsResponse) {} diff --git a/system/blueberry/tests/gd/cert/adb.py b/system/blueberry/tests/gd/cert/adb.py index 10d0110cfa..09d39258a9 100644 --- a/system/blueberry/tests/gd/cert/adb.py +++ b/system/blueberry/tests/gd/cert/adb.py @@ -16,7 +16,6 @@ import encodings import logging -import re import shlex import shutil diff --git a/system/blueberry/tests/gd/cert/captures.py b/system/blueberry/tests/gd/cert/captures.py index d8ae5fe1ab..76f16b3de5 100644 --- a/system/blueberry/tests/gd/cert/captures.py +++ b/system/blueberry/tests/gd/cert/captures.py @@ -22,7 +22,7 @@ from blueberry.tests.gd.cert.capture import Capture from blueberry.tests.gd.cert.matchers import HciMatchers from blueberry.tests.gd.cert.matchers import L2capMatchers from blueberry.tests.gd.cert.matchers import SecurityMatchers -from security.facade_pb2 import UiMsgType +from blueberry.facade.security.facade_pb2 import UiMsgType class HalCaptures(object): diff --git a/system/blueberry/tests/gd/cert/gd_base_test.py b/system/blueberry/tests/gd/cert/gd_base_test.py index da5b943cfc..691aba5a7c 100644 --- a/system/blueberry/tests/gd/cert/gd_base_test.py +++ b/system/blueberry/tests/gd/cert/gd_base_test.py @@ -21,7 +21,7 @@ import traceback import signal import subprocess -from facade import rootservice_pb2 as facade_rootservice +from blueberry.facade import rootservice_pb2 as facade_rootservice from functools import wraps from grpc import RpcError diff --git a/system/blueberry/tests/gd/cert/gd_device.py b/system/blueberry/tests/gd/cert/gd_device.py index 699eaaabfa..297cf52d67 100644 --- a/system/blueberry/tests/gd/cert/gd_device.py +++ b/system/blueberry/tests/gd/cert/gd_device.py @@ -43,21 +43,21 @@ from blueberry.tests.gd.cert.os_utils import is_subprocess_alive from blueberry.tests.gd.cert.os_utils import make_ports_available from blueberry.tests.gd.cert.os_utils import TerminalColor -from facade import rootservice_pb2_grpc as facade_rootservice_pb2_grpc -from hal import hal_facade_pb2_grpc -from hci.facade import hci_facade_pb2_grpc -from hci.facade import acl_manager_facade_pb2_grpc -from hci.facade import controller_facade_pb2_grpc -from hci.facade import le_acl_manager_facade_pb2_grpc -from hci.facade import le_advertising_manager_facade_pb2_grpc -from hci.facade import le_initiator_address_facade_pb2_grpc -from hci.facade import le_scanning_manager_facade_pb2_grpc -from l2cap.classic import facade_pb2_grpc as l2cap_facade_pb2_grpc -from l2cap.le import facade_pb2_grpc as l2cap_le_facade_pb2_grpc -from iso import facade_pb2_grpc as iso_facade_pb2_grpc -from neighbor.facade import facade_pb2_grpc as neighbor_facade_pb2_grpc -from security import facade_pb2_grpc as security_facade_pb2_grpc -from shim.facade import facade_pb2_grpc as shim_facade_pb2_grpc +from blueberry.facade import rootservice_pb2_grpc as facade_rootservice_pb2_grpc +from blueberry.facade.hal import hal_facade_pb2_grpc +from blueberry.facade.hci import hci_facade_pb2_grpc +from blueberry.facade.hci import acl_manager_facade_pb2_grpc +from blueberry.facade.hci import controller_facade_pb2_grpc +from blueberry.facade.hci import le_acl_manager_facade_pb2_grpc +from blueberry.facade.hci import le_advertising_manager_facade_pb2_grpc +from blueberry.facade.hci import le_initiator_address_facade_pb2_grpc +from blueberry.facade.hci import le_scanning_manager_facade_pb2_grpc +from blueberry.facade.l2cap.classic import facade_pb2_grpc as l2cap_facade_pb2_grpc +from blueberry.facade.l2cap.le import facade_pb2_grpc as l2cap_le_facade_pb2_grpc +from blueberry.facade.iso import facade_pb2_grpc as iso_facade_pb2_grpc +from blueberry.facade.neighbor import facade_pb2_grpc as neighbor_facade_pb2_grpc +from blueberry.facade.security import facade_pb2_grpc as security_facade_pb2_grpc +from blueberry.facade.shim import facade_pb2_grpc as shim_facade_pb2_grpc from mobly import utils from mobly.controllers.android_device_lib.adb import AdbError @@ -453,15 +453,18 @@ class GdAndroidDevice(GdDeviceBase): logging.info("Setting up device %s %s" % (self.label, self.serial_number)) asserts.assert_true(self.adb.ensure_root(), "device %s cannot run as root", self.serial_number) self.ensure_verity_disabled() + logging.info("Confirmed that verity is disabled on device %s %s" % (self.label, self.serial_number)) # Try freeing ports and ignore results self.cleanup_port_forwarding() self.sync_device_time() + logging.info("Ports cleaned up and clock is set for device %s %s" % (self.label, self.serial_number)) # Set up port forwarding or reverse or die self.tcp_forward_or_die(self.grpc_port, self.grpc_port) self.tcp_forward_or_die(self.grpc_root_server_port, self.grpc_root_server_port) self.tcp_reverse_or_die(self.signal_port, self.signal_port) + logging.info("Port forwarding done on device %s %s" % (self.label, self.serial_number)) # Push test binaries self.push_or_die(os.path.join(get_gd_root(), "target", "bluetooth_stack_with_facade"), "system/bin") @@ -472,6 +475,7 @@ class GdAndroidDevice(GdDeviceBase): self.push_or_die(os.path.join(get_gd_root(), "target", "libgrpc++.so"), "system/lib64") self.push_or_die(os.path.join(get_gd_root(), "target", "libgrpc_wrap.so"), "system/lib64") self.push_or_die(os.path.join(get_gd_root(), "target", "libstatslog_bt.so"), "system/lib64") + logging.info("Binaries pushed to device %s %s" % (self.label, self.serial_number)) try: self.adb.shell("rm /data/misc/bluetooth/logs/btsnoop_hci.log") @@ -496,8 +500,12 @@ class GdAndroidDevice(GdDeviceBase): except AdbError as error: if ADB_FILE_NOT_EXIST_ERROR not in str(error): logging.error("Error during setup: " + str(error)) + logging.info("Old logs removed from device %s %s" % (self.label, self.serial_number)) + # Ensure Bluetooth is disabled + self.ensure_no_output(self.adb.shell("settings put global ble_scan_always_enabled 0")) self.ensure_no_output(self.adb.shell("svc bluetooth disable")) + logging.info("Bluetooth disabled on device %s %s" % (self.label, self.serial_number)) # Start logcat logging self.logcat_output_path = os.path.join( @@ -574,7 +582,7 @@ class GdAndroidDevice(GdDeviceBase): except AdbError as error: msg = PORT_FORWARDING_ERROR_MSG_PREFIX + str(error) if "not found" in msg: - logging.info(msg) + logging.debug(msg) else: logging.error(msg) @@ -583,7 +591,7 @@ class GdAndroidDevice(GdDeviceBase): except AdbError as error: msg = PORT_FORWARDING_ERROR_MSG_PREFIX + str(error) if "not found" in msg: - logging.info(msg) + logging.debug(msg) else: logging.error(msg) @@ -592,7 +600,7 @@ class GdAndroidDevice(GdDeviceBase): except AdbError as error: msg = PORT_FORWARDING_ERROR_MSG_PREFIX + str(error) if "not found" in msg: - logging.info(msg) + logging.debug(msg) else: logging.error(msg) diff --git a/system/blueberry/tests/gd/cert/logging_client_interceptor.py b/system/blueberry/tests/gd/cert/logging_client_interceptor.py index 5ab7149626..cd48395524 100644 --- a/system/blueberry/tests/gd/cert/logging_client_interceptor.py +++ b/system/blueberry/tests/gd/cert/logging_client_interceptor.py @@ -17,7 +17,7 @@ import grpc import re -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from google.protobuf import text_format diff --git a/system/blueberry/tests/gd/cert/py_acl_manager.py b/system/blueberry/tests/gd/cert/py_acl_manager.py index beecf84d2d..dfdf05e2ac 100644 --- a/system/blueberry/tests/gd/cert/py_acl_manager.py +++ b/system/blueberry/tests/gd/cert/py_acl_manager.py @@ -22,7 +22,7 @@ from blueberry.tests.gd.cert.closable import Closable from blueberry.tests.gd.cert.closable import safeClose from bluetooth_packets_python3 import hci_packets from blueberry.tests.gd.cert.truth import assertThat -from hci.facade import acl_manager_facade_pb2 as acl_manager_facade +from blueberry.facade.hci import acl_manager_facade_pb2 as acl_manager_facade class PyAclManagerAclConnection(IEventStream, Closable): diff --git a/system/blueberry/tests/gd/cert/py_hal.py b/system/blueberry/tests/gd/cert/py_hal.py index 6dca1701b8..73e43db9a8 100644 --- a/system/blueberry/tests/gd/cert/py_hal.py +++ b/system/blueberry/tests/gd/cert/py_hal.py @@ -30,7 +30,6 @@ from bluetooth_packets_python3.hci_packets import BroadcastFlag from bluetooth_packets_python3.hci_packets import PacketBoundaryFlag from bluetooth_packets_python3 import hci_packets from blueberry.tests.gd.cert.matchers import HciMatchers -from bluetooth_packets_python3.hci_packets import FilterDuplicates from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingLegacyParametersBuilder from bluetooth_packets_python3.hci_packets import LegacyAdvertisingProperties from bluetooth_packets_python3.hci_packets import PeerAddressType @@ -41,15 +40,13 @@ from bluetooth_packets_python3.hci_packets import GapDataType from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingDataBuilder from bluetooth_packets_python3.hci_packets import Operation from bluetooth_packets_python3.hci_packets import OwnAddressType -from bluetooth_packets_python3.hci_packets import LeScanningFilterPolicy from bluetooth_packets_python3.hci_packets import Enable from bluetooth_packets_python3.hci_packets import FragmentPreference from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingScanResponseBuilder from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingEnableBuilder -from bluetooth_packets_python3.hci_packets import LeSetExtendedScanEnableBuilder from bluetooth_packets_python3.hci_packets import EnabledSet from bluetooth_packets_python3.hci_packets import OpCode -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common class PyHalAclConnection(IEventStream): diff --git a/system/blueberry/tests/gd/cert/py_hci.py b/system/blueberry/tests/gd/cert/py_hci.py index e1edbc6f0a..682c528871 100644 --- a/system/blueberry/tests/gd/cert/py_hci.py +++ b/system/blueberry/tests/gd/cert/py_hci.py @@ -23,10 +23,9 @@ from blueberry.tests.gd.cert.closable import safeClose from blueberry.tests.gd.cert.captures import HciCaptures from bluetooth_packets_python3 import hci_packets from blueberry.tests.gd.cert.truth import assertThat -from hci.facade import hci_facade_pb2 as hci_facade -from facade import common_pb2 as common +from blueberry.facade.hci import hci_facade_pb2 as hci_facade +from blueberry.facade import common_pb2 as common from blueberry.tests.gd.cert.matchers import HciMatchers -from bluetooth_packets_python3.hci_packets import FilterDuplicates from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingLegacyParametersBuilder from bluetooth_packets_python3.hci_packets import LegacyAdvertisingProperties from bluetooth_packets_python3.hci_packets import PeerAddressType @@ -37,12 +36,10 @@ from bluetooth_packets_python3.hci_packets import GapDataType from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingDataBuilder from bluetooth_packets_python3.hci_packets import Operation from bluetooth_packets_python3.hci_packets import OwnAddressType -from bluetooth_packets_python3.hci_packets import LeScanningFilterPolicy from bluetooth_packets_python3.hci_packets import Enable from bluetooth_packets_python3.hci_packets import FragmentPreference from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingScanResponseBuilder from bluetooth_packets_python3.hci_packets import LeSetExtendedAdvertisingEnableBuilder -from bluetooth_packets_python3.hci_packets import LeSetExtendedScanEnableBuilder from bluetooth_packets_python3.hci_packets import EnabledSet from bluetooth_packets_python3.hci_packets import OpCode from bluetooth_packets_python3.hci_packets import AclBuilder diff --git a/system/blueberry/tests/gd/cert/py_l2cap.py b/system/blueberry/tests/gd/cert/py_l2cap.py index f72e021ae3..bce696599c 100644 --- a/system/blueberry/tests/gd/cert/py_l2cap.py +++ b/system/blueberry/tests/gd/cert/py_l2cap.py @@ -16,10 +16,10 @@ from google.protobuf import empty_pb2 as empty_proto -from l2cap.classic import facade_pb2 as l2cap_facade_pb2 -from l2cap.classic.facade_pb2 import LinkSecurityInterfaceCallbackEventType -from l2cap.le import facade_pb2 as l2cap_le_facade_pb2 -from l2cap.le.facade_pb2 import SecurityLevel +from blueberry.facade.l2cap.classic import facade_pb2 as l2cap_facade_pb2 +from blueberry.facade.l2cap.classic.facade_pb2 import LinkSecurityInterfaceCallbackEventType +from blueberry.facade.l2cap.le import facade_pb2 as l2cap_le_facade_pb2 +from blueberry.facade.l2cap.le.facade_pb2 import SecurityLevel from bluetooth_packets_python3 import hci_packets from bluetooth_packets_python3 import l2cap_packets from blueberry.tests.gd.cert.event_stream import FilteringEventStream @@ -29,7 +29,6 @@ from blueberry.tests.gd.cert.py_hci import PyHci from blueberry.tests.gd.cert.matchers import HciMatchers from blueberry.tests.gd.cert.matchers import L2capMatchers from blueberry.tests.gd.cert.truth import assertThat -from facade import common_pb2 as common class PyL2capChannel(IEventStream): diff --git a/system/blueberry/tests/gd/cert/py_le_acl_manager.py b/system/blueberry/tests/gd/cert/py_le_acl_manager.py index 5162205df1..914ec84629 100644 --- a/system/blueberry/tests/gd/cert/py_le_acl_manager.py +++ b/system/blueberry/tests/gd/cert/py_le_acl_manager.py @@ -24,7 +24,7 @@ from blueberry.tests.gd.cert.closable import safeClose from bluetooth_packets_python3 import hci_packets from blueberry.tests.gd.cert.truth import assertThat from datetime import timedelta -from hci.facade import le_acl_manager_facade_pb2 as le_acl_manager_facade +from blueberry.facade.hci import le_acl_manager_facade_pb2 as le_acl_manager_facade class PyLeAclManagerAclConnection(IEventStream, Closable): diff --git a/system/blueberry/tests/gd/cert/py_le_iso.py b/system/blueberry/tests/gd/cert/py_le_iso.py index 52834ff536..e8825ec011 100644 --- a/system/blueberry/tests/gd/cert/py_le_iso.py +++ b/system/blueberry/tests/gd/cert/py_le_iso.py @@ -16,9 +16,7 @@ import logging -from bluetooth_packets_python3 import hci_packets from blueberry.tests.gd.cert.capture import Capture -from blueberry.tests.gd.cert.captures import SecurityCaptures from blueberry.tests.gd.cert.closable import Closable from blueberry.tests.gd.cert.closable import safeClose from blueberry.tests.gd.cert.event_stream import EventStream, IEventStream @@ -26,9 +24,8 @@ from blueberry.tests.gd.cert.event_stream import FilteringEventStream from blueberry.tests.gd.cert.matchers import IsoMatchers from blueberry.tests.gd.cert.truth import assertThat from datetime import timedelta -from facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from iso import facade_pb2 as iso_facade_pb2 +from blueberry.facade.iso import facade_pb2 as iso_facade_pb2 class CisTestParameters(): diff --git a/system/blueberry/tests/gd/cert/py_le_security.py b/system/blueberry/tests/gd/cert/py_le_security.py index 0f992138c7..ed53592e04 100644 --- a/system/blueberry/tests/gd/cert/py_le_security.py +++ b/system/blueberry/tests/gd/cert/py_le_security.py @@ -24,15 +24,9 @@ from blueberry.tests.gd.cert.event_stream import EventStream from blueberry.tests.gd.cert.matchers import SecurityMatchers from blueberry.tests.gd.cert.truth import assertThat from datetime import timedelta -from facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from security.facade_pb2 import IoCapabilityMessage -from security.facade_pb2 import AuthenticationRequirementsMessage -from security.facade_pb2 import LeAuthRequirementsMessage -from security.facade_pb2 import OobDataPresentMessage -from security.facade_pb2 import UiCallbackMsg -from security.facade_pb2 import UiCallbackType -from security.facade_pb2 import HelperMsgType +from blueberry.facade.security.facade_pb2 import LeAuthRequirementsMessage +from blueberry.facade.security.facade_pb2 import HelperMsgType class PyLeSecurity(Closable): diff --git a/system/blueberry/tests/gd/cert/py_neighbor.py b/system/blueberry/tests/gd/cert/py_neighbor.py index 303281c080..ffb1dfa1bc 100644 --- a/system/blueberry/tests/gd/cert/py_neighbor.py +++ b/system/blueberry/tests/gd/cert/py_neighbor.py @@ -21,8 +21,8 @@ from blueberry.tests.gd.cert.closable import Closable from blueberry.tests.gd.cert.closable import safeClose from blueberry.tests.gd.cert.truth import assertThat from google.protobuf import empty_pb2 as empty_proto -from hci.facade import hci_facade_pb2 as hci_facade -from neighbor.facade import facade_pb2 as neighbor_facade +from blueberry.facade.hci import hci_facade_pb2 as hci_facade +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade class InquirySession(Closable, IEventStream): diff --git a/system/blueberry/tests/gd/cert/py_security.py b/system/blueberry/tests/gd/cert/py_security.py index 53e8d9755d..e8f62a80e5 100644 --- a/system/blueberry/tests/gd/cert/py_security.py +++ b/system/blueberry/tests/gd/cert/py_security.py @@ -16,26 +16,23 @@ import logging -from bluetooth_packets_python3 import hci_packets from blueberry.tests.gd.cert.closable import Closable from blueberry.tests.gd.cert.closable import safeClose from blueberry.tests.gd.cert.event_stream import EventStream from blueberry.tests.gd.cert.truth import assertThat -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from security.facade_pb2 import AuthenticationRequirements -from security.facade_pb2 import AuthenticationRequirementsMessage -from security.facade_pb2 import BondMsgType -from security.facade_pb2 import SecurityPolicyMessage -from security.facade_pb2 import IoCapabilities -from security.facade_pb2 import IoCapabilityMessage -from security.facade_pb2 import OobDataBondMessage -from security.facade_pb2 import OobDataMessage -from security.facade_pb2 import OobDataPresentMessage -from security.facade_pb2 import UiMsgType -from security.facade_pb2 import UiCallbackMsg -from security.facade_pb2 import UiCallbackType +from blueberry.facade.security.facade_pb2 import AuthenticationRequirements +from blueberry.facade.security.facade_pb2 import AuthenticationRequirementsMessage +from blueberry.facade.security.facade_pb2 import SecurityPolicyMessage +from blueberry.facade.security.facade_pb2 import IoCapabilities +from blueberry.facade.security.facade_pb2 import IoCapabilityMessage +from blueberry.facade.security.facade_pb2 import OobDataBondMessage +from blueberry.facade.security.facade_pb2 import OobDataMessage +from blueberry.facade.security.facade_pb2 import UiMsgType +from blueberry.facade.security.facade_pb2 import UiCallbackMsg +from blueberry.facade.security.facade_pb2 import UiCallbackType class PySecurity(Closable): diff --git a/system/blueberry/tests/gd/gd_postsubmit_tests.py b/system/blueberry/tests/gd/gd_postsubmit_tests.py index 17c8a6c3ee..41cd09ee56 100644 --- a/system/blueberry/tests/gd/gd_postsubmit_tests.py +++ b/system/blueberry/tests/gd/gd_postsubmit_tests.py @@ -20,7 +20,7 @@ from mobly import suite_runner DISABLED_TESTS = set() -ENABLED_TESTS = list(ALL_TESTS - DISABLED_TESTS) +POSTSUBMIT_TESTS = list(ALL_TESTS - DISABLED_TESTS) if __name__ == '__main__': - suite_runner.run_suite(ENABLED_TESTS) + suite_runner.run_suite(POSTSUBMIT_TESTS) diff --git a/system/blueberry/tests/gd/gd_presubmit_tests.py b/system/blueberry/tests/gd/gd_presubmit_tests.py index 7a2cb7ee60..bbc942c323 100644 --- a/system/blueberry/tests/gd/gd_presubmit_tests.py +++ b/system/blueberry/tests/gd/gd_presubmit_tests.py @@ -19,23 +19,23 @@ from blueberry.tests.gd.gd_all_tests import ALL_TESTS from mobly import suite_runner # TODO(b/194723246): Investigate failures to re-activate the test class. -from blueberry.tests.gd.hci.le_scanning_manager_test_blueberry import LeScanningManagerTest +from blueberry.tests.gd.hci.le_scanning_manager_test import LeScanningManagerTest # TODO(b/194723246): Investigate failures to re-activate the test class. -from blueberry.tests.gd.l2cap.classic.l2cap_test_blueberry import L2capTest +from blueberry.tests.gd.l2cap.classic.l2cap_test import L2capTest # TODO(b/194723246): Investigate failures to re-activate the test class. -from blueberry.tests.gd.l2cap.le.le_l2cap_test_blueberry import LeL2capTest +from blueberry.tests.gd.l2cap.le.le_l2cap_test import LeL2capTest # TODO(b/194723246): Investigate failures to re-activate the test class. -from blueberry.tests.gd.security.le_security_test_blueberry import LeSecurityTest +from blueberry.tests.gd.security.le_security_test import LeSecurityTest # TODO(b/194723246): Investigate failures to re-activate the test class. -from blueberry.tests.gd.security.security_test_blueberry import SecurityTest +from blueberry.tests.gd.security.security_test import SecurityTest DISABLED_TESTS = {LeScanningManagerTest, L2capTest, LeL2capTest, LeSecurityTest, SecurityTest} -ENABLED_TESTS = list(ALL_TESTS - DISABLED_TESTS) +PRESUBMIT_TESTS = list(ALL_TESTS - DISABLED_TESTS) if __name__ == '__main__': - suite_runner.run_suite(ENABLED_TESTS) + suite_runner.run_suite(PRESUBMIT_TESTS) diff --git a/system/blueberry/tests/gd/gd_test_runner.py b/system/blueberry/tests/gd/gd_test_runner.py new file mode 100644 index 0000000000..cc2a1d2336 --- /dev/null +++ b/system/blueberry/tests/gd/gd_test_runner.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# +# Copyright 2021 - 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. + +from blueberry.tests.gd.gd_all_tests import ALL_TESTS +from blueberry.tests.gd.gd_presubmit_tests import PRESUBMIT_TESTS +from blueberry.tests.gd.gd_postsubmit_tests import POSTSUBMIT_TESTS + +from mobly import suite_runner +import sys +import argparse +import pathlib + +DISABLED_TESTS = set() + +ENABLED_TESTS = list(ALL_TESTS - DISABLED_TESTS) + + +def main(): + """ + Local test runner that allows to specify list of tests to and customize + test config file location + """ + parser = argparse.ArgumentParser(description="Run local GD cert tests.") + parser.add_argument( + '-c', '--config', type=str, required=True, metavar='<PATH>', help='Path to the test configuration file.') + parser.add_argument( + '--tests', + '--test_case', + nargs='+', + type=str, + metavar='[ClassA[.test_a] ClassB[.test_b] ...]', + help='A list of test classes and optional tests to execute.') + parser.add_argument("--all_tests", "-A", type=bool, dest="all_tests", default=False, nargs="?") + parser.add_argument("--presubmit", type=bool, dest="presubmit", default=False, nargs="?") + parser.add_argument("--postsubmit", type=bool, dest="postsubmit", default=False, nargs="?") + args = parser.parse_args() + test_list = ALL_TESTS + if args.all_tests: + test_list = ALL_TESTS + elif args.presubmit: + test_list = PRESUBMIT_TESTS + elif args.postsubmit: + test_list = POSTSUBMIT_TESTS + # Do not pass this layer's cmd line argument to next layer + argv = ["--config", args.config] + if args.tests: + argv.append("--tests") + for test in args.tests: + argv.append(test) + + suite_runner.run_suite(test_list, argv=argv) + + +if __name__ == "__main__": + main() diff --git a/system/blueberry/tests/gd/hci/acl_manager_test.py b/system/blueberry/tests/gd/hci/acl_manager_test.py index 710880dfc7..e989127d98 100644 --- a/system/blueberry/tests/gd/hci/acl_manager_test.py +++ b/system/blueberry/tests/gd/hci/acl_manager_test.py @@ -20,7 +20,7 @@ from blueberry.tests.gd.cert.py_acl_manager import PyAclManager from blueberry.tests.gd.cert.truth import assertThat from bluetooth_packets_python3 import hci_packets from datetime import timedelta -from neighbor.facade import facade_pb2 as neighbor_facade +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade from mobly import test_runner diff --git a/system/blueberry/tests/gd/hci/controller_test.py b/system/blueberry/tests/gd/hci/controller_test.py index eb31ededa2..88a6b647eb 100644 --- a/system/blueberry/tests/gd/hci/controller_test.py +++ b/system/blueberry/tests/gd/hci/controller_test.py @@ -20,7 +20,7 @@ from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.cert.truth import assertThat from bluetooth_packets_python3 import hci_packets from google.protobuf import empty_pb2 as empty_proto -from hci.facade import controller_facade_pb2 as controller_facade +from blueberry.facade.hci import controller_facade_pb2 as controller_facade from mobly import test_runner diff --git a/system/blueberry/tests/gd/hci/direct_hci_test.py b/system/blueberry/tests/gd/hci/direct_hci_test.py index f1d9758d90..a88defa33a 100644 --- a/system/blueberry/tests/gd/hci/direct_hci_test.py +++ b/system/blueberry/tests/gd/hci/direct_hci_test.py @@ -22,7 +22,7 @@ from blueberry.tests.gd.cert.py_hal import PyHal from blueberry.tests.gd.cert.py_hci import PyHci from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from bluetooth_packets_python3.hci_packets import EventCode from bluetooth_packets_python3.hci_packets import LoopbackMode from bluetooth_packets_python3.hci_packets import WriteLoopbackModeBuilder diff --git a/system/blueberry/tests/gd/hci/le_acl_manager_test.py b/system/blueberry/tests/gd/hci/le_acl_manager_test.py index c90fb821ec..34ef228e72 100644 --- a/system/blueberry/tests/gd/hci/le_acl_manager_test.py +++ b/system/blueberry/tests/gd/hci/le_acl_manager_test.py @@ -20,11 +20,11 @@ from blueberry.tests.gd.cert.event_stream import EventStream from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert.py_le_acl_manager import PyLeAclManager from google.protobuf import empty_pb2 as empty_proto -from facade import common_pb2 as common -from hci.facade import le_acl_manager_facade_pb2 as le_acl_manager_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from hci.facade import hci_facade_pb2 as hci_facade +from blueberry.facade import common_pb2 as common +from blueberry.facade.hci import le_acl_manager_facade_pb2 as le_acl_manager_facade +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.hci import hci_facade_pb2 as hci_facade import bluetooth_packets_python3 as bt_packets from bluetooth_packets_python3 import hci_packets from bluetooth_packets_python3 import RawBuilder diff --git a/system/blueberry/tests/gd/hci/le_advertising_manager_test.py b/system/blueberry/tests/gd/hci/le_advertising_manager_test.py index 7ee64b41c9..2e2500ede0 100644 --- a/system/blueberry/tests/gd/hci/le_advertising_manager_test.py +++ b/system/blueberry/tests/gd/hci/le_advertising_manager_test.py @@ -23,13 +23,13 @@ from blueberry.tests.gd.cert.matchers import AdvertisingMatchers from blueberry.tests.gd.cert.py_hci import PyHci from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from hci.facade import \ +from blueberry.facade.hci import \ le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from hci.facade.le_advertising_manager_facade_pb2 import AdvertisingCallbackMsgType -from hci.facade.le_advertising_manager_facade_pb2 import AdvertisingStatus +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.hci.le_advertising_manager_facade_pb2 import AdvertisingCallbackMsgType +from blueberry.facade.hci.le_advertising_manager_facade_pb2 import AdvertisingStatus from mobly import test_runner diff --git a/system/blueberry/tests/gd/hci/le_scanning_manager_test.py b/system/blueberry/tests/gd/hci/le_scanning_manager_test.py index 6aa10b284e..faf3ba2520 100644 --- a/system/blueberry/tests/gd/hci/le_scanning_manager_test.py +++ b/system/blueberry/tests/gd/hci/le_scanning_manager_test.py @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import sys import logging from bluetooth_packets_python3 import hci_packets @@ -24,15 +22,15 @@ from blueberry.tests.gd.cert.event_stream import EventStream from blueberry.tests.gd.cert.matchers import ScanningMatchers from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test -from facade import common_pb2 as common -from facade import rootservice_pb2 as facade_rootservice +from blueberry.facade import common_pb2 as common +from blueberry.facade import rootservice_pb2 as facade_rootservice from google.protobuf import empty_pb2 as empty_proto -from hci.facade import hci_facade_pb2 as hci_facade -from hci.facade import le_scanning_manager_facade_pb2 as le_scanning_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from hci.facade.le_scanning_manager_facade_pb2 import ScanningCallbackMsgType -from hci.facade.le_scanning_manager_facade_pb2 import ScanningStatus +from blueberry.facade.hci import hci_facade_pb2 as hci_facade +from blueberry.facade.hci import le_scanning_manager_facade_pb2 as le_scanning_facade +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.hci.le_scanning_manager_facade_pb2 import ScanningCallbackMsgType +from blueberry.facade.hci.le_scanning_manager_facade_pb2 import ScanningStatus from mobly import test_runner diff --git a/system/blueberry/tests/gd/hci/le_scanning_with_security_test.py b/system/blueberry/tests/gd/hci/le_scanning_with_security_test.py index 85fc5ef448..77e911d0c9 100644 --- a/system/blueberry/tests/gd/hci/le_scanning_with_security_test.py +++ b/system/blueberry/tests/gd/hci/le_scanning_with_security_test.py @@ -18,12 +18,12 @@ from blueberry.tests.gd.cert.event_stream import EventStream from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test from google.protobuf import empty_pb2 as empty_proto -from hci.facade import hci_facade_pb2 as hci_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from hci.facade import le_scanning_manager_facade_pb2 as le_scanning_facade +from blueberry.facade.hci import hci_facade_pb2 as hci_facade +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.hci import le_scanning_manager_facade_pb2 as le_scanning_facade from bluetooth_packets_python3 import hci_packets -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from mobly import test_runner diff --git a/system/blueberry/tests/gd/iso/cert_le_iso.py b/system/blueberry/tests/gd/iso/cert_le_iso.py index 28afe1e933..ee478e61e4 100644 --- a/system/blueberry/tests/gd/iso/cert_le_iso.py +++ b/system/blueberry/tests/gd/iso/cert_le_iso.py @@ -17,10 +17,7 @@ import logging from blueberry.tests.gd.cert.closable import Closable -from blueberry.tests.gd.cert.closable import safeClose from blueberry.tests.gd.cert.py_le_iso import PyLeIso -import bluetooth_packets_python3 as bt_packets -from bluetooth_packets_python3 import l2cap_packets class CertLeIso(Closable): diff --git a/system/blueberry/tests/gd/iso/le_iso_test.py b/system/blueberry/tests/gd/iso/le_iso_test.py index 55fbec7083..dda9d804a0 100644 --- a/system/blueberry/tests/gd/iso/le_iso_test.py +++ b/system/blueberry/tests/gd/iso/le_iso_test.py @@ -14,10 +14,8 @@ # limitations under the License. from bluetooth_packets_python3 import hci_packets -from blueberry.tests.gd.cert.event_stream import EventStream -from blueberry.tests.gd.cert.matchers import HciMatchers, IsoMatchers, L2capMatchers +from blueberry.tests.gd.cert.matchers import IsoMatchers from blueberry.tests.gd.cert.metadata import metadata -from blueberry.tests.gd.cert.py_hci import PyHci from blueberry.tests.gd.cert.py_l2cap import PyLeL2cap from blueberry.tests.gd.cert.py_le_iso import PyLeIso from blueberry.tests.gd.cert.py_le_iso import CisTestParameters @@ -25,10 +23,10 @@ from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.iso.cert_le_iso import CertLeIso from blueberry.tests.gd.l2cap.le.cert_le_l2cap import CertLeL2cap -from facade import common_pb2 as common -from hci.facade import controller_facade_pb2 as controller_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade import common_pb2 as common +from blueberry.facade.hci import controller_facade_pb2 as controller_facade +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade from mobly import asserts from mobly import test_runner diff --git a/system/blueberry/tests/gd/l2cap/classic/l2cap_performance_test.py b/system/blueberry/tests/gd/l2cap/classic/l2cap_performance_test.py index cc9a247068..681c5b9db1 100644 --- a/system/blueberry/tests/gd/l2cap/classic/l2cap_performance_test.py +++ b/system/blueberry/tests/gd/l2cap/classic/l2cap_performance_test.py @@ -21,7 +21,7 @@ from blueberry.tests.gd.cert.performance_test_logger import PerformanceTestLogge from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.l2cap.classic.cert_l2cap import CertL2cap from blueberry.tests.gd.l2cap.classic.l2cap_test import L2capTestBase -from l2cap.classic.facade_pb2 import RetransmissionFlowControlMode +from blueberry.facade.l2cap.classic.facade_pb2 import RetransmissionFlowControlMode from bluetooth_packets_python3 import RawBuilder from bluetooth_packets_python3.l2cap_packets import FcsType from bluetooth_packets_python3.l2cap_packets import SupervisoryFunction diff --git a/system/blueberry/tests/gd/l2cap/classic/l2cap_test.py b/system/blueberry/tests/gd/l2cap/classic/l2cap_test.py index ccc6fb82cc..acb12e76a3 100644 --- a/system/blueberry/tests/gd/l2cap/classic/l2cap_test.py +++ b/system/blueberry/tests/gd/l2cap/classic/l2cap_test.py @@ -30,10 +30,10 @@ from blueberry.tests.gd.cert.py_l2cap import PyL2cap from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.l2cap.classic.cert_l2cap import CertL2cap -from facade import common_pb2 +from blueberry.facade import common_pb2 from google.protobuf import empty_pb2 as empty_proto -from l2cap.classic.facade_pb2 import RetransmissionFlowControlMode -from neighbor.facade import facade_pb2 as neighbor_facade +from blueberry.facade.l2cap.classic.facade_pb2 import RetransmissionFlowControlMode +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade from mobly import asserts from mobly import test_runner diff --git a/system/blueberry/tests/gd/l2cap/classic/pts_l2cap_test.py b/system/blueberry/tests/gd/l2cap/classic/pts_l2cap_test.py index f71e3f1799..e0bf516d42 100644 --- a/system/blueberry/tests/gd/l2cap/classic/pts_l2cap_test.py +++ b/system/blueberry/tests/gd/l2cap/classic/pts_l2cap_test.py @@ -13,16 +13,17 @@ # 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. + from datetime import timedelta import time from blueberry.tests.gd.cert.pts_base_test import PTSBaseTestClass from blueberry.tests.gd.cert.event_stream import EventStream -from facade import common_pb2 -from facade import rootservice_pb2 as facade_rootservice_pb2 -from l2cap.classic import facade_pb2 as l2cap_facade_pb2 +from blueberry.facade import common_pb2 +from blueberry.facade import rootservice_pb2 as facade_rootservice_pb2 +from blueberry.facade.l2cap.classic import facade_pb2 as l2cap_facade_pb2 from google.protobuf import empty_pb2 -from neighbor.facade import facade_pb2 as neighbor_facade +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade class PTSL2capTest(PTSBaseTestClass): diff --git a/system/blueberry/tests/gd/l2cap/le/cert_le_l2cap.py b/system/blueberry/tests/gd/l2cap/le/cert_le_l2cap.py index 29652f28f5..36139f62d4 100644 --- a/system/blueberry/tests/gd/l2cap/le/cert_le_l2cap.py +++ b/system/blueberry/tests/gd/l2cap/le/cert_le_l2cap.py @@ -26,7 +26,6 @@ import bluetooth_packets_python3 as bt_packets from bluetooth_packets_python3 import l2cap_packets from bluetooth_packets_python3.l2cap_packets import LeCommandCode from bluetooth_packets_python3.l2cap_packets import LeCreditBasedConnectionResponseResult -from mobly import asserts class CertLeL2capChannel(IEventStream): diff --git a/system/blueberry/tests/gd/l2cap/le/dual_l2cap_test.py b/system/blueberry/tests/gd/l2cap/le/dual_l2cap_test.py index ee30a983c1..b9b172af63 100644 --- a/system/blueberry/tests/gd/l2cap/le/dual_l2cap_test.py +++ b/system/blueberry/tests/gd/l2cap/le/dual_l2cap_test.py @@ -22,12 +22,12 @@ from blueberry.tests.gd.cert.metadata import metadata from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.l2cap.classic.cert_l2cap import CertL2cap from blueberry.tests.gd.l2cap.le.cert_le_l2cap import CertLeL2cap -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from hci.facade import le_acl_manager_facade_pb2 as le_acl_manager_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from neighbor.facade import facade_pb2 as neighbor_facade +from blueberry.facade.hci import le_acl_manager_facade_pb2 as le_acl_manager_facade +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade from mobly import test_runner # Assemble a sample packet. diff --git a/system/blueberry/tests/gd/l2cap/le/le_l2cap_test.py b/system/blueberry/tests/gd/l2cap/le/le_l2cap_test.py index 8ccad1e2c3..95b67e8a3b 100644 --- a/system/blueberry/tests/gd/l2cap/le/le_l2cap_test.py +++ b/system/blueberry/tests/gd/l2cap/le/le_l2cap_test.py @@ -22,12 +22,12 @@ from blueberry.tests.gd.cert.matchers import L2capMatchers from blueberry.tests.gd.cert.metadata import metadata from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.l2cap.le.cert_le_l2cap import CertLeL2cap -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from hci.facade import le_acl_manager_facade_pb2 as le_acl_manager_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from l2cap.le.facade_pb2 import SecurityLevel +from blueberry.facade.hci import le_acl_manager_facade_pb2 as le_acl_manager_facade +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.l2cap.le.facade_pb2 import SecurityLevel from mobly import test_runner # Assemble a sample packet. diff --git a/system/blueberry/tests/gd/neighbor/neighbor_test.py b/system/blueberry/tests/gd/neighbor/neighbor_test.py index 3b1606053c..46fcad8cfc 100644 --- a/system/blueberry/tests/gd/neighbor/neighbor_test.py +++ b/system/blueberry/tests/gd/neighbor/neighbor_test.py @@ -18,7 +18,7 @@ from blueberry.tests.gd.cert.matchers import HciMatchers, NeighborMatchers from blueberry.tests.gd.cert.py_hci import PyHci from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert.py_neighbor import PyNeighbor -from neighbor.facade import facade_pb2 as neighbor_facade +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade from bluetooth_packets_python3 import hci_packets from bluetooth_packets_python3.hci_packets import OpCode from blueberry.tests.gd.cert import gd_base_test diff --git a/system/blueberry/tests/gd/rust/topshim/facade/automation_helper.py b/system/blueberry/tests/gd/rust/topshim/facade/automation_helper.py index 8b0f73e02f..224dffb32a 100644 --- a/system/blueberry/tests/gd/rust/topshim/facade/automation_helper.py +++ b/system/blueberry/tests/gd/rust/topshim/facade/automation_helper.py @@ -17,8 +17,8 @@ import asyncio import grpc -from rust.topshim.facade import facade_pb2 -from rust.topshim.facade import facade_pb2_grpc +from blueberry.facade.topshim import facade_pb2 +from blueberry.facade.topshim import facade_pb2_grpc class AdapterAutomationHelper(): diff --git a/system/blueberry/tests/gd/rust_devices_config.yaml b/system/blueberry/tests/gd/rust_devices_config.yaml new file mode 100644 index 0000000000..9414c52b59 --- /dev/null +++ b/system/blueberry/tests/gd/rust_devices_config.yaml @@ -0,0 +1,44 @@ +_description: Bluetooth cert testing +TestBeds: + - Name: AndroidDeviceCert + Controllers: + GdDevice: + - grpc_port: '8898' + grpc_root_server_port: '8896' + signal_port: '8894' + label: cert + serial_number: 'CERT' + name: Cert Device + cmd: + - "adb" + - "-s" + - "$(serial_number)" + - "shell" + - "ASAN_OPTIONS=detect_container_overflow=0" + - "/system/bin/bluetooth_with_facades" + - "--grpc-port=$(grpc_port)" + - "--root-server-port=$(grpc_root_server_port)" + - "--btsnoop=/data/misc/bluetooth/logs/btsnoop_hci.log" + - "--btsnooz=/data/misc/bluetooth/logs/btsnooz_hci.log" + - "--btconfig=/data/misc/bluedroid/bt_config.conf" + - "--signal-port=$(signal_port)" + - grpc_port: '8899' + grpc_root_server_port: '8897' + signal_port: '8895' + label: dut + serial_number: 'DUT' + name: DUT Device + cmd: + - "adb" + - "-s" + - "$(serial_number)" + - "shell" + - "ASAN_OPTIONS=detect_container_overflow=0" + - "/system/bin/bluetooth_with_facades" + - "--grpc-port=$(grpc_port)" + - "--root-server-port=$(grpc_root_server_port)" + - "--btsnoop=/data/misc/bluetooth/logs/btsnoop_hci.log" + - "--btsnooz=/data/misc/bluetooth/logs/btsnooz_hci.log" + - "--btconfig=/data/misc/bluedroid/bt_config.conf" + - "--signal-port=$(signal_port)" +logpath: "/tmp/logs"
\ No newline at end of file diff --git a/system/blueberry/tests/gd/rust_host_config.yaml b/system/blueberry/tests/gd/rust_host_config.yaml new file mode 100644 index 0000000000..527a1d11ce --- /dev/null +++ b/system/blueberry/tests/gd/rust_host_config.yaml @@ -0,0 +1,32 @@ +_description: Bluetooth cert testing +TestBeds: + - Name: HostOnlyCert + Controllers: + rootcanal: + test_port: '6401' + hci_port: '6402' + link_layer_port: '6403' + GdDevice: + - grpc_port: '8998' + grpc_root_server_port: '8996' + signal_port: '8994' + label: cert + name: Cert Device + cmd: + - "$GD_ROOT/bluetooth_with_facades" + - "--grpc-port=$(grpc_port)" + - "--root-server-port=$(grpc_root_server_port)" + - "--rootcanal-port=$(rootcanal_port)" + - "--signal-port=$(signal_port)" + - grpc_port: '8999' + grpc_root_server_port: '8997' + signal_port: '8995' + label: dut + name: DUT Device + cmd: + - "$GD_ROOT/bluetooth_with_facades" + - "--grpc-port=$(grpc_port)" + - "--root-server-port=$(grpc_root_server_port)" + - "--rootcanal-port=$(rootcanal_port)" + - "--signal-port=$(signal_port)" +logpath: "/tmp/logs" diff --git a/system/blueberry/tests/gd/security/cert_security.py b/system/blueberry/tests/gd/security/cert_security.py index 90e469a4f7..0bd79ecf17 100644 --- a/system/blueberry/tests/gd/security/cert_security.py +++ b/system/blueberry/tests/gd/security/cert_security.py @@ -24,12 +24,11 @@ from blueberry.tests.gd.cert.matchers import HciMatchers from blueberry.tests.gd.cert.py_hci import PyHci from blueberry.tests.gd.cert.py_security import PySecurity from blueberry.tests.gd.cert.truth import assertThat -from datetime import datetime from google.protobuf import empty_pb2 as empty_proto -from l2cap.classic import facade_pb2 as l2cap_facade -from security.facade_pb2 import IoCapabilities -from security.facade_pb2 import AuthenticationRequirements -from security.facade_pb2 import OobDataPresent +from blueberry.facade.l2cap.classic import facade_pb2 as l2cap_facade +from blueberry.facade.security.facade_pb2 import IoCapabilities +from blueberry.facade.security.facade_pb2 import AuthenticationRequirements +from blueberry.facade.security.facade_pb2 import OobDataPresent class CertSecurity(PySecurity): diff --git a/system/blueberry/tests/gd/security/le_security_test.py b/system/blueberry/tests/gd/security/le_security_test.py index 570f841429..0c9090b5f2 100644 --- a/system/blueberry/tests/gd/security/le_security_test.py +++ b/system/blueberry/tests/gd/security/le_security_test.py @@ -14,7 +14,6 @@ # limitations under the License. from bluetooth_packets_python3 import hci_packets -from bluetooth_packets_python3.hci_packets import OpCode from bluetooth_packets_python3.security_packets import PairingFailedReason from blueberry.tests.gd.cert.matchers import SecurityMatchers from blueberry.tests.gd.cert.metadata import metadata @@ -23,22 +22,18 @@ from blueberry.tests.gd.cert.py_le_security import PyLeSecurity from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test from datetime import timedelta -from facade import common_pb2 as common -from hci.facade import controller_facade_pb2 as controller_facade -from hci.facade import le_advertising_manager_facade_pb2 as le_advertising_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade import common_pb2 as common +from blueberry.facade.hci import le_advertising_manager_facade_pb2 as le_advertising_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade from google.protobuf import empty_pb2 as empty_proto -from neighbor.facade import facade_pb2 as neighbor_facade -from security.facade_pb2 import AuthenticationRequirements -from security.facade_pb2 import BondMsgType -from security.facade_pb2 import OobDataMessage -from security.facade_pb2 import UiCallbackMsg -from security.facade_pb2 import UiCallbackType -from security.facade_pb2 import UiMsgType -from security.facade_pb2 import LeAuthRequirementsMessage -from security.facade_pb2 import LeIoCapabilityMessage -from security.facade_pb2 import LeOobDataPresentMessage -from security.facade_pb2 import LeMaximumEncryptionKeySizeMessage +from blueberry.facade.security.facade_pb2 import BondMsgType +from blueberry.facade.security.facade_pb2 import OobDataMessage +from blueberry.facade.security.facade_pb2 import UiCallbackMsg +from blueberry.facade.security.facade_pb2 import UiCallbackType +from blueberry.facade.security.facade_pb2 import UiMsgType +from blueberry.facade.security.facade_pb2 import LeIoCapabilityMessage +from blueberry.facade.security.facade_pb2 import LeOobDataPresentMessage +from blueberry.facade.security.facade_pb2 import LeMaximumEncryptionKeySizeMessage from mobly import asserts from mobly import test_runner diff --git a/system/blueberry/tests/gd/security/security_test.py b/system/blueberry/tests/gd/security/security_test.py index 19a6bbd22c..9071e4aedc 100644 --- a/system/blueberry/tests/gd/security/security_test.py +++ b/system/blueberry/tests/gd/security/security_test.py @@ -19,17 +19,17 @@ from blueberry.tests.gd.cert.py_security import PySecurity from blueberry.tests.gd.cert.truth import assertThat from blueberry.tests.gd.cert import gd_base_test from blueberry.tests.gd.security.cert_security import CertSecurity -from facade import common_pb2 as common +from blueberry.facade import common_pb2 as common from google.protobuf import empty_pb2 as empty_proto -from hci.facade import controller_facade_pb2 as controller_facade -from hci.facade import le_initiator_address_facade_pb2 as le_initiator_address_facade -from l2cap.classic.facade_pb2 import ClassicSecurityPolicy -from neighbor.facade import facade_pb2 as neighbor_facade -from security.facade_pb2 import AuthenticationRequirements -from security.facade_pb2 import BondMsgType -from security.facade_pb2 import IoCapabilities -from security.facade_pb2 import OobDataPresent -from security.facade_pb2 import UiMsgType +from blueberry.facade.hci import controller_facade_pb2 as controller_facade +from blueberry.facade.hci import le_initiator_address_facade_pb2 as le_initiator_address_facade +from blueberry.facade.l2cap.classic.facade_pb2 import ClassicSecurityPolicy +from blueberry.facade.neighbor import facade_pb2 as neighbor_facade +from blueberry.facade.security.facade_pb2 import AuthenticationRequirements +from blueberry.facade.security.facade_pb2 import BondMsgType +from blueberry.facade.security.facade_pb2 import IoCapabilities +from blueberry.facade.security.facade_pb2 import OobDataPresent +from blueberry.facade.security.facade_pb2 import UiMsgType from mobly import test_runner diff --git a/system/gd/Android.bp b/system/gd/Android.bp index 12b35d5c6d..cbb475f5fe 100644 --- a/system/gd/Android.bp +++ b/system/gd/Android.bp @@ -249,16 +249,16 @@ cc_binary { ":BluetoothFacade_shim_layer", ], generated_headers: [ - "BluetoothFacadeGeneratedStub_h", + "BlueberryFacadeGeneratedStub_h", "BluetoothGeneratedBundlerSchema_h_bfbs", "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", // Needed here to guarantee that generated zip file is created before // bluetooth_cert_tests.zip is packaged - "BluetoothFacadeAndCertGeneratedStub_py", + "BlueberryFacadeAndCertGeneratedStub_py", ], generated_sources: [ - "BluetoothFacadeGeneratedStub_cc", + "BlueberryFacadeGeneratedStub_cc", ], static_libs: [ "breakpad_client", @@ -727,177 +727,6 @@ genrule { ], } -filegroup { - name: "BluetoothFacadeProto", - srcs: [ - "facade/common.proto", - "facade/rootservice.proto", - "hal/hal_facade.proto", - "hci/facade/hci_facade.proto", - "hci/facade/acl_manager_facade.proto", - "hci/facade/controller_facade.proto", - "hci/facade/le_acl_manager_facade.proto", - "hci/facade/le_advertising_manager_facade.proto", - "hci/facade/le_initiator_address_facade.proto", - "hci/facade/le_scanning_manager_facade.proto", - "iso/facade.proto", - "neighbor/facade/facade.proto", - "l2cap/classic/facade.proto", - "l2cap/le/facade.proto", - "security/facade.proto", - "shim/facade/facade.proto", - ], -} - -genrule { - name: "BluetoothFacadeGeneratedStub_h", - tools: [ - "aprotoc", - "protoc-gen-grpc-cpp-plugin", - ], - cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)", - srcs: [ - ":BluetoothFacadeProto", - ], - out: [ - "facade/common.grpc.pb.h", - "facade/common.pb.h", - "facade/rootservice.grpc.pb.h", - "facade/rootservice.pb.h", - "hal/hal_facade.grpc.pb.h", - "hal/hal_facade.pb.h", - "hci/facade/hci_facade.grpc.pb.h", - "hci/facade/hci_facade.pb.h", - "hci/facade/acl_manager_facade.grpc.pb.h", - "hci/facade/acl_manager_facade.pb.h", - "hci/facade/controller_facade.grpc.pb.h", - "hci/facade/controller_facade.pb.h", - "hci/facade/le_acl_manager_facade.grpc.pb.h", - "hci/facade/le_acl_manager_facade.pb.h", - "hci/facade/le_advertising_manager_facade.grpc.pb.h", - "hci/facade/le_advertising_manager_facade.pb.h", - "hci/facade/le_initiator_address_facade.grpc.pb.h", - "hci/facade/le_initiator_address_facade.pb.h", - "hci/facade/le_scanning_manager_facade.grpc.pb.h", - "hci/facade/le_scanning_manager_facade.pb.h", - "iso/facade.grpc.pb.h", - "iso/facade.pb.h", - "l2cap/classic/facade.grpc.pb.h", - "l2cap/classic/facade.pb.h", - "l2cap/le/facade.grpc.pb.h", - "l2cap/le/facade.pb.h", - "neighbor/facade/facade.grpc.pb.h", - "neighbor/facade/facade.pb.h", - "security/facade.grpc.pb.h", - "security/facade.pb.h", - "shim/facade/facade.grpc.pb.h", - "shim/facade/facade.pb.h", - ], -} - -genrule { - name: "BluetoothFacadeGeneratedStub_cc", - tools: [ - "aprotoc", - "protoc-gen-grpc-cpp-plugin", - ], - cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)", - srcs: [ - ":BluetoothFacadeProto", - ], - out: [ - "facade/common.grpc.pb.cc", - "facade/common.pb.cc", - "facade/rootservice.grpc.pb.cc", - "facade/rootservice.pb.cc", - "hal/hal_facade.grpc.pb.cc", - "hal/hal_facade.pb.cc", - "hci/facade/hci_facade.grpc.pb.cc", - "hci/facade/hci_facade.pb.cc", - "hci/facade/acl_manager_facade.grpc.pb.cc", - "hci/facade/acl_manager_facade.pb.cc", - "hci/facade/controller_facade.grpc.pb.cc", - "hci/facade/controller_facade.pb.cc", - "hci/facade/le_acl_manager_facade.grpc.pb.cc", - "hci/facade/le_acl_manager_facade.pb.cc", - "hci/facade/le_advertising_manager_facade.grpc.pb.cc", - "hci/facade/le_advertising_manager_facade.pb.cc", - "hci/facade/le_initiator_address_facade.grpc.pb.cc", - "hci/facade/le_initiator_address_facade.pb.cc", - "hci/facade/le_scanning_manager_facade.grpc.pb.cc", - "hci/facade/le_scanning_manager_facade.pb.cc", - "iso/facade.grpc.pb.cc", - "iso/facade.pb.cc", - "l2cap/classic/facade.grpc.pb.cc", - "l2cap/classic/facade.pb.cc", - "l2cap/le/facade.grpc.pb.cc", - "l2cap/le/facade.pb.cc", - "neighbor/facade/facade.grpc.pb.cc", - "neighbor/facade/facade.pb.cc", - "security/facade.grpc.pb.cc", - "security/facade.pb.cc", - "shim/facade/facade.grpc.pb.cc", - "shim/facade/facade.pb.cc", - ], -} - -genrule { - name: "BluetoothFacadeAndCertGeneratedStub_py", - tools: [ - "aprotoc", - "protoc-gen-grpc-python-plugin", - "soong_zip", - ], - cmd: "mkdir -p $(genDir)/files && " + - "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd -Ipackages/modules/Bluetooth/system/blueberry/ -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) $(in) --grpc_out=$(genDir)/files --python_out=$(genDir)/files && " + - "touch $(genDir)/files/facade/__init__.py && " + - "touch $(genDir)/files/hal/__init__.py && " + - "touch $(genDir)/files/hci/__init__.py && " + - "touch $(genDir)/files/hci/facade/__init__.py && " + - "touch $(genDir)/files/iso/__init__.py && " + - "touch $(genDir)/files/l2cap/classic/__init__.py && " + - "touch $(genDir)/files/l2cap/le/__init__.py && " + - "touch $(genDir)/files/neighbor/facade/__init__.py && " + - "touch $(genDir)/files/security/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/controllers && " + - "touch $(genDir)/files/blueberry/controllers/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/decorators && " + - "touch $(genDir)/files/blueberry/decorators/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/grpc && " + - "touch $(genDir)/files/blueberry/grpc/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/utils && " + - "touch $(genDir)/files/blueberry/utils/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/cert && " + - "touch $(genDir)/files/blueberry/tests/gd/cert/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/hal && " + - "touch $(genDir)/files/blueberry/tests/gd/hal/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/hci && " + - "touch $(genDir)/files/blueberry/tests/gd/hci/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/iso && " + - "touch $(genDir)/files/blueberry/tests/gd/iso/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/l2cap/classic && " + - "touch $(genDir)/files/blueberry/tests/gd/l2cap/classic/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/l2cap/le && " + - "touch $(genDir)/files/blueberry/tests/gd/l2cap/le/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/neighbor && " + - "touch $(genDir)/files/blueberry/tests/gd/neighbor/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/security && " + - "touch $(genDir)/files/blueberry/tests/gd/security/__init__.py && " + - "mkdir -p $(genDir)/files/blueberry/tests/gd/shim && " + - "touch $(genDir)/files/blueberry/tests/gd/shim/__init__.py && " + - // Bundle topshim proto here for now - "mkdir -p $(genDir)/files/blueberry/tests/gd/rust/topshim/facade && " + - "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) packages/modules/Bluetooth/system/gd/rust/topshim/facade/facade.proto --grpc_out=$(genDir)/files --python_out=$(genDir)/files && " + - "touch $(genDir)/files/blueberry/tests/gd/rust/__init__.py && " + - "touch $(genDir)/files/blueberry/tests/gd/rust/topshim/__init__.py && " + - "touch $(genDir)/files/blueberry/tests/gd/rust/topshim/facade/__init__.py && " + - "$(location soong_zip) -C $(genDir)/files -D $(genDir)/files -o $(out)", - srcs: [ - ":BluetoothFacadeProto", - ], - out: ["bluetooth_cert_generated_py.zip"], -} - cc_defaults { name: "bluetooth_py3_native_extension_defaults", include_dirs: [ @@ -988,22 +817,3 @@ cc_library_host_shared { ], rtti: true, } - -rust_protobuf { - name: "libbt_facade_proto", - crate_name: "bt_facade_proto", - protos: ["facade/common.proto"], - grpc_protos: [ - "hci/facade/controller_facade.proto", - "hci/facade/hci_facade.proto", - "hal/hal_facade.proto", - "facade/rootservice.proto", - ], - source_stem: "facade", - host_supported: true, - apex_available: [ - "//apex_available:platform", - "com.android.bluetooth", - ], - min_sdk_version: "30", -} diff --git a/system/gd/cert/run b/system/gd/cert/run index 13a0f68545..c15d621f86 100755 --- a/system/gd/cert/run +++ b/system/gd/cert/run @@ -77,8 +77,8 @@ CERT_HOST_LOGS="/tmp/logs/HostOnlyCert" CERT_DEVICE_LOGS="TODO: Add this" CERT_TEST_VENV=${ANDROID_BUILD_TOP}/out/dist/bluetooth_venv OUT_TARGET="${ANDROID_BUILD_TOP}/out/target" -TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd/cert/host_config.json" -TEST_FILTER="-tf ${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd/cert/all_cert_testcases" +TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/host_config.yaml" +TEST_FILTER="--presubmit" CPP_BUILD_TARGET="bluetooth_stack_with_facade root-canal bluetooth_packets_python3" RUST_BUILD_TARGET="bluetooth_with_facades root-canal bluetooth_packets_python3 bt_topshim_facade" BUILD_TARGET=$CPP_BUILD_TARGET @@ -90,9 +90,6 @@ SKIP_SOONG_BUILD=false USE_ASHMEM_VENV=true VERBOSE_MODE=false -# Directory for test configs to modify -CONFIG_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - ## Verify devices connected and valid DUT_SERIAL="DUT Not Set" DUT_ADB="DUT Not Set" @@ -155,30 +152,26 @@ function parse_options { shift # past argument ;; --device) - TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd/cert/devices_config.json" - TEST_FILTER="-tf ${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd/cert/real_device_testcases" - RR="$(cat ${TEST_CONFIG}|grep \"CERT\\\|DUT\")" + TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/devices_config.yaml" + RR="$(cat ${TEST_CONFIG}|grep \'CERT\\\|DUT\')" if [ "$RR" != "" ]; then - DUT_SERIAL="$(menu-adb DUT)" - DUT_ADB="adb -s ${DUT_SERIAL}" - DUT_NAME="$(adb devices -l | grep -v "List of device" | grep ${DUT_SERIAL} | awk '{ print $6 }' | cut -d ':' -f 2)" - CERT_SERIAL="$(menu-adb CERT)" - CERT_ADB="adb -s ${CERT_SERIAL}" - CERT_NAME="$(adb devices -l | grep -v "List of device" | grep ${CERT_SERIAL} | awk '{ print $6 }' | cut -d ':' -f 2)" - - if [ "${CERT_SERIAL}" == "${DUT_SERIAL}" ]; then - echo - echo -e "${RED}ERROR: CERT and DUT cannot be the same device, or you only have one device connected!${NOCOLOR}" - echo - exit 1 - fi - - ## Set android devices in config - pushd . - cd "${CONFIG_DIR}" - popd - sed -i "s/\"DUT\"/\"${DUT_SERIAL}\"/g" ${CONFIG_DIR}/devices_config.json - sed -i "s/\"CERT\"/\"${CERT_SERIAL}\"/g" ${CONFIG_DIR}/devices_config.json + DUT_SERIAL="$(menu-adb DUT)" + DUT_ADB="adb -s ${DUT_SERIAL}" + DUT_NAME="$(adb devices -l | grep -v "List of device" | grep ${DUT_SERIAL} | awk '{ print $6 }' | cut -d ':' -f 2)" + CERT_SERIAL="$(menu-adb CERT)" + CERT_ADB="adb -s ${CERT_SERIAL}" + CERT_NAME="$(adb devices -l | grep -v "List of device" | grep ${CERT_SERIAL} | awk '{ print $6 }' | cut -d ':' -f 2)" + + if [ "${CERT_SERIAL}" == "${DUT_SERIAL}" ]; then + echo + echo -e "${RED}ERROR: CERT and DUT cannot be the same device, or you only have one device connected!${NOCOLOR}" + echo + exit 1 + fi + + ## Set android devices in config + sed -i "s/'DUT'/'${DUT_SERIAL}'/g" ${TEST_CONFIG} + sed -i "s/'CERT'/'${CERT_SERIAL}'/g" ${TEST_CONFIG} fi shift # past argument ;; @@ -198,13 +191,13 @@ function parse_options { --rust) BUILD_TARGET=$RUST_BUILD_TARGET export RUST_BACKTRACE=1 - TEST_CONFIG=$ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/rust_android_devices_config.json + TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/rust_devices_config.yaml" shift # past argument ;; --rhost) export RUST_BACKTRACE=1 BUILD_TARGET=$RUST_BUILD_TARGET - TEST_CONFIG=$ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/rust_host_config.json + TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/rust_host_config.yaml" shift # past argument ;; # This will log everything to both log file and stdout @@ -228,10 +221,10 @@ function parse_options { # Set the test filter if [[ -n "$1" ]] ; then - TEST_FILTER="-tc $1" + TEST_FILTER="--tests $1" fi - INSTALL_ARGS="--reuse-acts" + INSTALL_ARGS="--reuse-libraries" if [ "$CLEAN_VENV" == true ] ; then echo -e "${YELLOW}Cleaning up existing virtualenv${NOCOLOR}" rm -rf $CERT_TEST_VENV/* @@ -246,13 +239,13 @@ function parse_options { function soong_build { if [ "$CLEAN_VENV" == true ] ; then - $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"modules-in-a-dir" --dir="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd" dist $BUILD_TARGET -j20 + $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"modules-in-a-dir" --dir="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system" dist $BUILD_TARGET -j20 if [[ $? -ne 0 ]] ; then echo -e "${RED}Failed to build ${BUILD_TARGET}${NOCOLOR}" exit 1 fi else - $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"all-modules" --dir="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd" $BUILD_TARGET -j20 + $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"all-modules" --dir="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system" $BUILD_TARGET -j20 if [[ $? -ne 0 ]] ; then echo -e "${RED}Failed to build ${BUILD_TARGET}${NOCOLOR}" exit 1 @@ -296,7 +289,7 @@ function setup_venv { exit 1 fi - unzip -o -q "${ANDROID_BUILD_TOP}/out/dist/bluetooth_cert_tests.zip" -d "${CERT_TEST_VENV}/acts" + unzip -o -q "${ANDROID_BUILD_TOP}/out/dist/bluetooth_cert_tests.zip" -d "${CERT_TEST_VENV}/sources" if [[ $? -ne 0 ]] ; then echo -e "${RED}Error unzipping bluetooth_cert_tests.zip${NOCOLOR}" exit 1 @@ -309,7 +302,7 @@ function incremental_venv { #LINT.IfChange HOST_BIN="${ANDROID_BUILD_TOP}/out/host/linux-x86/bin" HOST_LIB="${ANDROID_BUILD_TOP}/out/host/linux-x86/lib64" - DEST_DIR="${ANDROID_BUILD_TOP}/out/dist/bluetooth_venv/acts" + DEST_DIR="${ANDROID_BUILD_TOP}/out/dist/bluetooth_venv/sources" DEST_LIB_DIR="${DEST_DIR}/lib64" cp {$HOST_BIN,$DEST_DIR}/bluetooth_stack_with_facade cp {$HOST_BIN,$DEST_DIR}/bluetooth_with_facades @@ -335,23 +328,25 @@ function incremental_venv { cp {$HOST_LIB,$DEST_LIB_DIR}/liblzma.so cp {$HOST_LIB,$DEST_LIB_DIR}/libbacktrace.so - for i in `find ${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd -name "*.py" -type f`; do - cp {${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd,$DEST_DIR}${i#${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/gd} + i="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/setup.py" + cp {${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system,$DEST_DIR}${i#${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system} + for i in `find ${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry -name "*.py" -type f`; do + cp {${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system,$DEST_DIR}${i#${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system} done -#LINT.ThenChange(../Android.mk) +#LINT.ThenChange(../../Android.mk) venv_common } function venv_common { - $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/acts/setup.py" --quiet build --force) + $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/sources/setup.py" --quiet build --force "${INSTALL_ARGS}") if [[ $? -ne 0 ]] ; then echo -e "${RED}Error building GD Python libraries${NOCOLOR}" echo -e "${YELLOW}NOTE:${NOCOLOR} To build external libraries the first time, please add --clean option." exit 1 fi - $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/acts/setup.py" --quiet install --skip-build --force "${INSTALL_ARGS}") + $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/sources/setup.py" --quiet install --skip-build --force "${INSTALL_ARGS}") if [[ $? -ne 0 ]] ; then echo -e "${RED}Error installing GD Python libraries${NOCOLOR}" exit 1 @@ -367,14 +362,13 @@ if [[ $? -ne 0 ]] ; then fi if [ "${VERBOSE_MODE}" == true ] ; then - TEMP_CONFIG=/tmp/temp_acts_config.json + TEMP_CONFIG=/tmp/temp_mobly_config.yaml cat "${TEST_CONFIG}" | "${CERT_TEST_VENV}/bin/python" -c " import sys -import json -from acts import keys -config = json.load(sys.stdin) +import yaml +config = yaml.load(sys.stdin) config['verbose_mode'] = True -print(json.dumps(config)) +print(yaml.dump(config)) " > "${TEMP_CONFIG}" TEST_CONFIG="${TEMP_CONFIG}" if [[ $? -ne 0 ]] ; then @@ -416,10 +410,8 @@ function gotta_go_fast { function run_tests { for n in $(seq "${NUM_REPETITIONS}"); do - $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/bin/act.py" \ - -c "${TEST_CONFIG}" \ - "${TEST_FILTER}" \ - -tp "${CERT_TEST_VENV}"/acts) + $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/sources/blueberry/tests/gd/gd_test_runner.py" \ + "-c ${TEST_CONFIG}" "${TEST_FILTER}") done if [ "${CLEAN_VENV}" != true ] ; then diff --git a/system/gd/cert/rust_android_devices_config.json b/system/gd/cert/rust_android_devices_config.json deleted file mode 100644 index 6d76310ddd..0000000000 --- a/system/gd/cert/rust_android_devices_config.json +++ /dev/null @@ -1,55 +0,0 @@ -{ "_description": "Bluetooth cert testing", - "testbed": - [ - { - "_description": "Two Android devices cert testbed", - "name": "AndroidDeviceCert", - "GdDevice": - [ - { - "grpc_port": "8898", - "grpc_root_server_port": "8896", - "signal_port": "8894", - "label": "cert", - "serial_number": "CERT", - "name": "Cert Device", - "cmd": - [ - "adb", - "-s", - "$(serial_number)", - "shell", - "/system/bin/bluetooth_with_facadas", - "--grpc-port=$(grpc_port)", - "--root-server-port=$(grpc_root_server_port)", - "--btsnoop=/data/misc/bluetooth/logs/btsnoop_hci.log", - "--btconfig=/data/misc/bluedroid/bt_config.conf", - "--signal-port=$(signal_port)" - ] - }, - { - "grpc_port": "8899", - "grpc_root_server_port": "8897", - "signal_port": "8895", - "label": "dut", - "serial_number": "DUT", - "name": "DUT Device", - "cmd": - [ - "adb", - "-s", - "$(serial_number)", - "shell", - "/system/bin/bluetooth_with_facades", - "--grpc-port=$(grpc_port)", - "--root-server-port=$(grpc_root_server_port)", - "--btsnoop=/data/misc/bluetooth/logs/btsnoop_hci.log", - "--btconfig=/data/misc/bluedroid/bt_config.conf", - "--signal-port=$(signal_port)" - ] - } - ] - } - ], - "logpath": "/tmp/logs" -} diff --git a/system/gd/cert/rust_host_config.json b/system/gd/cert/rust_host_config.json deleted file mode 100644 index 2972a53e8d..0000000000 --- a/system/gd/cert/rust_host_config.json +++ /dev/null @@ -1,50 +0,0 @@ - -{ "_description": "Bluetooth cert testing", - "testbed": - [ - { - "_description": "Host only cert testbed", - "name": "HostOnlyCert", - "rootcanal": - { - "test_port": "6401", - "hci_port": "6402", - "link_layer_port": "6403" - }, - "GdDevice": - [ - { - "grpc_port": "8998", - "grpc_root_server_port": "8996", - "signal_port": "8994", - "label": "cert", - "name": "Cert Device", - "cmd": - [ - "$GD_ROOT/bluetooth_with_facades", - "--grpc-port=$(grpc_port)", - "--root-server-port=$(grpc_root_server_port)", - "--rootcanal-port=$(rootcanal_port)", - "--signal-port=$(signal_port)" - ] - }, - { - "grpc_port": "8999", - "grpc_root_server_port": "8997", - "signal_port": "8995", - "label": "dut", - "name": "DUT Device", - "cmd": - [ - "$GD_ROOT/bluetooth_with_facades", - "--grpc-port=$(grpc_port)", - "--root-server-port=$(grpc_root_server_port)", - "--rootcanal-port=$(rootcanal_port)", - "--signal-port=$(signal_port)" - ] - } - ] - } - ], - "logpath": "/tmp/logs" -} diff --git a/system/gd/facade/grpc_root_server.cc b/system/gd/facade/grpc_root_server.cc index 21e98e4251..1a76b0dfe0 100644 --- a/system/gd/facade/grpc_root_server.cc +++ b/system/gd/facade/grpc_root_server.cc @@ -18,8 +18,8 @@ #include <string> +#include "blueberry/facade/rootservice.grpc.pb.h" #include "facade/read_only_property_server.h" -#include "facade/rootservice.grpc.pb.h" #include "grpc/grpc_module.h" #include "hal/facade.h" #include "hci/facade/acl_manager_facade.h" @@ -53,18 +53,19 @@ namespace bluetooth { namespace facade { +using ::blueberry::facade::BluetoothModule; using ::bluetooth::grpc::GrpcModule; using ::bluetooth::os::Thread; namespace { -class RootFacadeService : public ::bluetooth::facade::RootFacade::Service { +class RootFacadeService : public ::blueberry::facade::RootFacade::Service { public: RootFacadeService(int grpc_port) : grpc_port_(grpc_port) {} ::grpc::Status StartStack( ::grpc::ServerContext* context, - const ::bluetooth::facade::StartStackRequest* request, - ::bluetooth::facade::StartStackResponse* response) override { + const ::blueberry::facade::StartStackRequest* request, + ::blueberry::facade::StartStackResponse* response) override { if (is_running_) { return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "stack is running"); } @@ -136,8 +137,8 @@ class RootFacadeService : public ::bluetooth::facade::RootFacade::Service { ::grpc::Status StopStack( ::grpc::ServerContext* context, - const ::bluetooth::facade::StopStackRequest* request, - ::bluetooth::facade::StopStackResponse* response) override { + const ::blueberry::facade::StopStackRequest* request, + ::blueberry::facade::StopStackResponse* response) override { if (!is_running_) { return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "stack is not running"); } diff --git a/system/gd/facade/read_only_property_server.cc b/system/gd/facade/read_only_property_server.cc index 182e5e7907..6c3e262ff3 100644 --- a/system/gd/facade/read_only_property_server.cc +++ b/system/gd/facade/read_only_property_server.cc @@ -21,13 +21,13 @@ namespace bluetooth { namespace facade { -class ReadOnlyPropertyService : public ReadOnlyProperty::Service { +class ReadOnlyPropertyService : public blueberry::facade::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 { + ::blueberry::facade::BluetoothAddress* response) override { auto address = controller_->GetMacAddress().ToString(); response->set_address(address); return ::grpc::Status::OK; diff --git a/system/gd/facade/read_only_property_server.h b/system/gd/facade/read_only_property_server.h index 55faec17b3..4345cf1aa1 100644 --- a/system/gd/facade/read_only_property_server.h +++ b/system/gd/facade/read_only_property_server.h @@ -20,7 +20,7 @@ #include <memory> -#include "facade/rootservice.grpc.pb.h" +#include "blueberry/facade/rootservice.grpc.pb.h" #include "grpc/grpc_module.h" namespace bluetooth { diff --git a/system/gd/grpc/grpc_event_queue.h b/system/gd/grpc/grpc_event_queue.h index 089c3d02e6..ffacb14700 100644 --- a/system/gd/grpc/grpc_event_queue.h +++ b/system/gd/grpc/grpc_event_queue.h @@ -22,8 +22,8 @@ #include <chrono> #include <utility> +#include "blueberry/facade/common.pb.h" #include "common/blocking_queue.h" -#include "facade/common.pb.h" #include "os/log.h" namespace bluetooth { diff --git a/system/gd/hal/facade.cc b/system/gd/hal/facade.cc index d33a834922..1e967ce734 100644 --- a/system/gd/hal/facade.cc +++ b/system/gd/hal/facade.cc @@ -19,8 +19,8 @@ #include <memory> #include <mutex> +#include "blueberry/facade/hal/hal_facade.grpc.pb.h" #include "grpc/grpc_event_queue.h" -#include "hal/hal_facade.grpc.pb.h" #include "hal/hci_hal.h" using ::grpc::ServerAsyncResponseWriter; @@ -30,7 +30,8 @@ using ::grpc::ServerContext; namespace bluetooth { namespace hal { -class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::hal::HciHalCallbacks { +class HciHalFacadeService : public blueberry::facade::hal::HciHalFacade::Service, + public ::bluetooth::hal::HciHalCallbacks { public: explicit HciHalFacadeService(HciHal* hal) : hal_(hal) { hal->registerIncomingPacketCallback(this); @@ -42,7 +43,7 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha ::grpc::Status SendCommand( ::grpc::ServerContext* context, - const ::bluetooth::facade::Data* request, + const ::blueberry::facade::Data* request, ::google::protobuf::Empty* response) override { std::unique_lock<std::mutex> lock(mutex_); can_send_hci_command_ = false; @@ -56,7 +57,7 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha ::grpc::Status SendAcl( ::grpc::ServerContext* context, - const ::bluetooth::facade::Data* request, + const ::blueberry::facade::Data* request, ::google::protobuf::Empty* response) override { std::string req_string = request->payload(); hal_->sendAclData(std::vector<uint8_t>(req_string.begin(), req_string.end())); @@ -65,7 +66,7 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha ::grpc::Status SendSco( ::grpc::ServerContext* context, - const ::bluetooth::facade::Data* request, + const ::blueberry::facade::Data* request, ::google::protobuf::Empty* response) override { std::string req_string = request->payload(); hal_->sendScoData(std::vector<uint8_t>(req_string.begin(), req_string.end())); @@ -75,34 +76,34 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha ::grpc::Status StreamEvents( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { return pending_hci_events_.RunLoop(context, writer); }; ::grpc::Status StreamAcl( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { return pending_acl_events_.RunLoop(context, writer); }; ::grpc::Status StreamSco( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { return pending_sco_events_.RunLoop(context, writer); }; ::grpc::Status StreamIso( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { return pending_iso_events_.RunLoop(context, writer); }; void hciEventReceived(bluetooth::hal::HciPacket event) override { { - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(event.begin(), event.end())); pending_hci_events_.OnIncomingEvent(std::move(response)); } @@ -111,19 +112,19 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha } void aclDataReceived(bluetooth::hal::HciPacket data) override { - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(data.begin(), data.end())); pending_acl_events_.OnIncomingEvent(std::move(response)); } void scoDataReceived(bluetooth::hal::HciPacket data) override { - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(data.begin(), data.end())); pending_sco_events_.OnIncomingEvent(std::move(response)); } void isoDataReceived(bluetooth::hal::HciPacket data) override { - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(data.begin(), data.end())); pending_iso_events_.OnIncomingEvent(std::move(response)); } @@ -133,10 +134,10 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha bool can_send_hci_command_ = true; mutable std::mutex mutex_; std::condition_variable cv_; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_hci_events_{"StreamEvents"}; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_acl_events_{"StreamAcl"}; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_sco_events_{"StreamSco"}; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_iso_events_{"StreamIso"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_hci_events_{"StreamEvents"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_acl_events_{"StreamAcl"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_sco_events_{"StreamSco"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_iso_events_{"StreamIso"}; }; void HciHalFacadeModule::ListDependencies(ModuleList* list) const { diff --git a/system/gd/hal/hal_facade.proto b/system/gd/hal/hal_facade.proto deleted file mode 100644 index 109af0d6eb..0000000000 --- a/system/gd/hal/hal_facade.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package bluetooth.hal; - -import "google/protobuf/empty.proto"; -import "facade/common.proto"; - -service HciHalFacade { - rpc SendCommand(facade.Data) returns (google.protobuf.Empty) {} - rpc StreamEvents(google.protobuf.Empty) returns (stream facade.Data) {} - - rpc SendAcl(facade.Data) returns (google.protobuf.Empty) {} - rpc StreamAcl(google.protobuf.Empty) returns (stream facade.Data) {} - - rpc SendSco(facade.Data) returns (google.protobuf.Empty) {} - rpc StreamSco(google.protobuf.Empty) returns (stream facade.Data) {} - - rpc SendIso(facade.Data) returns (google.protobuf.Empty) {} - rpc StreamIso(google.protobuf.Empty) returns (stream facade.Data) {} -} diff --git a/system/gd/hci/facade/acl_manager_facade.cc b/system/gd/hci/facade/acl_manager_facade.cc index 4923d9fdae..7e249a1723 100644 --- a/system/gd/hci/facade/acl_manager_facade.cc +++ b/system/gd/hci/facade/acl_manager_facade.cc @@ -20,13 +20,13 @@ #include <memory> #include <mutex> +#include "blueberry/facade/hci/acl_manager_facade.grpc.pb.h" +#include "blueberry/facade/hci/acl_manager_facade.pb.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" #include "hci/acl_manager.h" #include "hci/address.h" #include "hci/class_of_device.h" -#include "hci/facade/acl_manager_facade.grpc.pb.h" -#include "hci/facade/acl_manager_facade.pb.h" #include "hci/hci_packets.h" #include "packet/raw_builder.h" @@ -44,6 +44,8 @@ using acl_manager::ClassicAclConnection; using acl_manager::ConnectionCallbacks; using acl_manager::ConnectionManagementCallbacks; +using namespace blueberry::facade::hci; + class AclManagerFacadeService : public AclManagerFacade::Service, public ConnectionCallbacks { public: AclManagerFacadeService(AclManager* acl_manager, ::bluetooth::os::Handler* facade_handler) diff --git a/system/gd/hci/facade/controller_facade.cc b/system/gd/hci/facade/controller_facade.cc index 48b66e2bc1..d10d52f266 100644 --- a/system/gd/hci/facade/controller_facade.cc +++ b/system/gd/hci/facade/controller_facade.cc @@ -20,13 +20,13 @@ #include <memory> #include <mutex> +#include "blueberry/facade/hci/controller_facade.grpc.pb.h" +#include "blueberry/facade/hci/controller_facade.pb.h" #include "common/bind.h" #include "common/blocking_queue.h" #include "grpc/grpc_event_queue.h" #include "hci/address.h" #include "hci/controller.h" -#include "hci/facade/controller_facade.grpc.pb.h" -#include "hci/facade/controller_facade.pb.h" using ::grpc::ServerAsyncResponseWriter; using ::grpc::ServerAsyncWriter; @@ -36,12 +36,15 @@ namespace bluetooth { namespace hci { namespace facade { +using namespace blueberry::facade::hci; +using blueberry::facade::BluetoothAddress; + class ControllerFacadeService : public ControllerFacade::Service { public: ControllerFacadeService(Controller* controller, ::bluetooth::os::Handler*) : controller_(controller) {} - ::grpc::Status GetMacAddress(::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - AddressMsg* response) override { + ::grpc::Status GetMacAddress( + ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, BluetoothAddress* response) override { Address local_address = controller_->GetMacAddress(); response->set_address(local_address.ToString()); return ::grpc::Status::OK; diff --git a/system/gd/hci/facade/facade.cc b/system/gd/hci/facade/facade.cc index 8bd459d494..75ade3dcde 100644 --- a/system/gd/hci/facade/facade.cc +++ b/system/gd/hci/facade/facade.cc @@ -18,10 +18,10 @@ #include <memory> +#include "blueberry/facade/hci/hci_facade.grpc.pb.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" #include "hci/controller.h" -#include "hci/facade/hci_facade.grpc.pb.h" #include "hci/hci_layer.h" #include "hci/hci_packets.h" @@ -33,6 +33,8 @@ namespace bluetooth { namespace hci { namespace facade { +using namespace blueberry::facade::hci; + class HciFacadeService : public HciFacade::Service { public: HciFacadeService(HciLayer* hci_layer, Controller* controller, ::bluetooth::os::Handler* facade_handler) @@ -68,7 +70,7 @@ class HciFacadeService : public HciFacade::Service { ::grpc::Status SendCommand( ::grpc::ServerContext* context, - const ::bluetooth::facade::Data* command, + const ::blueberry::facade::Data* command, ::google::protobuf::Empty* response) override { auto payload = std::vector<uint8_t>(command->payload().begin(), command->payload().end()); auto packet = std::make_unique<TestCommandBuilder>(payload); @@ -83,7 +85,7 @@ class HciFacadeService : public HciFacade::Service { ::grpc::Status RequestEvent( ::grpc::ServerContext* context, - const ::bluetooth::hci::EventRequest* event, + const ::blueberry::facade::hci::EventRequest* event, ::google::protobuf::Empty* response) override { hci_layer_->RegisterEventHandler( static_cast<EventCode>(event->code()), facade_handler_->BindOn(this, &HciFacadeService::on_event)); @@ -92,7 +94,7 @@ class HciFacadeService : public HciFacade::Service { ::grpc::Status RequestLeSubevent( ::grpc::ServerContext* context, - const ::bluetooth::hci::EventRequest* event, + const ::blueberry::facade::hci::EventRequest* event, ::google::protobuf::Empty* response) override { hci_layer_->RegisterLeEventHandler( static_cast<SubeventCode>(event->code()), facade_handler_->BindOn(this, &HciFacadeService::on_le_subevent)); @@ -102,14 +104,14 @@ class HciFacadeService : public HciFacade::Service { ::grpc::Status StreamEvents( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { return pending_events_.RunLoop(context, writer); }; ::grpc::Status StreamLeSubevents( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { return pending_le_events_.RunLoop(context, writer); }; @@ -134,7 +136,7 @@ class HciFacadeService : public HciFacade::Service { ::grpc::Status SendAcl( ::grpc::ServerContext* context, - const ::bluetooth::facade::Data* acl, + const ::blueberry::facade::Data* acl, ::google::protobuf::Empty* response) override { waiting_acl_packet_ = std::make_unique<TestAclBuilder>(std::vector<uint8_t>(acl->payload().begin(), acl->payload().end())); @@ -156,7 +158,7 @@ class HciFacadeService : public HciFacade::Service { ::grpc::Status StreamAcl( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::grpc::ServerWriter<::bluetooth::facade::Data>* writer) override { + ::grpc::ServerWriter<::blueberry::facade::Data>* writer) override { hci_layer_->GetAclQueueEnd()->RegisterDequeue( facade_handler_, common::Bind(&HciFacadeService::on_acl_ready, common::Unretained(this))); unregister_acl_dequeue_ = true; @@ -175,7 +177,7 @@ class HciFacadeService : public HciFacade::Service { ASSERT(acl_ptr != nullptr); ASSERT(acl_ptr->IsValid()); LOG_INFO("Got an Acl message for handle 0x%hx", acl_ptr->GetHandle()); - ::bluetooth::facade::Data incoming; + ::blueberry::facade::Data incoming; incoming.set_payload(std::string(acl_ptr->begin(), acl_ptr->end())); pending_acl_events_.OnIncomingEvent(std::move(incoming)); } @@ -183,7 +185,7 @@ class HciFacadeService : public HciFacade::Service { void on_event(hci::EventView view) { ASSERT(view.IsValid()); LOG_INFO("Got an Event %s", EventCodeText(view.GetEventCode()).c_str()); - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(view.begin(), view.end())); pending_events_.OnIncomingEvent(std::move(response)); } @@ -191,7 +193,7 @@ class HciFacadeService : public HciFacade::Service { void on_le_subevent(hci::LeMetaEventView view) { ASSERT(view.IsValid()); LOG_INFO("Got an LE Event %s", SubeventCodeText(view.GetSubeventCode()).c_str()); - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(view.begin(), view.end())); pending_le_events_.OnIncomingEvent(std::move(response)); } @@ -199,7 +201,7 @@ class HciFacadeService : public HciFacade::Service { void on_complete(hci::CommandCompleteView view) { ASSERT(view.IsValid()); LOG_INFO("Got a Command complete %s", OpCodeText(view.GetCommandOpCode()).c_str()); - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(view.begin(), view.end())); pending_events_.OnIncomingEvent(std::move(response)); } @@ -207,7 +209,7 @@ class HciFacadeService : public HciFacade::Service { void on_status(hci::CommandStatusView view) { ASSERT(view.IsValid()); LOG_INFO("Got a Command status %s", OpCodeText(view.GetCommandOpCode()).c_str()); - ::bluetooth::facade::Data response; + ::blueberry::facade::Data response; response.set_payload(std::string(view.begin(), view.end())); pending_events_.OnIncomingEvent(std::move(response)); } @@ -215,9 +217,9 @@ class HciFacadeService : public HciFacade::Service { HciLayer* hci_layer_; Controller* controller_; ::bluetooth::os::Handler* facade_handler_; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_events_{"StreamEvents"}; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_le_events_{"StreamLeSubevents"}; - ::bluetooth::grpc::GrpcEventQueue<::bluetooth::facade::Data> pending_acl_events_{"StreamAcl"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_events_{"StreamEvents"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_le_events_{"StreamLeSubevents"}; + ::bluetooth::grpc::GrpcEventQueue<::blueberry::facade::Data> pending_acl_events_{"StreamAcl"}; bool unregister_acl_dequeue_{false}; std::unique_ptr<TestAclBuilder> waiting_acl_packet_; bool completed_packets_callback_registered_{false}; diff --git a/system/gd/hci/facade/hci_facade.proto b/system/gd/hci/facade/hci_facade.proto deleted file mode 100644 index 7465a45ab6..0000000000 --- a/system/gd/hci/facade/hci_facade.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto3"; - -package bluetooth.hci; - -import "google/protobuf/empty.proto"; -import "facade/common.proto"; - -service HciFacade { - rpc SendCommand(facade.Data) returns (google.protobuf.Empty) {} - - rpc RequestEvent(EventRequest) returns (google.protobuf.Empty) {} - rpc StreamEvents(google.protobuf.Empty) returns (stream facade.Data) {} - - rpc RequestLeSubevent(EventRequest) returns (google.protobuf.Empty) {} - rpc StreamLeSubevents(google.protobuf.Empty) returns (stream facade.Data) {} - - rpc SendAcl(facade.Data) returns (google.protobuf.Empty) {} - rpc StreamAcl(google.protobuf.Empty) returns (stream facade.Data) {} -} - -message EventRequest { - uint32 code = 1; -} diff --git a/system/gd/hci/facade/le_acl_manager_facade.cc b/system/gd/hci/facade/le_acl_manager_facade.cc index 75c6aac6db..927ae6b96b 100644 --- a/system/gd/hci/facade/le_acl_manager_facade.cc +++ b/system/gd/hci/facade/le_acl_manager_facade.cc @@ -20,11 +20,11 @@ #include <memory> #include <mutex> +#include "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.h" +#include "blueberry/facade/hci/le_acl_manager_facade.pb.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" #include "hci/acl_manager.h" -#include "hci/facade/le_acl_manager_facade.grpc.pb.h" -#include "hci/facade/le_acl_manager_facade.pb.h" #include "hci/hci_packets.h" #include "packet/raw_builder.h" @@ -42,6 +42,8 @@ using acl_manager::LeAclConnection; using acl_manager::LeConnectionCallbacks; using acl_manager::LeConnectionManagementCallbacks; +using namespace blueberry::facade::hci; + class LeAclManagerFacadeService : public LeAclManagerFacade::Service, public LeConnectionCallbacks { public: LeAclManagerFacadeService(AclManager* acl_manager, ::bluetooth::os::Handler* facade_handler) @@ -61,7 +63,7 @@ class LeAclManagerFacadeService : public LeAclManagerFacade::Service, public LeC ::grpc::Status CreateConnection( ::grpc::ServerContext* context, - const ::bluetooth::facade::BluetoothAddressWithType* request, + const ::blueberry::facade::BluetoothAddressWithType* request, ::grpc::ServerWriter<LeConnectionEvent>* writer) override { Address peer_address; ASSERT(Address::FromString(request->address().address(), peer_address)); @@ -77,7 +79,7 @@ class LeAclManagerFacadeService : public LeAclManagerFacade::Service, public LeC ::grpc::Status CreateBackgroundAndDirectConnection( ::grpc::ServerContext* context, - const ::bluetooth::facade::BluetoothAddressWithType* request, + const ::blueberry::facade::BluetoothAddressWithType* request, ::grpc::ServerWriter<LeConnectionEvent>* writer) override { Address peer_address; ASSERT(Address::FromString(request->address().address(), peer_address)); @@ -96,7 +98,7 @@ class LeAclManagerFacadeService : public LeAclManagerFacade::Service, public LeC ::grpc::Status CancelConnection( ::grpc::ServerContext* context, - const ::bluetooth::facade::BluetoothAddressWithType* request, + const ::blueberry::facade::BluetoothAddressWithType* request, google::protobuf::Empty* response) override { Address peer_address; ASSERT(Address::FromString(request->address().address(), peer_address)); diff --git a/system/gd/hci/facade/le_advertising_manager_facade.cc b/system/gd/hci/facade/le_advertising_manager_facade.cc index 30dd2dab3c..fabf790be1 100644 --- a/system/gd/hci/facade/le_advertising_manager_facade.cc +++ b/system/gd/hci/facade/le_advertising_manager_facade.cc @@ -14,18 +14,19 @@ * limitations under the License. */ +#include "hci/facade/le_advertising_manager_facade.h" + #include <cstdint> #include <unordered_map> #include <utility> +#include "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.h" +#include "blueberry/facade/hci/le_advertising_manager_facade.pb.h" #include "common/bidi_queue.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" #include "hci/address.h" #include "hci/address_with_type.h" -#include "hci/facade/le_advertising_manager_facade.grpc.pb.h" -#include "hci/facade/le_advertising_manager_facade.h" -#include "hci/facade/le_advertising_manager_facade.pb.h" #include "hci/le_advertising_manager.h" #include "os/log.h" @@ -39,8 +40,12 @@ using ::grpc::ServerContext; using ::grpc::ServerWriter; using ::grpc::Status; -using ::bluetooth::facade::BluetoothAddress; -using ::bluetooth::facade::BluetoothAddressTypeEnum; +using ::blueberry::facade::BluetoothAddress; +using ::blueberry::facade::BluetoothAddressTypeEnum; +using ::blueberry::facade::hci::AdvertisingConfig; +using ::blueberry::facade::hci::ExtendedAdvertisingConfig; +using ::blueberry::facade::hci::GapDataMsg; +using ::blueberry::facade::hci::PeriodicAdvertisingParameters; hci::GapData GapDataFromProto(const GapDataMsg& gap_data_proto) { hci::GapData gap_data; @@ -183,6 +188,25 @@ class LeAdvertiser { hci::AdvertisingConfig config_; }; +using ::blueberry::facade::hci::AddressMsg; +using ::blueberry::facade::hci::AdvertisingCallbackMsg; +using ::blueberry::facade::hci::AdvertisingCallbackMsgType; +using ::blueberry::facade::hci::AdvertisingStatus; +using ::blueberry::facade::hci::CreateAdvertiserRequest; +using ::blueberry::facade::hci::CreateAdvertiserResponse; +using ::blueberry::facade::hci::EnableAdvertiserRequest; +using ::blueberry::facade::hci::EnablePeriodicAdvertisingRequest; +using ::blueberry::facade::hci::ExtendedCreateAdvertiserRequest; +using ::blueberry::facade::hci::ExtendedCreateAdvertiserResponse; +using ::blueberry::facade::hci::GetNumberOfAdvertisingInstancesResponse; +using ::blueberry::facade::hci::GetOwnAddressRequest; +using ::blueberry::facade::hci::LeAdvertisingManagerFacade; +using ::blueberry::facade::hci::RemoveAdvertiserRequest; +using ::blueberry::facade::hci::SetDataRequest; +using ::blueberry::facade::hci::SetParametersRequest; +using ::blueberry::facade::hci::SetPeriodicDataRequest; +using ::blueberry::facade::hci::SetPeriodicParametersRequest; + class LeAdvertisingManagerFacadeService : public LeAdvertisingManagerFacade::Service, AdvertisingCallback { public: LeAdvertisingManagerFacadeService(LeAdvertisingManager* le_advertising_manager, os::Handler* facade_handler) @@ -429,7 +453,7 @@ class LeAdvertisingManagerFacadeService : public LeAdvertisingManagerFacade::Ser AddressMsg msg; msg.set_message_type(AdvertisingCallbackMsgType::OWN_ADDRESS_READ); msg.set_advertiser_id(advertiser_id); - bluetooth::facade::BluetoothAddressWithType facade_address; + blueberry::facade::BluetoothAddressWithType facade_address; facade_address.mutable_address()->set_address(address.ToString()); facade_address.set_type(static_cast<facade::BluetoothAddressTypeEnum>(address_type)); *msg.mutable_address() = facade_address; diff --git a/system/gd/hci/facade/le_initiator_address_facade.cc b/system/gd/hci/facade/le_initiator_address_facade.cc index c19b3dbad2..4f226ce8a6 100644 --- a/system/gd/hci/facade/le_initiator_address_facade.cc +++ b/system/gd/hci/facade/le_initiator_address_facade.cc @@ -20,11 +20,11 @@ #include <memory> #include <mutex> +#include "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.h" +#include "blueberry/facade/hci/le_initiator_address_facade.pb.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" #include "hci/acl_manager.h" -#include "hci/facade/le_initiator_address_facade.grpc.pb.h" -#include "hci/facade/le_initiator_address_facade.pb.h" #include "hci/hci_packets.h" #include "packet/raw_builder.h" @@ -38,6 +38,8 @@ namespace bluetooth { namespace hci { namespace facade { +using namespace blueberry::facade::hci; + class LeInitiatorAddressFacadeService : public LeInitiatorAddressFacade::Service { public: LeInitiatorAddressFacadeService(AclManager* acl_manager, ::bluetooth::os::Handler* facade_handler) @@ -74,11 +76,11 @@ class LeInitiatorAddressFacadeService : public LeInitiatorAddressFacade::Service ::grpc::Status GetCurrentInitiatorAddress( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::bluetooth::facade::BluetoothAddressWithType* response) override { + ::blueberry::facade::BluetoothAddressWithType* response) override { AddressWithType current = address_manager_->GetCurrentAddress(); - auto bluetooth_address = new ::bluetooth::facade::BluetoothAddress(); + auto bluetooth_address = new ::blueberry::facade::BluetoothAddress(); bluetooth_address->set_address(current.GetAddress().ToString()); - response->set_type(static_cast<::bluetooth::facade::BluetoothAddressTypeEnum>(current.GetAddressType())); + response->set_type(static_cast<::blueberry::facade::BluetoothAddressTypeEnum>(current.GetAddressType())); response->set_allocated_address(bluetooth_address); return ::grpc::Status::OK; } @@ -86,11 +88,11 @@ class LeInitiatorAddressFacadeService : public LeInitiatorAddressFacade::Service ::grpc::Status GetAnotherAddress( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, - ::bluetooth::facade::BluetoothAddressWithType* response) override { + ::blueberry::facade::BluetoothAddressWithType* response) override { AddressWithType another = address_manager_->GetAnotherAddress(); - auto bluetooth_address = new ::bluetooth::facade::BluetoothAddress(); + auto bluetooth_address = new ::blueberry::facade::BluetoothAddress(); bluetooth_address->set_address(another.GetAddress().ToString()); - response->set_type(static_cast<::bluetooth::facade::BluetoothAddressTypeEnum>(another.GetAddressType())); + response->set_type(static_cast<::blueberry::facade::BluetoothAddressTypeEnum>(another.GetAddressType())); response->set_allocated_address(bluetooth_address); return ::grpc::Status::OK; } diff --git a/system/gd/hci/facade/le_scanning_manager_facade.cc b/system/gd/hci/facade/le_scanning_manager_facade.cc index 8842517955..8e583e218b 100644 --- a/system/gd/hci/facade/le_scanning_manager_facade.cc +++ b/system/gd/hci/facade/le_scanning_manager_facade.cc @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "hci/le_scanning_manager.h" +#include "hci/facade/le_scanning_manager_facade.h" #include <cstdint> #include <unordered_map> #include <utility> +#include "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.h" +#include "blueberry/facade/hci/le_scanning_manager_facade.pb.h" #include "common/bidi_queue.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" -#include "hci/facade/le_scanning_manager_facade.grpc.pb.h" -#include "hci/facade/le_scanning_manager_facade.h" -#include "hci/facade/le_scanning_manager_facade.pb.h" +#include "hci/le_scanning_manager.h" #include "os/log.h" #include "packet/raw_builder.h" @@ -39,6 +39,8 @@ using ::grpc::ServerContext; using ::grpc::ServerWriter; using ::grpc::Status; +using namespace blueberry::facade::hci; + class LeScanningManagerFacadeService : public LeScanningManagerFacade::Service, ScanningCallback { public: LeScanningManagerFacadeService(LeScanningManager* le_scanning_manager, os::Handler* facade_handler) diff --git a/system/gd/iso/facade.cc b/system/gd/iso/facade.cc index 1f2f8fe184..42779f0e63 100644 --- a/system/gd/iso/facade.cc +++ b/system/gd/iso/facade.cc @@ -15,12 +15,12 @@ */ #include "iso/facade.h" +#include "blueberry/facade/iso/facade.grpc.pb.h" #include "common/contextual_callback.h" #include "grpc/grpc_event_queue.h" #include "hci/acl_manager.h" #include "hci/address_with_type.h" #include "hci/le_address_manager.h" -#include "iso/facade.grpc.pb.h" #include "iso/iso_module.h" #include "os/handler.h" @@ -29,6 +29,8 @@ using bluetooth::hci::AclManager; namespace bluetooth { namespace iso { +using namespace blueberry::facade::iso; + class IsoModuleFacadeService : public IsoModuleFacade::Service { public: IsoModuleFacadeService(IsoModule* iso_module, AclManager* acl_manager, ::bluetooth::os::Handler* iso_handler) diff --git a/system/gd/l2cap/classic/facade.cc b/system/gd/l2cap/classic/facade.cc index 9ec64567dc..73eebaaab2 100644 --- a/system/gd/l2cap/classic/facade.cc +++ b/system/gd/l2cap/classic/facade.cc @@ -14,17 +14,18 @@ * limitations under the License. */ +#include "l2cap/classic/facade.h" + #include <condition_variable> #include <cstdint> #include <unordered_map> +#include "blueberry/facade/l2cap/classic/facade.grpc.pb.h" #include "common/bidi_queue.h" #include "common/bind.h" #include "common/callback.h" #include "grpc/grpc_event_queue.h" #include "hci/address.h" -#include "l2cap/classic/facade.grpc.pb.h" -#include "l2cap/classic/facade.h" #include "l2cap/classic/l2cap_classic_module.h" #include "os/log.h" #include "packet/raw_builder.h" @@ -39,6 +40,8 @@ namespace bluetooth { namespace l2cap { namespace classic { +using namespace blueberry::facade::l2cap::classic; + class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service, public LinkSecurityInterfaceListener { public: L2capClassicModuleFacadeService(L2capClassicModule* l2cap_layer, os::Handler* facade_handler) @@ -132,7 +135,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service ::grpc::Status InitiateConnectionForSecurity( ::grpc::ServerContext* context, - const facade::BluetoothAddress* request, + const blueberry::facade::BluetoothAddress* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address(), peer)); @@ -159,7 +162,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service ::grpc::Status SecurityLinkHold( ::grpc::ServerContext* context, - const facade::BluetoothAddress* request, + const blueberry::facade::BluetoothAddress* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address(), peer)); @@ -174,7 +177,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service ::grpc::Status SecurityLinkEnsureAuthenticated( ::grpc::ServerContext* context, - const facade::BluetoothAddress* request, + const blueberry::facade::BluetoothAddress* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address(), peer)); @@ -189,7 +192,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service ::grpc::Status SecurityLinkRelease( ::grpc::ServerContext* context, - const facade::BluetoothAddress* request, + const blueberry::facade::BluetoothAddress* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address(), peer)); @@ -205,7 +208,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service ::grpc::Status SecurityLinkDisconnect( ::grpc::ServerContext* context, - const facade::BluetoothAddress* request, + const blueberry::facade::BluetoothAddress* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address(), peer)); diff --git a/system/gd/l2cap/le/facade.cc b/system/gd/l2cap/le/facade.cc index fa84028fd3..b0e795594c 100644 --- a/system/gd/l2cap/le/facade.cc +++ b/system/gd/l2cap/le/facade.cc @@ -16,11 +16,11 @@ #include "l2cap/le/facade.h" +#include "blueberry/facade/l2cap/le/facade.grpc.pb.h" #include "grpc/grpc_event_queue.h" #include "l2cap/le/dynamic_channel.h" #include "l2cap/le/dynamic_channel_manager.h" #include "l2cap/le/dynamic_channel_service.h" -#include "l2cap/le/facade.grpc.pb.h" #include "l2cap/le/l2cap_le_module.h" #include "l2cap/le/security_policy.h" #include "l2cap/psm.h" @@ -30,6 +30,8 @@ namespace bluetooth { namespace l2cap { namespace le { +using namespace blueberry::facade::l2cap::le; + SecurityPolicy SecurityLevelToPolicy(SecurityLevel level) { switch (level) { case SecurityLevel::NO_SECURITY: diff --git a/system/gd/neighbor/facade/facade.cc b/system/gd/neighbor/facade/facade.cc index 31f7761b8a..d543fae2d8 100644 --- a/system/gd/neighbor/facade/facade.cc +++ b/system/gd/neighbor/facade/facade.cc @@ -18,10 +18,10 @@ #include <memory> +#include "blueberry/facade/neighbor/facade.grpc.pb.h" #include "common/bind.h" #include "grpc/grpc_event_queue.h" #include "hci/hci_packets.h" -#include "neighbor/facade/facade.grpc.pb.h" using ::grpc::ServerAsyncResponseWriter; using ::grpc::ServerAsyncWriter; @@ -31,6 +31,8 @@ namespace bluetooth { namespace neighbor { namespace facade { +using namespace blueberry::facade::neighbor; + class NeighborFacadeService : public NeighborFacade::Service { public: NeighborFacadeService( @@ -49,9 +51,7 @@ class NeighborFacadeService : public NeighborFacade::Service { facade_handler_(facade_handler) {} ::grpc::Status SetConnectability( - ::grpc::ServerContext* context, - const ::bluetooth::neighbor::EnableMsg* request, - ::google::protobuf::Empty* response) override { + ::grpc::ServerContext* context, const EnableMsg* request, ::google::protobuf::Empty* response) override { if (request->enabled()) { connectability_module_->StartConnectability(); } else { @@ -62,7 +62,7 @@ class NeighborFacadeService : public NeighborFacade::Service { ::grpc::Status SetDiscoverability( ::grpc::ServerContext* context, - const ::bluetooth::neighbor::DiscoverabilitiyMsg* request, + const DiscoverabilitiyMsg* request, ::google::protobuf::Empty* response) override { switch (request->mode()) { case DiscoverabilityMode::OFF: @@ -82,7 +82,7 @@ class NeighborFacadeService : public NeighborFacade::Service { ::grpc::Status SetInquiryMode( ::grpc::ServerContext* context, - const ::bluetooth::neighbor::InquiryMsg* request, + const InquiryMsg* request, ::grpc::ServerWriter<InquiryResultMsg>* writer) override { inquiry_module_->RegisterCallbacks(inquiry_callbacks_); switch (request->result_mode()) { @@ -116,7 +116,7 @@ class NeighborFacadeService : public NeighborFacade::Service { ::grpc::Status ReadRemoteName( ::grpc::ServerContext* context, - const ::bluetooth::neighbor::RemoteNameRequestMsg* request, + const RemoteNameRequestMsg* request, ::google::protobuf::Empty* response) override { hci::Address remote; ASSERT(hci::Address::FromString(request->address(), remote)); @@ -152,9 +152,7 @@ class NeighborFacadeService : public NeighborFacade::Service { } ::grpc::Status EnableInquiryScan( - ::grpc::ServerContext* context, - const ::bluetooth::neighbor::EnableMsg* request, - ::google::protobuf::Empty* response) override { + ::grpc::ServerContext* context, const EnableMsg* request, ::google::protobuf::Empty* response) override { if (request->enabled()) { scan_module_->SetInquiryScan(); } else { @@ -164,9 +162,7 @@ class NeighborFacadeService : public NeighborFacade::Service { } ::grpc::Status EnablePageScan( - ::grpc::ServerContext* context, - const ::bluetooth::neighbor::EnableMsg* request, - ::google::protobuf::Empty* response) override { + ::grpc::ServerContext* context, const EnableMsg* request, ::google::protobuf::Empty* response) override { if (request->enabled()) { scan_module_->SetPageScan(); } else { diff --git a/system/gd/rust/stack/src/hci/controller_facade.rs b/system/gd/rust/stack/src/hci/controller_facade.rs index 027de440c5..7f0dd665fc 100644 --- a/system/gd/rust/stack/src/hci/controller_facade.rs +++ b/system/gd/rust/stack/src/hci/controller_facade.rs @@ -3,9 +3,8 @@ use crate::hci::controller::{null_terminated_to_string, ControllerExports}; use crate::hci::Hci; use bt_common::GrpcFacade; -use bt_facade_proto::controller_facade::{ - AddressMsg, NameMsg, OpCodeMsg, SingleValueMsg, SupportedMsg, -}; +use bt_facade_proto::common::BluetoothAddress; +use bt_facade_proto::controller_facade::{NameMsg, OpCodeMsg, SingleValueMsg, SupportedMsg}; use bt_facade_proto::controller_facade_grpc::{create_controller_facade, ControllerFacade}; use bt_facade_proto::empty::Empty; use bt_packets::hci::{ReadLocalNameBuilder, WriteLocalNameBuilder}; @@ -40,10 +39,15 @@ impl GrpcFacade for ControllerFacadeService { } impl ControllerFacade for ControllerFacadeService { - fn get_mac_address(&mut self, ctx: RpcContext<'_>, _req: Empty, sink: UnarySink<AddressMsg>) { + fn get_mac_address( + &mut self, + ctx: RpcContext<'_>, + _req: Empty, + sink: UnarySink<BluetoothAddress>, + ) { let clone = self.clone(); ctx.spawn(async move { - let mut address = AddressMsg::new(); + let mut address = BluetoothAddress::new(); address.set_address(clone.exports.address.bytes.to_vec()); sink.success(address).await.unwrap(); }); diff --git a/system/gd/rust/topshim/facade/Android.bp b/system/gd/rust/topshim/facade/Android.bp index be61d34a4a..c97cca8972 100644 --- a/system/gd/rust/topshim/facade/Android.bp +++ b/system/gd/rust/topshim/facade/Android.bp @@ -66,23 +66,3 @@ rust_binary_host { "libpaste", ], } - -rust_protobuf { - name: "libbt_topshim_facade_protobuf", - crate_name: "bt_topshim_facade_protobuf", - source_stem: "topshim_facade", - host_supported: true, - grpc_protos: ["facade.proto"], -} - -genrule { - name: "libbt_topshim_facade_py_proto", - tools: [ - "aprotoc", - "protoc-gen-grpc-python-plugin", - "soong_zip", - ], - cmd: "$(location aprotoc) --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) -Ipackages/modules/Bluetooth/system/gd/rust/topshim/facade $(in) --grpc_out=$(genDir) --python_out=$(genDir)", - srcs: ["facade.proto"], - out: ["facade_pb2.py", "facade_pb2_grpc.py"], -} diff --git a/system/gd/rust/topshim/facade/utils.proto b/system/gd/rust/topshim/facade/utils.proto deleted file mode 100644 index 9f0fd5cf03..0000000000 --- a/system/gd/rust/topshim/facade/utils.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package blueberry; - -message Empty {} - -message BluetoothAddress { - bytes address = 1; -} - -service ReadOnlyProperty { - rpc ReadLocalAddress(Empty) returns (BluetoothAddress) {} -}
\ No newline at end of file diff --git a/system/gd/security/facade.cc b/system/gd/security/facade.cc index a866c10cbe..00c6e8661a 100644 --- a/system/gd/security/facade.cc +++ b/system/gd/security/facade.cc @@ -15,13 +15,13 @@ */ #include "security/facade.h" +#include "blueberry/facade/security/facade.grpc.pb.h" #include "grpc/grpc_event_queue.h" #include "hci/address_with_type.h" #include "hci/le_address_manager.h" #include "l2cap/classic/security_policy.h" #include "l2cap/le/l2cap_le_module.h" #include "os/handler.h" -#include "security/facade.grpc.pb.h" #include "security/pairing/oob_data.h" #include "security/security_manager_listener.h" #include "security/security_module.h" @@ -32,6 +32,8 @@ using bluetooth::l2cap::le::L2capLeModule; namespace bluetooth { namespace security { +using namespace blueberry::facade::security; + namespace { constexpr uint8_t AUTH_REQ_NO_BOND = 0x01; constexpr uint8_t AUTH_REQ_BOND = 0x01; @@ -41,11 +43,11 @@ constexpr uint8_t AUTH_REQ_KEYPRESS_MASK = 0x10; constexpr uint8_t AUTH_REQ_CT2_MASK = 0x20; constexpr uint8_t AUTH_REQ_RFU_MASK = 0xC0; -facade::BluetoothAddressWithType ToFacadeAddressWithType(hci::AddressWithType address) { - facade::BluetoothAddressWithType ret; +blueberry::facade::BluetoothAddressWithType ToFacadeAddressWithType(hci::AddressWithType address) { + blueberry::facade::BluetoothAddressWithType ret; ret.mutable_address()->set_address(address.GetAddress().ToString()); - ret.set_type(static_cast<facade::BluetoothAddressTypeEnum>(address.GetAddressType())); + ret.set_type(static_cast<blueberry::facade::BluetoothAddressTypeEnum>(address.GetAddressType())); return ret; } @@ -90,8 +92,10 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public helper_events_.OnIncomingEvent(disconnected); } - ::grpc::Status CreateBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, - ::google::protobuf::Empty* response) override { + ::grpc::Status CreateBond( + ::grpc::ServerContext* context, + const blueberry::facade::BluetoothAddressWithType* request, + ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = static_cast<hci::AddressType>(request->type()); @@ -100,9 +104,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public } ::grpc::Status CreateBondOutOfBand( - ::grpc::ServerContext* context, - const ::bluetooth::security::OobDataBondMessage* request, - ::google::protobuf::Empty* response) override { + ::grpc::ServerContext* context, const OobDataBondMessage* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address().address(), peer)); hci::AddressType peer_type = static_cast<hci::AddressType>(request->address().type()); @@ -141,8 +143,10 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return oob_events_.RunLoop(context, writer); } - ::grpc::Status CreateBondLe(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, - ::google::protobuf::Empty* response) override { + ::grpc::Status CreateBondLe( + ::grpc::ServerContext* context, + const blueberry::facade::BluetoothAddressWithType* request, + ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = static_cast<hci::AddressType>(request->type()); @@ -150,8 +154,10 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return ::grpc::Status::OK; } - ::grpc::Status CancelBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, - ::google::protobuf::Empty* response) override { + ::grpc::Status CancelBond( + ::grpc::ServerContext* context, + const blueberry::facade::BluetoothAddressWithType* request, + ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; @@ -159,8 +165,10 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return ::grpc::Status::OK; } - ::grpc::Status RemoveBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, - ::google::protobuf::Empty* response) override { + ::grpc::Status RemoveBond( + ::grpc::ServerContext* context, + const blueberry::facade::BluetoothAddressWithType* request, + ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; @@ -275,7 +283,9 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public } ::grpc::Status SetLeInitiatorAddressPolicy( - ::grpc::ServerContext* context, const hci::PrivacyPolicy* request, ::google::protobuf::Empty* response) override { + ::grpc::ServerContext* context, + const blueberry::facade::hci::PrivacyPolicy* request, + ::google::protobuf::Empty* response) override { Address address = Address::kEmpty; hci::LeAddressManager::AddressPolicy address_policy = static_cast<hci::LeAddressManager::AddressPolicy>(request->address_policy()); @@ -322,9 +332,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public } ::grpc::Status GetLeOutOfBandData( - ::grpc::ServerContext* context, - const ::google::protobuf::Empty* request, - ::bluetooth::security::OobDataMessage* response) override { + ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, OobDataMessage* response) override { std::array<uint8_t, 16> le_sc_c; std::array<uint8_t, 16> le_sc_r; security_module_->GetFacadeConfigurationApi()->GetLeOutOfBandData(&le_sc_c, &le_sc_r); @@ -341,9 +349,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public } ::grpc::Status SetOutOfBandData( - ::grpc::ServerContext* context, - const ::bluetooth::security::OobDataMessage* request, - ::google::protobuf::Empty* response) override { + ::grpc::ServerContext* context, const OobDataMessage* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address().address(), peer)); hci::AddressType peer_type = static_cast<hci::AddressType>(request->address().type()); diff --git a/system/gd/shim/facade/facade.cc b/system/gd/shim/facade/facade.cc index 1c725968a8..de1466495d 100644 --- a/system/gd/shim/facade/facade.cc +++ b/system/gd/shim/facade/facade.cc @@ -18,14 +18,14 @@ #include <memory> +#include "blueberry/facade/shim/facade.grpc.pb.h" +#include "blueberry/facade/shim/facade.pb.h" #include "common/bind.h" #include "flatbuffers/idl.h" #include "flatbuffers/reflection_generated.h" #include "grpc/grpc_event_queue.h" #include "os/log.h" #include "shim/dumpsys.h" -#include "shim/facade/facade.grpc.pb.h" -#include "shim/facade/facade.pb.h" using ::grpc::ServerAsyncResponseWriter; using ::grpc::ServerAsyncWriter; @@ -35,6 +35,8 @@ namespace bluetooth { namespace shim { namespace facade { +using namespace blueberry::facade::shim; + class ShimFacadeService : public ShimFacade::Service { public: ShimFacadeService(shim::Dumpsys* dumpsys_layer, ::bluetooth::os::Handler* facade_handler) diff --git a/system/gd/setup.py b/system/setup.py index 34cd9fb6c1..cdb76f8a3a 100644 --- a/system/gd/setup.py +++ b/system/setup.py @@ -15,7 +15,6 @@ # limitations under the License. from distutils import log -from distutils.errors import DistutilsModuleError import os from setuptools import find_packages from setuptools import setup @@ -24,10 +23,14 @@ import stat import subprocess import sys +reuse_libraries = False +force_install = False + install_requires = [ 'grpcio', 'psutil', 'protobuf>=3.14.0', + 'mobly', ] host_executables = [ @@ -50,12 +53,16 @@ def set_permissions_for_host_executables(outputs): class InstallLocalPackagesForInstallation(install): def run(self): + global reuse_libraries, force_install install_args = [sys.executable, '-m', 'pip', 'install'] subprocess.check_call(install_args + ['--upgrade', 'pip']) for package in install_requires: self.announce('Installing %s...' % package, log.INFO) - subprocess.check_call(install_args + ['-v', '--no-cache-dir', package]) + cmd = install_args + ['-v', '--no-cache-dir', package] + if force_install and not reuse_libraries: + cmd.append("--force-reinstall") + subprocess.check_call(cmd) self.announce('Dependencies installed.') install.run(self) @@ -63,6 +70,12 @@ class InstallLocalPackagesForInstallation(install): def main(): + global reuse_libraries, force_install + if sys.argv[-1] == "--reuse-libraries": + reuse_libraries = True + sys.argv = sys.argv[:-1] + if "--force" in sys.argv: + force_install = True # Relative path from calling directory to this file our_dir = os.path.dirname(__file__) # Must cd into this dir for package resolution to work |