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

Commit c83c8d80 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang Committed by Automerger Merge Worker
Browse files

Merge changes from topic "qual-mps-sdp" am: 4270c1d0

parents efd6b6e2 4270c1d0
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ static int add_pbapc_sdp(const bluetooth_sdp_pce_record* rec);
static int add_pbaps_sdp(const bluetooth_sdp_pse_record* rec);
static int add_opps_sdp(const bluetooth_sdp_ops_record* rec);
static int add_saps_sdp(const bluetooth_sdp_sap_record* rec);
static int add_mps_sdp(const bluetooth_sdp_mps_record* rec);
bt_status_t remove_sdp_record(int record_id);
static int free_sdp_slot(int id);

@@ -376,6 +377,9 @@ void on_create_record_event(int id) {
        handle = add_pbapc_sdp(&record->pce);
        service_id = BTA_PCE_SERVICE_ID;
        break;
      case SDP_TYPE_MPS:
        handle = add_mps_sdp(&record->mps);
        break;
      default:
        BTIF_TRACE_DEBUG("Record type %d is not supported", record->hdr.type);
        break;
@@ -854,3 +858,52 @@ static int add_saps_sdp(const bluetooth_sdp_sap_record* rec) {
  }
  return sdp_handle;
}

/* Create a Multi-Profile Specification SDP record based on information stored
 * in a bluetooth_sdp_mps_record */
static int add_mps_sdp(const bluetooth_sdp_mps_record* rec) {
  uint16_t service = UUID_SERVCLASS_MPS_SC;
  uint16_t browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
  bool status = true;
  uint32_t sdp_handle = 0;

  sdp_handle = SDP_CreateRecord();
  if (sdp_handle == 0) {
    LOG_ERROR("Unable to register MPS record");
    return sdp_handle;
  }

  status &= SDP_AddServiceClassIdList(sdp_handle, 1, &service);

  /* Add in the Bluetooth Profile Descriptor List */
  status &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_MPS_PROFILE,
                                         rec->hdr.profile_version);

  /* Add supported scenarios MPSD */
  status &= SDP_AddAttribute(sdp_handle, ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPSD,
                             UINT_DESC_TYPE, (uint32_t)8,
                             (uint8_t*)&rec->supported_scenarios_mpsd);
  /* Add supported scenarios MPMD */
  status &= SDP_AddAttribute(sdp_handle, ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPMD,
                             UINT_DESC_TYPE, (uint32_t)8,
                             (uint8_t*)&rec->supported_scenarios_mpmd);
  /* Add supported dependencies */
  status &= SDP_AddAttribute(sdp_handle, ATTR_ID_MPS_SUPPORTED_DEPENDENCIES,
                             UINT_DESC_TYPE, (uint32_t)2,
                             (uint8_t*)&rec->supported_dependencies);

  /* Make the service browseable */
  status &=
      SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse);

  if (!status) {
    SDP_DeleteRecord(sdp_handle);
    sdp_handle = 0;
    APPL_TRACE_ERROR("%s() FAILED", __func__);
    return sdp_handle;
  }
  bta_sys_add_uuid(service); /* UUID_SERVCLASS_MPS_SC */
  APPL_TRACE_DEBUG("%s():  SDP Registered (handle 0x%08x)", __func__,
                   sdp_handle);
  return sdp_handle;
}
+6 −1
Original line number Diff line number Diff line
@@ -253,7 +253,12 @@ impl IBluetoothCallback for BtCallback {
    ) {
    }

    fn on_sdp_record_created(&self, _record: BtSdpRecord, _handle: i32) {}
    fn on_sdp_record_created(&self, record: BtSdpRecord, handle: i32) {
        print_info!("SDP record handle={} created", handle);
        if let BtSdpRecord::Mps(_) = record {
            self.context.lock().unwrap().mps_sdp_handle = Some(handle);
        }
    }
}

