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

Commit a1f9c1b1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I6d4a14ce,I233fe305 into tm-dev

* changes:
  Cert: Fix test infra to meet latest environment requirement
  GATT: Add more logs in GATT to help with debugging
parents e3d987d9 0077bd31
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ LOCAL_target_executables := \
	$(TARGET_OUT_EXECUTABLES)/bluetooth_stack_with_facade

LOCAL_target_libraries := \
	$(TARGET_OUT_SHARED_LIBRARIES)/android.system.suspend.control-V1-ndk.so \
	$(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so \
	$(TARGET_OUT_SHARED_LIBRARIES)/libbluetooth_gd.so \
	$(TARGET_OUT_SHARED_LIBRARIES)/libgrpc++_unsecure.so \
+2 −3
Original line number Diff line number Diff line
@@ -491,8 +491,6 @@ class GdAndroidDevice(GdDeviceBase):

        # Push test binaries
        self.push_or_die(os.path.join(get_gd_root(), "target", "bluetooth_stack_with_facade"), "system/bin")
        self.push_or_die(
            os.path.join(get_gd_root(), "target", "android.system.suspend.control-V1-ndk.so"), "system/lib64")
        self.push_or_die(os.path.join(get_gd_root(), "target", "libbluetooth_gd.so"), "system/lib64")
        self.push_or_die(os.path.join(get_gd_root(), "target", "libgrpc++_unsecure.so"), "system/lib64")
        self.push_or_die(os.path.join(get_gd_root(), "target", "libgrpc++.so"), "system/lib64")
@@ -529,7 +527,8 @@ class GdAndroidDevice(GdDeviceBase):
        self.ensure_no_output(self.adb.shell("settings put global ble_scan_always_enabled 0"))
        self.adb.shell("cmd bluetooth_manager disable")
        device_bt_state = int(self.adb.shell("settings get global bluetooth_on"))
        asserts.assert_equal(device_bt_state, 0, "Failed to disable Bluetooth on device %s %s" % (self.label, self.serial_number))
        asserts.assert_equal(device_bt_state, 0,
                             "Failed to disable Bluetooth on device %s %s" % (self.label, self.serial_number))
        logging.info("Bluetooth disabled on device %s %s" % (self.label, self.serial_number))

        # Start logcat logging
+8 −4
Original line number Diff line number Diff line
@@ -61,9 +61,10 @@ class GdSl4aBaseTestClass(BaseTestClass):
        # Enable full btsnoop log
        self.dut.adb.root()
        self.dut.adb.shell("setprop persist.bluetooth.btsnooplogmode full")
        getprop_result = self.dut.adb.shell("getprop persist.bluetooth.btsnooplogmode") == "full"
        if not getprop_result:
            self.dut.log.warning("Failed to enable Bluetooth Hci Snoop Logging.")
        getprop_result = self.dut.adb.getprop("persist.bluetooth.btsnooplogmode")
        if getprop_result is None or ("full" not in getprop_result.lower()):
            self.dut.log.warning(
                "Failed to enable Bluetooth Hci Snoop Logging, getprop returned {}".format(getprop_result))

        self.ble = BleLib(dut=self.dut)

@@ -95,7 +96,10 @@ class GdSl4aBaseTestClass(BaseTestClass):
        # Make sure BLE is disabled and Bluetooth is disabled after test
        self.dut.sl4a.bluetoothDisableBLE()
        disable_bluetooth(self.dut.sl4a, self.dut.ed)
        try:
            self.cert.rootservice.StopStack(facade_rootservice.StopStackRequest())
        except Exception:
            logging.error("Failed to stop CERT stack")

        # TODO: split cert logcat logs into individual tests
        current_test_dir = get_current_context().get_full_output_path()
+15 −14
Original line number Diff line number Diff line
@@ -255,8 +255,7 @@ void bta_gattc_process_api_open(const tBTA_GATTC_DATA* p_msg) {

  tBTA_GATTC_RCB* p_clreg = bta_gattc_cl_get_regcb(p_msg->api_conn.client_if);
  if (!p_clreg) {
    LOG(ERROR) << __func__
               << ": Failed, unknown client_if=" << +p_msg->api_conn.client_if;
    LOG_ERROR("Failed, unknown client_if=%d", +p_msg->api_conn.client_if);
    return;
  }

@@ -268,10 +267,10 @@ void bta_gattc_process_api_open(const tBTA_GATTC_DATA* p_msg) {
  tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_alloc_clcb(
      p_msg->api_conn.client_if, p_msg->api_conn.remote_bda,
      p_msg->api_conn.transport);
  if (p_clcb != NULL) {
  if (p_clcb != nullptr) {
    bta_gattc_sm_execute(p_clcb, event, p_msg);
  } else {
    LOG(ERROR) << "No resources to open a new connection.";
    LOG_ERROR("No resources to open a new connection.");

    bta_gattc_send_open_cback(p_clreg, GATT_NO_RESOURCES,
                              p_msg->api_conn.remote_bda, GATT_INVALID_CONN_ID,
@@ -367,7 +366,6 @@ void bta_gattc_open(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
                    p_data->api_conn.transport, p_data->api_conn.opportunistic,
                    p_data->api_conn.initiating_phys)) {
    LOG(ERROR) << "Connection open failure";

    bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data);
    return;
  }
@@ -396,8 +394,8 @@ static void bta_gattc_init_bk_conn(const tBTA_GATTC_API_OPEN* p_data,
  /* always call open to hold a connection */
  if (!GATT_Connect(p_data->client_if, p_data->remote_bda, false,
                    p_data->transport, false)) {
    LOG(ERROR) << __func__
               << " unable to connect to remote bd_addr=" << p_data->remote_bda;
    LOG_ERROR("Unable to connect to remote bd_addr=%s",
              p_data->remote_bda.ToString().c_str());
    bta_gattc_send_open_cback(p_clreg, GATT_ERROR, p_data->remote_bda,
                              GATT_INVALID_CONN_ID, BT_TRANSPORT_LE, 0);
    return;
@@ -406,7 +404,7 @@ static void bta_gattc_init_bk_conn(const tBTA_GATTC_API_OPEN* p_data,
  uint16_t conn_id;
  if (!GATT_GetConnIdIfConnected(p_data->client_if, p_data->remote_bda,
                                 &conn_id, p_data->transport)) {
    LOG_WARN("Not a connected remote device");
    LOG_INFO("Not a connected remote device yet");
    return;
  }

@@ -442,7 +440,9 @@ void bta_gattc_cancel_bk_conn(const tBTA_GATTC_API_CANCEL_OPEN* p_data) {
    if (GATT_CancelConnect(p_data->client_if, p_data->remote_bda, false)) {
      cb_data.status = GATT_SUCCESS;
    } else {
      LOG(ERROR) << __func__ << ": failed";
      LOG_ERROR("failed for client_if=%d, remote_bda=%s, is_direct=false",
                static_cast<int>(p_data->client_if),
                p_data->remote_bda.ToString().c_str());
    }
  }
  p_clreg = bta_gattc_cl_get_regcb(p_data->client_if);
@@ -577,16 +577,17 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
  tBTA_GATTC cb_data = {
      .close =
          {
              .client_if = p_clcb->p_rcb->client_if,
              .conn_id = p_clcb->bta_conn_id,
              .reason = GATT_CONN_OK,
              .remote_bda = p_clcb->bda,
              .status = GATT_SUCCESS,
              .client_if = p_clcb->p_rcb->client_if,
              .remote_bda = p_clcb->bda,
              .reason = GATT_CONN_OK,
          },
  };

  if (p_clcb->transport == BT_TRANSPORT_BR_EDR)
  if (p_clcb->transport == BT_TRANSPORT_BR_EDR) {
    bta_sys_conn_close(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
  }

  bta_gattc_clcb_dealloc(p_clcb);

+8 −6
Original line number Diff line number Diff line
@@ -489,18 +489,20 @@ void bta_gatts_close(UNUSED_ATTR tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) {

  if (GATT_GetConnectionInfor(p_msg->hdr.layer_specific, &gatt_if, remote_bda,
                              &transport)) {
    if (GATT_Disconnect(p_msg->hdr.layer_specific) != GATT_SUCCESS) {
      LOG(ERROR) << __func__
                 << ": fail conn_id=" << loghex(p_msg->hdr.layer_specific);
    } else {
      status = GATT_SUCCESS;
    LOG_DEBUG("Disconnecting gatt_if=%d, remote_bda=%s, transport=%d", +gatt_if,
              remote_bda.ToString().c_str(), transport);
    status = GATT_Disconnect(p_msg->hdr.layer_specific);
    if (status != GATT_SUCCESS) {
      LOG_ERROR("fail conn_id=%d", +p_msg->hdr.layer_specific);
      status = GATT_ERROR;
    }

    p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);

    if (p_rcb && p_rcb->p_cback) {
      if (transport == BT_TRANSPORT_BR_EDR)
      if (transport == BT_TRANSPORT_BR_EDR) {
        bta_sys_conn_close(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
      }

      tBTA_GATTS bta_gatts;
      bta_gatts.status = status;
Loading