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

Commit cf102edb authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

eatt: Accept incoming Eatt connection request for uknown devices

Android checks Server Supported Feature characteristic before it allows
to create EATT channel. However for LE it is not necessary to test this
characteristic, and if remote device sends connection request it is OK
to assume EATT is supported and add it to known devices.

Bug: 235195694
Test: atest BluetoothInstrumentationTests
Tag: #feature

Change-Id: I2651e431feab4603a10a05334458009525948cf4
parent 7d9b2546
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -118,10 +118,14 @@ struct eatt_impl {
     */
    eatt_device* eatt_dev = this->find_device_by_address(bda);
    if (!eatt_dev) {
      LOG(ERROR) << __func__ << " unknown device: " << bda;
      L2CA_ConnectCreditBasedRsp(bda, identifier, lcids,
                                 L2CAP_CONN_NO_RESOURCES, NULL);
      return;
      /* If there is no device it means, Android did not read yet Server
       * supported features, but according to Core 5.3, Vol 3,  Part G, 6.2.1,
       * for LE case it is not necessary to read it before establish connection.
       * Therefore assume, device supports EATT since we got request to create
       * EATT channels. Just create device here. */
      LOG(INFO) << __func__ << " Adding device: " << bda
                << " on incoming EATT creation request";
      eatt_dev = add_eatt_device(bda);
    }

    uint16_t max_mps = controller_get_interface()->get_acl_data_size_ble();
+5 −3
Original line number Diff line number Diff line
@@ -184,13 +184,15 @@ TEST_F(EattTest, ConnectSucceed) {
TEST_F(EattTest, IncomingEattConnectionByUnknownDevice) {
  std::vector<uint16_t> incoming_cids{71, 72, 73, 74, 75};

  EXPECT_CALL(l2cap_interface_,
              ConnectCreditBasedRsp(test_address, 1, incoming_cids,
                                    L2CAP_CONN_NO_RESOURCES, _))
  EXPECT_CALL(
      l2cap_interface_,
      ConnectCreditBasedRsp(test_address, 1, incoming_cids, L2CAP_CONN_OK, _))
      .WillOnce(Return(true));

  l2cap_app_info_.pL2CA_CreditBasedConnectInd_Cb(
      test_address, incoming_cids, BT_PSM_EATT, EATT_MIN_MTU_MPS, 1);

  DisconnectEattDevice(incoming_cids);
}

TEST_F(EattTest, IncomingEattConnectionByKnownDevice) {