当前位置: 首页>>代码示例>>C++>>正文


C++ BluetoothProfileManagerBase::GetAddress方法代码示例

本文整理汇总了C++中BluetoothProfileManagerBase::GetAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ BluetoothProfileManagerBase::GetAddress方法的具体用法?C++ BluetoothProfileManagerBase::GetAddress怎么用?C++ BluetoothProfileManagerBase::GetAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BluetoothProfileManagerBase的用法示例。


在下文中一共展示了BluetoothProfileManagerBase::GetAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cmd

nsresult
AudioManager::Observe(nsISupports* aSubject,
                      const char* aTopic,
                      const PRUnichar* aData)
{
    if ((strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED_ID) == 0) ||
            (strcmp(aTopic, BLUETOOTH_A2DP_STATUS_CHANGED_ID) == 0)) {
        nsresult rv;
        int status = NS_ConvertUTF16toUTF8(aData).ToInteger(&rv);
        if (NS_FAILED(rv) || status > 1 || status < 0) {
            NS_WARNING(nsPrintfCString("Wrong data value of %s", aTopic).get());
            return NS_ERROR_FAILURE;
        }

        nsAutoString tmp_address;
        BluetoothProfileManagerBase* profile =
            static_cast<BluetoothProfileManagerBase*>(aSubject);
        profile->GetAddress(tmp_address);
        nsAutoCString address = NS_ConvertUTF16toUTF8(tmp_address);

        audio_policy_dev_state_t audioState = status ?
                                              AUDIO_POLICY_DEVICE_STATE_AVAILABLE :
                                              AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;

        if (!strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
            AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
                                                  audioState, address.get());
            AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
                                                  audioState, address.get());
            if (audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
                String8 cmd;
                cmd.appendFormat("bt_samplerate=%d", kBtSampleRate);
                AudioSystem::setParameters(0, cmd);
                SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_BT_SCO);
            } else {
                // only force to none if the current force setting is bt_sco
                int32_t force;
                GetForceForUse(nsIAudioManager::USE_COMMUNICATION, &force);
                if (force == nsIAudioManager::FORCE_BT_SCO)
                    SetForceForUse(nsIAudioManager::USE_COMMUNICATION, nsIAudioManager::FORCE_NONE);
            }
        } else if (!strcmp(aTopic, BLUETOOTH_A2DP_STATUS_CHANGED_ID)) {
            AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP,
                                                  audioState, address.get());
            if (audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
                String8 cmd("bluetooth_enabled=true");
                AudioSystem::setParameters(0, cmd);
                cmd.setTo("A2dpSuspended=false");
                AudioSystem::setParameters(0, cmd);
            }
        }
    } else {
        NS_WARNING("Unexpected topic in AudioManager");
        return NS_ERROR_FAILURE;
    }

    return NS_OK;
}
开发者ID:hibrium,项目名称:Pale-Moon,代码行数:58,代码来源:AudioManager.cpp

示例2: DispatchBluetoothReply

nsresult
BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
  uint16_t aServiceUuid, BluetoothReplyRunnable* aRunnable)
{
  MOZ_ASSERT(NS_IsMainThread());

  if (!IsReady()) {
    NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth service is not ready yet!");
    DispatchBluetoothReply(aRunnable, BluetoothValue(), errorStr);
    return NS_OK;
  }

  BluetoothProfileManagerBase* profile =
    BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
  if (!profile) {
    InfallibleTArray<BluetoothNamedValue> emptyArr;
    DispatchBluetoothReply(aRunnable, emptyArr,
                           NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE));
    return NS_OK;
  }

  nsTArray<nsString> deviceAddresses;
  if (profile->IsConnected()) {
    nsString address;
    profile->GetAddress(address);
    deviceAddresses.AppendElement(address);
  }

  int requestedDeviceCount = deviceAddresses.Length();
  if (requestedDeviceCount == 0) {
    InfallibleTArray<BluetoothNamedValue> emptyArr;
    DispatchBluetoothReply(aRunnable, emptyArr, EmptyString());
    return NS_OK;
  }

  for (int i = 0; i < requestedDeviceCount; i++) {
    // Retrieve all properties of devices
    bt_bdaddr_t addressType;
    StringToBdAddressType(deviceAddresses[i], &addressType);

    int ret = sBtInterface->get_remote_device_properties(&addressType);
    if (ret != BT_STATUS_SUCCESS) {
      DispatchBluetoothReply(aRunnable, BluetoothValue(true),
                             NS_LITERAL_STRING("GetConnectedDeviceFailed"));
      return NS_OK;
    }
  }

  sRequestedDeviceCountArray.AppendElement(requestedDeviceCount);
  sGetDeviceRunnableArray.AppendElement(aRunnable);

  return NS_OK;
}
开发者ID:MYSHLIFE,项目名称:gecko-dev,代码行数:53,代码来源:BluetoothServiceBluedroid.cpp

示例3: GetRemoteDevicePropertiesResultHandler

nsresult
BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
  uint16_t aServiceUuid, BluetoothReplyRunnable* aRunnable)
{
  MOZ_ASSERT(NS_IsMainThread());

  ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);

  BluetoothProfileManagerBase* profile =
    BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
  if (!profile) {
    DispatchReplyError(aRunnable, NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE));
    return NS_OK;
  }

  nsTArray<nsString> deviceAddresses;
  if (profile->IsConnected()) {
    nsString address;
    profile->GetAddress(address);
    deviceAddresses.AppendElement(address);
  }

  int requestedDeviceCount = deviceAddresses.Length();
  if (requestedDeviceCount == 0) {
    InfallibleTArray<BluetoothNamedValue> emptyArr;
    DispatchReplySuccess(aRunnable, emptyArr);
    return NS_OK;
  }

  sRequestedDeviceCountArray.AppendElement(requestedDeviceCount);
  sGetDeviceRunnableArray.AppendElement(aRunnable);

  for (int i = 0; i < requestedDeviceCount; i++) {
    // Retrieve all properties of devices
    sBtInterface->GetRemoteDeviceProperties(deviceAddresses[i],
      new GetRemoteDevicePropertiesResultHandler(deviceAddresses[i]));
  }

  return NS_OK;
}
开发者ID:Mardak,项目名称:tiles-dev,代码行数:40,代码来源:BluetoothServiceBluedroid.cpp


注:本文中的BluetoothProfileManagerBase::GetAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。