Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd8f893a authored by Martin Brabham's avatar Martin Brabham
Browse files

Wire up callback in facade

Bug: 164495896
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: If1c63ebf80ad69b66d56bdd1fd2c0fcdfe880877
parent bca1e9dc
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -304,6 +304,23 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
    return ::grpc::Status::OK;
  }

  ::grpc::Status FetchDisconnectEvents(
      ::grpc::ServerContext* context,
      const ::google::protobuf::Empty* request,
      ::grpc::ServerWriter<DisconnectMsg>* writer) override {
    security_module_->GetFacadeConfigurationApi()->SetDisconnectCallback(
        common::Bind(&SecurityModuleFacadeService::DisconnectEventOccurred, common::Unretained(this)));
    return disconnect_events_.RunLoop(context, writer);
  }

  void DisconnectEventOccurred(bluetooth::hci::AddressWithType peer) {
    LOG_INFO("%s", peer.ToString().c_str());
    DisconnectMsg msg;
    msg.mutable_address()->mutable_address()->set_address(peer.ToString());
    msg.mutable_address()->set_type(static_cast<facade::BluetoothAddressTypeEnum>(peer.GetAddressType()));
    disconnect_events_.OnIncomingEvent(msg);
  }

  void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& peer, std::string name) {
    LOG_INFO("%s", peer.ToString().c_str());
    UiMsg display_yes_no;
@@ -412,6 +429,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
  ::bluetooth::grpc::GrpcEventQueue<SecurityHelperMsg> helper_events_{"Events that don't fit any other category"};
  ::bluetooth::grpc::GrpcEventQueue<EnforceSecurityPolicyMsg> enforce_security_policy_events_{
      "Enforce Security Policy Events"};
  ::bluetooth::grpc::GrpcEventQueue<DisconnectMsg> disconnect_events_{"Disconnect events"};
  uint32_t unique_id{1};
  std::map<uint32_t, common::OnceCallback<void(bool)>> user_yes_no_callbacks_;
  std::map<uint32_t, common::OnceCallback<void(uint32_t)>> user_passkey_callbacks_;
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ service SecurityModuleFacade {
  rpc FetchHelperEvents(google.protobuf.Empty) returns (stream SecurityHelperMsg) {}
  rpc EnforceSecurityPolicy(SecurityPolicyMessage) returns (google.protobuf.Empty) {}
  rpc FetchEnforceSecurityPolicyEvents(google.protobuf.Empty) returns (stream EnforceSecurityPolicyMsg) {}
  rpc FetchDisconnectEvents(google.protobuf.Empty) returns (stream DisconnectMsg) {}
}

message OobDataMessage {
@@ -155,3 +156,7 @@ message SecurityPolicyMessage {
message EnforceSecurityPolicyMsg {
  bool result = 1;
}

message DisconnectMsg {
  facade.BluetoothAddressWithType address = 1;
}