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

Commit 08143ed9 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5968679 from 074388a9 to qt-qpr2-release

Change-Id: I03a4e1138516a3d0e4cb98963f773c23a4f1f2da
parents cd11c5c9 074388a9
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -195,7 +195,14 @@ bt_status_t btif_queue_connect_next(void) {


  LOG_INFO(LOG_TAG, "%s: executing connection request: %s", __func__,
  LOG_INFO(LOG_TAG, "%s: executing connection request: %s", __func__,
           head.ToString().c_str());
           head.ToString().c_str());
  return head.connect();
  bt_status_t b_status = head.connect();
  if (b_status != BT_STATUS_SUCCESS) {
    LOG_INFO(LOG_TAG,
             "%s: connect %s failed, advance to next scheduled connection.",
             __func__, head.ToString().c_str());
    btif_queue_advance();
  }
  return b_status;
}
}


/*******************************************************************************
/*******************************************************************************
+43 −0
Original line number Original line Diff line number Diff line
@@ -97,6 +97,49 @@ TEST_F(BtifProfileQueueTest, test_connect) {
  EXPECT_EQ(sResult, UUID1_ADDR1);
  EXPECT_EQ(sResult, UUID1_ADDR1);
}
}


static bt_status_t test_connect_cb_fail(RawAddress* bda, uint16_t uuid) {
  sResult = UNKNOWN;
  if (*bda == BtifProfileQueueTest::kTestAddr1) {
    if (uuid == BtifProfileQueueTest::kTestUuid1) {
      sResult = UUID1_ADDR1;
    } else if (uuid == BtifProfileQueueTest::kTestUuid2) {
      sResult = UUID2_ADDR1;
    }
  } else if (*bda == BtifProfileQueueTest::kTestAddr2) {
    if (uuid == BtifProfileQueueTest::kTestUuid1) {
      sResult = UUID1_ADDR2;
    } else if (uuid == BtifProfileQueueTest::kTestUuid2) {
      sResult = UUID2_ADDR2;
    }
  }
  return BT_STATUS_BUSY;
}

TEST_F(BtifProfileQueueTest, test_connect_fail_still_can_advance_the_queue) {
  sResult = NOT_SET;
  // First connect-message for UUID1-ADDR1 is executed, but does not be removed
  // from connect-queue yet.
  btif_queue_connect(kTestUuid1, &kTestAddr1, test_connect_cb);
  EXPECT_EQ(sResult, UUID1_ADDR1);
  sResult = NOT_SET;
  // Second connect-message for UUID2-ADDR1 be pushed into connect-queue, but is
  // not executed
  btif_queue_connect(kTestUuid2, &kTestAddr1, test_connect_cb_fail);
  EXPECT_EQ(sResult, NOT_SET);
  // Third connect-message for UUID1-ADDR2 be pushed into connect-queue, but is
  // not executed
  btif_queue_connect(kTestUuid1, &kTestAddr2, test_connect_cb_fail);
  EXPECT_EQ(sResult, NOT_SET);
  // Fourth connect-message for UUID2-ADDR2 be pushed into connect-queue, but is
  // not executed
  btif_queue_connect(kTestUuid2, &kTestAddr2, test_connect_cb_fail);
  EXPECT_EQ(sResult, NOT_SET);
  // removed First connect-message from connect-queue, check it can advance to
  // subsequent connect-message.
  btif_queue_advance();
  EXPECT_EQ(sResult, UUID2_ADDR2);
}

TEST_F(BtifProfileQueueTest, test_connect_same_uuid_do_not_repeat) {
TEST_F(BtifProfileQueueTest, test_connect_same_uuid_do_not_repeat) {
  sResult = NOT_SET;
  sResult = NOT_SET;
  btif_queue_connect(kTestUuid1, &kTestAddr1, test_connect_cb);
  btif_queue_connect(kTestUuid1, &kTestAddr1, test_connect_cb);
+8 −5
Original line number Original line Diff line number Diff line
@@ -4305,12 +4305,15 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
      }
      }
    }
    }


    if (!addr_matched) {
    /* p_auth_complete_callback might have freed the p_dev_rec, ensure it exists
      /* Don't callback unless this Connection-Complete-failure event has the
     * before accessing */
       * same mac address as the bonding device */
    p_dev_rec = btm_find_dev(bda);
    if (!p_dev_rec) {
      /* Don't callback when device security record was removed */
      VLOG(1) << __func__
      VLOG(1) << __func__
              << ": Different mac addresses: pairing_bda=" << btm_cb.pairing_bda
              << ": device security record associated with this bda has been "
              << ", bda=" << bda << ", do not callback";
                 "removed! bda="
              << bda << ", do not callback!";
      return;
      return;
    }
    }