void
BluetoothProfileController::SetupProfiles(bool aAssignServiceClass)
{
    MOZ_ASSERT(NS_IsMainThread());

    /**
     * When a service class is assigned, only its corresponding profile is put
     * into array.
     */
    if (aAssignServiceClass) {
        AddProfileWithServiceClass(mTarget.service);
        return;
    }

    // For a disconnect request, all connected profiles are put into array.
    if (!mConnect) {
        AddProfile(BluetoothHidManager::Get(), true);
        AddProfile(BluetoothOppManager::Get(), true);
        AddProfile(BluetoothA2dpManager::Get(), true);
        AddProfile(BluetoothHfpManager::Get(), true);
        return;
    }

    /**
     * For a connect request, put multiple profiles into array and connect to
     * all of them sequencely.
     */
    bool hasAudio = HAS_AUDIO(mTarget.cod);
    bool hasObjectTransfer = HAS_OBJECT_TRANSFER(mTarget.cod);
    bool hasRendering = HAS_RENDERING(mTarget.cod);
    bool isPeripheral = IS_PERIPHERAL(mTarget.cod);

    NS_ENSURE_TRUE_VOID(hasAudio || hasObjectTransfer ||
                        hasRendering || isPeripheral);

    /**
     * Connect to HFP/HSP first. Then, connect A2DP if Rendering bit is set.
     * It's almost impossible to send file to a remote device which is an Audio
     * device or a Rendering device, so we won't connect OPP in that case.
     */
    if (hasAudio) {
        AddProfile(BluetoothHfpManager::Get());
    }
    if (hasRendering) {
        AddProfile(BluetoothA2dpManager::Get());
    }
    if (hasObjectTransfer && !hasAudio && !hasRendering) {
        AddProfile(BluetoothOppManager::Get());
    }
    if (isPeripheral) {
        AddProfile(BluetoothHidManager::Get());
    }
}
Exemplo n.º 2
0
void
BluetoothProfileController::SetupProfiles(bool aAssignServiceClass)
{
    MOZ_ASSERT(NS_IsMainThread());

    /**
     * When a service class is assigned, only its corresponding profile is put
     * into array.
     */
    if (aAssignServiceClass) {
        AddProfileWithServiceClass(mTarget.service);
        return;
    }

    // For a disconnect request, all connected profiles are put into array.
    if (!mConnect) {
        AddProfile(BluetoothHidManager::Get(), true);
        AddProfile(BluetoothA2dpManager::Get(), true);
        AddProfile(BluetoothHfpManager::Get(), true);
        return;
    }

    /**
     * For a connect request, put multiple profiles into array and connect to
     * all of them sequencely.
     */
    bool hasAudio = HAS_AUDIO(mTarget.cod);
    bool hasRendering = HAS_RENDERING(mTarget.cod);
    bool isPeripheral = IS_PERIPHERAL(mTarget.cod);

    NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral);

    /**
     * Connect to HFP/HSP first. Then, connect A2DP if Rendering bit is set.
     */
    if (hasAudio) {
        AddProfile(BluetoothHfpManager::Get());
    }
    if (hasRendering) {
        AddProfile(BluetoothA2dpManager::Get());
    }
    if (isPeripheral) {
        AddProfile(BluetoothHidManager::Get());
    }
}
Exemplo n.º 3
0
void
BluetoothProfileController::SetupProfiles(bool aAssignServiceClass)
{
  MOZ_ASSERT(NS_IsMainThread());

  /**
   * When a service class is assigned, only its corresponding profile is put
   * into array.
   */
  if (aAssignServiceClass) {
    AddProfileWithServiceClass(mTarget.service);
    return;
  }

  // For a disconnect request, all connected profiles are put into array.
  if (!mConnect) {
    AddProfile(BluetoothHidManager::Get(), true);
    AddProfile(BluetoothAvrcpManager::Get(), true);
    AddProfile(BluetoothA2dpManager::Get(), true);
    AddProfile(BluetoothHfpManager::Get(), true);
    return;
  }

  /**
   * For a connect request, put multiple profiles into array and connect to
   * all of them sequencely.
   */
  bool hasAudio = HAS_AUDIO(mTarget.cod);
  bool hasRendering = HAS_RENDERING(mTarget.cod);
  bool isPeripheral = IS_PERIPHERAL(mTarget.cod);
  bool isRemoteControl = IS_REMOTE_CONTROL(mTarget.cod);
  bool isKeyboard = IS_KEYBOARD(mTarget.cod);
  bool isPointingDevice = IS_POINTING_DEVICE(mTarget.cod);
  bool isInvalid = IS_INVALID(mTarget.cod);

  // The value of CoD is invalid. Since the device didn't declare its class of
  // device properly, we assume the device may support all of these profiles.
  // Note the invalid CoD from bluedroid callback usually results from
  // NFC-triggered direct pairing for no EIR query records.
  if (isInvalid) {
    AddProfile(BluetoothHfpManager::Get());
    AddProfile(BluetoothA2dpManager::Get());
    AddProfile(BluetoothAvrcpManager::Get()); // register after A2DP
    return;
  }

  NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral);

  // Audio bit should be set if remote device supports HFP/HSP.
  if (hasAudio) {
    AddProfile(BluetoothHfpManager::Get());
  }

  // Rendering bit should be set if remote device supports A2DP.
  // A device which supports AVRCP should claim that it's a peripheral and it's
  // a remote control.
  if (hasRendering || (isPeripheral && isRemoteControl)) {
    AddProfile(BluetoothA2dpManager::Get());
    AddProfile(BluetoothAvrcpManager::Get()); // register after A2DP
  }

  // A device which supports HID should claim that it's a peripheral and it's
  // either a keyboard, a pointing device, or both.
  if (isPeripheral && (isKeyboard || isPointingDevice)) {
    AddProfile(BluetoothHidManager::Get());
  }
}