impl RPCProxy for BtCallback {
+24 −8
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use crate::ClientContext;
use crate::{console_red, console_yellow, print_error, print_info};
use bt_topshim::btif::{BtConnectionState, BtStatus, BtTransport};
use bt_topshim::profiles::hid_host::BthhReportType;
use bt_topshim::profiles::sdp::{BtSdpMpsRecord, BtSdpRecord};
use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState};
use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQA};
use btstack::bluetooth_gatt::{GattWriteType, IBluetoothGatt, ScanSettings, ScanType};
@@ -1688,14 +1689,29 @@ impl CommandHandler {
                    .unwrap()
                    .set_battery_level(level);
            }
            "enable" | "disable" => {
                self.context
                    .lock()
                    .unwrap()
                    .telephony_dbus
            "enable" => {
                let mut context = self.lock_context();
                context.telephony_dbus.as_mut().unwrap().set_phone_ops_enabled(true);
                if context.mps_sdp_handle.is_none() {
                    let success = context
                        .adapter_dbus
                        .as_mut()
                        .unwrap()
                    .set_phone_ops_enabled(get_arg(args, 0)? == "enable");
                        .create_sdp_record(BtSdpRecord::Mps(BtSdpMpsRecord::default()));
                    if !success {
                        return Err(format!("Failed to create SDP record").into());
                    }
                }
            }
            "disable" => {
                let mut context = self.lock_context();
                context.telephony_dbus.as_mut().unwrap().set_phone_ops_enabled(false);
                if let Some(handle) = context.mps_sdp_handle.take() {
                    let success = context.adapter_dbus.as_mut().unwrap().remove_sdp_record(handle);
                    if !success {
                        return Err(format!("Failed to remove SDP record").into());
                    }
                }
            }
            "incoming-call" => {
                let success = self
+21 −2
Original line number Diff line number Diff line
@@ -7,8 +7,9 @@ use bt_topshim::btif::{
use bt_topshim::profiles::gatt::{AdvertisingStatus, GattStatus, LePhy};
use bt_topshim::profiles::hid_host::BthhReportType;
use bt_topshim::profiles::sdp::{
    BtSdpDipRecord, BtSdpHeaderOverlay, BtSdpMasRecord, BtSdpMnsRecord, BtSdpOpsRecord,
    BtSdpPceRecord, BtSdpPseRecord, BtSdpRecord, BtSdpSapRecord, BtSdpType, SupportedFormatsList,
    BtSdpDipRecord, BtSdpHeaderOverlay, BtSdpMasRecord, BtSdpMnsRecord, BtSdpMpsRecord,
    BtSdpOpsRecord, BtSdpPceRecord, BtSdpPseRecord, BtSdpRecord, BtSdpSapRecord, BtSdpType,
    SupportedDependencies, SupportedFormatsList, SupportedScenarios,
};
use bt_topshim::profiles::socket::SocketType;
use bt_topshim::profiles::ProfileConnectionState;
@@ -181,6 +182,17 @@ struct BtSdpDipRecordDBus {
    primary_record: bool,
}

impl_dbus_arg_from_into!(SupportedScenarios, Vec<u8>);
impl_dbus_arg_from_into!(SupportedDependencies, Vec<u8>);

#[dbus_propmap(BtSdpMpsRecord)]
pub struct BtSdpMpsRecordDBus {
    hdr: BtSdpHeaderOverlay,
    supported_scenarios_mpsd: SupportedScenarios,
    supported_scenarios_mpmd: SupportedScenarios,
    supported_dependencies: SupportedDependencies,
}

fn read_propmap_value<T: 'static + DirectDBus>(
    propmap: &dbus::arg::PropMap,
    key: &str,
@@ -278,6 +290,10 @@ impl DBusArg for BtSdpRecord {
                let arg_0 = parse_propmap_value::<BtSdpDipRecord>(&data, "0")?;
                BtSdpRecord::Dip(arg_0)
            }
            BtSdpType::Mps => {
                let arg_0 = parse_propmap_value::<BtSdpMpsRecord>(&data, "0")?;
                BtSdpRecord::Mps(arg_0)
            }
        };
        Ok(record)
    }
@@ -314,6 +330,9 @@ impl DBusArg for BtSdpRecord {
            BtSdpRecord::Dip(dip_record) => {
                write_propmap_value::<BtSdpDipRecord>(&mut map, dip_record, &String::from("0"))?
            }
            BtSdpRecord::Mps(mps_record) => {
                write_propmap_value::<BtSdpMpsRecord>(&mut map, mps_record, &String::from("0"))?
            }
        }
        Ok(map)
    }
+4 −0
Original line number Diff line number Diff line
@@ -127,6 +127,9 @@ pub(crate) struct ClientContext {

    /// The schedule when a socket is connected.
    socket_test_schedule: Option<SocketSchedule>,

    /// The handle of the SDP record for MPS (Multi-Profile Specification).
    mps_sdp_handle: Option<i32>,
}

impl ClientContext {
@@ -170,6 +173,7 @@ impl ClientContext {
            is_restricted,
            gatt_client_context: GattClientContext::new(),
            socket_test_schedule: None,
            mps_sdp_handle: None,
        }
    }

Loading