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

Commit 25b716ca authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

L2CAP: Add Classic Fixed Channel APIs am: d91c695b

am: 3ad43ec2

Change-Id: I7588e0514195790cd1ed551ab04c8936b9cec8a8
parents 4df87196 3ad43ec2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@ filegroup {
    name: "BluetoothL2capSources",
    srcs: [
        "l2cap_layer.cc",
        "classic_fixed_channel.cc",
        "classic_fixed_channel_manager.cc",
        "classic_fixed_channel_service.cc",
    ],
}

+7 −0
Original line number Diff line number Diff line
@@ -29,5 +29,12 @@ constexpr Cid kLastFixedChannel = 63;
constexpr Cid kFirstDynamicChannel = kLastFixedChannel + 1;
constexpr Cid kLastDynamicChannel = (uint16_t)(0xffff + 1);

constexpr Cid kClassicSignallingCid = 1;
constexpr Cid kConnectionlessCid = 2;
constexpr Cid kLeAttributeCid = 4;
constexpr Cid kLeSignallingCid = 5;
constexpr Cid kSmpCid = 6;
constexpr Cid kSmpBrCid = 7;

}  // namespace l2cap
}  // namespace bluetooth
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "l2cap/classic_fixed_channel.h"

namespace bluetooth {
namespace l2cap {
void ClassicFixedChannel::RegisterOnCloseCallback(os::Handler* handler, OnCloseCallback callback) {}
void ClassicFixedChannel::Acquire() {}
void ClassicFixedChannel::Release() {}
common::BidiQueueEnd<packet::PacketView<packet::kLittleEndian>, packet::BasePacketBuilder>*
ClassicFixedChannel::GetQueueUpEnd() const {
  return nullptr;
}
}  // namespace l2cap
}  // namespace bluetooth
 No newline at end of file
+71 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include "common/bidi_queue.h"
#include "common/callback.h"
#include "os/handler.h"
#include "packet/base_packet_builder.h"
#include "packet/packet_view.h"

namespace bluetooth {
namespace l2cap {

/**
 * L2CAP fixed channel object. When a new object is created, it must be
 * acquired through calling {@link FixedChannel#Acquire()} within X seconds.
 * Otherwise, {@link FixeChannel#Release()} will be called automatically.
 *
 */
class ClassicFixedChannel {
 public:
  using OnCloseCallback = common::Callback<void()>;

  /**
   * Register close callback. If close callback is registered, when a channel is closed, the channel's resource will
   * only be freed after on_close callback is invoked. Otherwise, if no on_close callback is registered, the channel's
   * resource will be freed immediately after closing.
   *
   * @param on_close The callback invoked upon channel closing.
   */
  void RegisterOnCloseCallback(os::Handler* handler, OnCloseCallback on_close);

  /**
   * Indicate that this Fixed Channel is being used. This will prevent ACL
   * connection from being disconnected.
   */
  void Acquire();

  /**
   * Indicate that this Fixed Channel is no longer being used. ACL connection
   * will be disconnected after X seconds if no other DynamicChannel is connected
   * or no other Fixed Channel is using this ACL connection. However a module can
   * still receive data on this channel as long as it remains open.
   */
  void Release();

  /**
   * This method will retrieve the data channel queue to send and receive packets.
   *
   * {@see BidiQueueEnd}
   *
   * @return The upper end of a bi-directional queue.
   */
  common::BidiQueueEnd<packet::PacketView<packet::kLittleEndian>, packet::BasePacketBuilder>* GetQueueUpEnd() const;
};

}  // namespace l2cap
}  // namespace bluetooth
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "l2cap/classic_fixed_channel_manager.h"

namespace bluetooth {
namespace l2cap {

bool ClassicFixedChannelManager::ConnectServices(common::Address device,
                                                 OnConnectionFailureCallback on_connection_failure,
                                                 os::Handler* handler) {
  return false;
}

bool ClassicFixedChannelManager::RegisterService(Cid cid, const SecurityPolicy& security_policy,
                                                 OnRegistrationCompleteCallback on_registration_complete,
                                                 OnConnectionOpenCallback on_connection_open, os::Handler* handler) {
  return true;
}

}  // namespace l2cap
}  // namespace bluetooth
 No newline at end of file
Loading