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

Commit 1e1b344e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I8bff5eab,If1c63ebf,Ie62cae6a

* changes:
  Wire up test to disconnect callback
  Wire up callback in facade
  Facade Configuration: Set disconnect callback.
parents fadfface 5d3a1fd3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ class PySecurity(Closable):
        self._bond_event_stream = EventStream(self._device.security.FetchBondEvents(empty_proto.Empty()))
        self._enforce_security_policy_stream = EventStream(
            self._device.security.FetchEnforceSecurityPolicyEvents(empty_proto.Empty()))
        self._disconnect_event_stream = EventStream(self._device.security.FetchDisconnectEvents(empty_proto.Empty()))

    def create_bond(self, address, type):
        """
@@ -180,6 +181,13 @@ class PySecurity(Closable):
        assertThat(self._enforce_security_policy_stream).emits(
            lambda event: event.result == expected_enforce_security_event or logging.info(event.result))

    def wait_for_disconnect_event(self):
        """
            The Address is expected to be returned
        """
        logging.info("DUT: Waiting for Disconnect Event")
        assertThat(self._disconnect_event_stream).emits(lambda event: 1 == 1)

    def enforce_security_policy(self, address, type, policy):
        """
            Call to enforce classic security policy
@@ -193,3 +201,4 @@ class PySecurity(Closable):
        safeClose(self._ui_event_stream)
        safeClose(self._bond_event_stream)
        safeClose(self._enforce_security_policy_stream)
        safeClose(self._disconnect_event_stream)
+6 −0
Original line number Diff line number Diff line
@@ -206,5 +206,11 @@ class CertSecurity(PySecurity):
        """
        pass

    def wait_for_disconnect_event(self):
        """
            Cert side needs to pass
        """
        pass

    def close(self):
        safeClose(self._hci)
+2 −1
Original line number Diff line number Diff line
@@ -274,4 +274,5 @@ class SecurityTest(GdBaseTestClass):
                                self.cert_security.remove_bond(self.dut_security.get_address(),
                                                               common.BluetoothAddressTypeEnum.PUBLIC_DEVICE_ADDRESS)

                                time.sleep(.1)
                                self.dut_security.wait_for_disconnect_event()
                                self.cert_security.wait_for_disconnect_event()
+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;
}
Loading