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

Commit caec34bd authored by Jayden Kim's avatar Jayden Kim Committed by lianglli
Browse files

Add default implementation for Bluetooth Socket Offload

Bug: 342012881
Test: m android.hardware.bluetooth.socket-service.default
Change-Id: I63e78615f155e7cd0106253ef2b2ce3af8bb75ea
parent eb5b4885
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_binary {
    name: "android.hardware.bluetooth.socket-service.default",
    relative_install_path: "hw",
    init_rc: ["bluetooth-socket-service-default.rc"],
    vintf_fragments: [":manifest_android.hardware.bluetooth.socket-service.default.xml"],
    vendor: true,
    srcs: [
        "BluetoothSocket.cpp",
        "service.cpp",
    ],
    shared_libs: [
        "android.hardware.bluetooth.socket-V1-ndk",
        "libbase",
        "libbinder_ndk",
        "libhidlbase",
        "libutils",
        "liblog",
    ],
}

filegroup {
    name: "manifest_android.hardware.bluetooth.socket-service.default.xml",
    srcs: ["bluetooth-socket-service-default.xml"],
}
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 "BluetoothSocket.h"

using aidl::android::hardware::bluetooth::socket::Status;

namespace aidl::android::hardware::bluetooth::socket::impl {

BluetoothSocket::BluetoothSocket() {}
BluetoothSocket::~BluetoothSocket() {}

::ndk::ScopedAStatus BluetoothSocket::registerCallback(
    const std::shared_ptr<
        ::aidl::android::hardware::bluetooth::socket::IBluetoothSocketCallback>&
        in_callback) {
  if (in_callback == nullptr) {
    return ndk::ScopedAStatus::fromServiceSpecificError(STATUS_BAD_VALUE);
  }
  callback_ = in_callback;
  return ::ndk::ScopedAStatus::ok();
}
::ndk::ScopedAStatus BluetoothSocket::getSocketCapabilities(
    ::aidl::android::hardware::bluetooth::socket::SocketCapabilities*
        _aidl_return) {
  _aidl_return->leCocCapabilities.numberOfSupportedSockets = 0;
  _aidl_return->leCocCapabilities.mtu = 0;
  return ::ndk::ScopedAStatus::ok();
}
::ndk::ScopedAStatus BluetoothSocket::opened(
    const ::aidl::android::hardware::bluetooth::socket::SocketContext&
    /* in_context */) {
  return ::ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
::ndk::ScopedAStatus BluetoothSocket::closed(int64_t /*in_socketId*/) {
  return ::ndk::ScopedAStatus::ok();
}

}  // namespace aidl::android::hardware::bluetooth::socket::impl
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 <aidl/android/hardware/bluetooth/socket/BnBluetoothSocket.h>

namespace aidl::android::hardware::bluetooth::socket::impl {

class BluetoothSocket : public BnBluetoothSocket {
 public:
  BluetoothSocket();
  ~BluetoothSocket();

  ::ndk::ScopedAStatus registerCallback(
      const std::shared_ptr<::aidl::android::hardware::bluetooth::socket::
                                IBluetoothSocketCallback>& in_callback)
      override;
  ::ndk::ScopedAStatus getSocketCapabilities(
      ::aidl::android::hardware::bluetooth::socket::SocketCapabilities*
          _aidl_return) override;
  ::ndk::ScopedAStatus opened(
      const ::aidl::android::hardware::bluetooth::socket::SocketContext&
          in_context) override;
  ::ndk::ScopedAStatus closed(int64_t in_socketId) override;

 private:
  std::shared_ptr<IBluetoothSocketCallback> callback_;
};

}  // namespace aidl::android::hardware::bluetooth::socket::impl
+4 −0
Original line number Diff line number Diff line
service vendor.bluetooth.socket-default /vendor/bin/hw/android.hardware.bluetooth.socket-service.default
    class hal
    user nobody
    group nobody
+7 −0
Original line number Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="aidl">
        <name>android.hardware.bluetooth.socket</name>
        <version>1</version>
        <fqname>IBluetoothSocket/default</fqname>
    </hal>
</manifest>
Loading