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

Commit afc7a799 authored by Zach Johnson's avatar Zach Johnson
Browse files

Fold security level calls into hidd_conn_reg

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Id30b0dc46f9fd5487256420309c015f39fffc47d
parent 6434f6ad
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
#include <string.h>

#include "bt_types.h"
#include "bta/include/bta_api.h"
#include "btm_api.h"
#include "btu.h"
#include "hidd_api.h"
@@ -91,19 +90,6 @@ tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback) {

  if (host_cback == NULL) return HID_ERR_INVALID_PARAM;

  if (!BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_HIDD_SEC_CTRL,
                                  BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT,
                                  HID_PSM_CONTROL)) {
    HIDD_TRACE_ERROR("Security Registration 1 failed");
    return (HID_ERR_NO_RESOURCES);
  }

  if (!BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_HIDD_INTR, BTM_SEC_NONE,
                                  HID_PSM_INTERRUPT)) {
    HIDD_TRACE_ERROR("Security Registration 5 failed");
    return (HID_ERR_NO_RESOURCES);
  }

  /* Register with L2CAP */
  st = hidd_conn_reg();
  if (st != HID_SUCCESS) return st;
+14 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "hidd_api.h"
#include "hidd_int.h"

#include "bta/include/bta_api.h"
#include "osi/include/osi.h"
#include "stack/btm/btm_sec.h"

@@ -758,6 +759,19 @@ tHID_STATUS hidd_conn_reg(void) {
  hd_cb.l2cap_intr_cfg.flush_to_present = TRUE;
  hd_cb.l2cap_intr_cfg.flush_to = HID_DEV_FLUSH_TO;

  if (!BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_HIDD_SEC_CTRL,
                                  BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT,
                                  HID_PSM_CONTROL)) {
    HIDD_TRACE_ERROR("Security Registration 1 failed");
    return (HID_ERR_NO_RESOURCES);
  }

  if (!BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_HIDD_INTR, BTM_SEC_NONE,
                                  HID_PSM_INTERRUPT)) {
    HIDD_TRACE_ERROR("Security Registration 5 failed");
    return (HID_ERR_NO_RESOURCES);
  }

  if (!L2CA_Register(HID_PSM_CONTROL, (tL2CAP_APPL_INFO*)&dev_reg_info,
                     false /* enable_snoop */, nullptr, hd_cb.l2cap_cfg.mtu)) {
    HIDD_TRACE_ERROR("HID Control (device) registration failed");