Loading system/gd/cert/py_security.py +4 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,10 @@ class PySecurity(Closable): """ Call to enforce classic security policy """ pass self._device.security.EnforceSecurityPolicy( SecurityPolicyMessage( address=common.BluetoothAddressWithType(address=common.BluetoothAddress(address=address), type=type), policy=policy)) def close(self): if self._ui_event_stream is not None: Loading system/gd/security/facade.cc +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "grpc/grpc_event_queue.h" #include "hci/address_with_type.h" #include "l2cap/classic/security_policy.h" #include "os/handler.h" #include "security/facade.grpc.pb.h" #include "security/security_manager_listener.h" Loading Loading @@ -147,6 +148,17 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return ::grpc::Status::OK; } ::grpc::Status EnforceSecurityPolicy( ::grpc::ServerContext* context, const SecurityPolicyMessage* 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()); hci::AddressWithType peer_with_type(peer, peer_type); return ::grpc::Status::OK; } void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& peer, std::string name) { LOG_INFO("%s", peer.ToString().c_str()); UiMsg display_yes_no; Loading system/gd/security/facade.proto +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package bluetooth.security; import "google/protobuf/empty.proto"; import "facade/common.proto"; import "l2cap/classic/facade.proto"; service SecurityModuleFacade { rpc CreateBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} Loading @@ -18,6 +19,7 @@ service SecurityModuleFacade { rpc SendUiCallback(UiCallbackMsg) returns (google.protobuf.Empty) {} rpc FetchUiEvents(google.protobuf.Empty) returns (stream UiMsg) {} rpc FetchBondEvents(google.protobuf.Empty) returns (stream BondMsg) {} rpc EnforceSecurityPolicy(SecurityPolicyMessage) returns (google.protobuf.Empty) {} } enum UiMsgType { Loading Loading @@ -106,3 +108,8 @@ enum OobDataPresent { message OobDataMessage { OobDataPresent data_present = 1; } message SecurityPolicyMessage { facade.BluetoothAddressWithType address = 1; l2cap.classic.ClassicSecurityPolicy policy = 2; } Loading
system/gd/cert/py_security.py +4 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,10 @@ class PySecurity(Closable): """ Call to enforce classic security policy """ pass self._device.security.EnforceSecurityPolicy( SecurityPolicyMessage( address=common.BluetoothAddressWithType(address=common.BluetoothAddress(address=address), type=type), policy=policy)) def close(self): if self._ui_event_stream is not None: Loading
system/gd/security/facade.cc +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "grpc/grpc_event_queue.h" #include "hci/address_with_type.h" #include "l2cap/classic/security_policy.h" #include "os/handler.h" #include "security/facade.grpc.pb.h" #include "security/security_manager_listener.h" Loading Loading @@ -147,6 +148,17 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return ::grpc::Status::OK; } ::grpc::Status EnforceSecurityPolicy( ::grpc::ServerContext* context, const SecurityPolicyMessage* 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()); hci::AddressWithType peer_with_type(peer, peer_type); return ::grpc::Status::OK; } void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& peer, std::string name) { LOG_INFO("%s", peer.ToString().c_str()); UiMsg display_yes_no; Loading
system/gd/security/facade.proto +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package bluetooth.security; import "google/protobuf/empty.proto"; import "facade/common.proto"; import "l2cap/classic/facade.proto"; service SecurityModuleFacade { rpc CreateBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} Loading @@ -18,6 +19,7 @@ service SecurityModuleFacade { rpc SendUiCallback(UiCallbackMsg) returns (google.protobuf.Empty) {} rpc FetchUiEvents(google.protobuf.Empty) returns (stream UiMsg) {} rpc FetchBondEvents(google.protobuf.Empty) returns (stream BondMsg) {} rpc EnforceSecurityPolicy(SecurityPolicyMessage) returns (google.protobuf.Empty) {} } enum UiMsgType { Loading Loading @@ -106,3 +108,8 @@ enum OobDataPresent { message OobDataMessage { OobDataPresent data_present = 1; } message SecurityPolicyMessage { facade.BluetoothAddressWithType address = 1; l2cap.classic.ClassicSecurityPolicy policy = 2; }