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

Commit 84c0d6a4 authored by Chienyuan Huang's avatar Chienyuan Huang Committed by Automerger Merge Worker
Browse files

Merge changes from topic "Bluetooth_Ranging" into main am: 64930a63 am: bbb0d88c am: 997ede9b

parents f30401d7 997ede9b
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

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

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

#include "BluetoothChannelSoundingSession.h"

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

BluetoothChannelSounding::BluetoothChannelSounding() {}
BluetoothChannelSounding::~BluetoothChannelSounding() {}

ndk::ScopedAStatus BluetoothChannelSounding::getVendorSpecificData(
    std::optional<
        std::vector<std::optional<VendorSpecificData>>>* /*_aidl_return*/) {
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSounding::getSupportedSessionTypes(
    std::optional<std::vector<SessionType>>* _aidl_return) {
  std::vector<SessionType> supported_session_types = {};
  *_aidl_return = supported_session_types;
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSounding::getMaxSupportedCsSecurityLevel(
    CsSecurityLevel* _aidl_return) {
  CsSecurityLevel security_level = CsSecurityLevel::NOT_SUPPORTED;
  *_aidl_return = security_level;
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSounding::openSession(
    const BluetoothChannelSoundingParameters& /*in_params*/,
    const std::shared_ptr<IBluetoothChannelSoundingSessionCallback>&
        in_callback,
    std::shared_ptr<IBluetoothChannelSoundingSession>* _aidl_return) {
  if (in_callback == nullptr) {
    return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
        EX_ILLEGAL_ARGUMENT, "Invalid nullptr callback");
  }
  std::shared_ptr<BluetoothChannelSoundingSession> session = nullptr;
  session = ndk::SharedRefBase::make<BluetoothChannelSoundingSession>(
      in_callback, Reason::LOCAL_STACK_REQUEST);
  *_aidl_return = session;
  return ::ndk::ScopedAStatus::ok();
}
}  // namespace aidl::android::hardware::bluetooth::ranging::impl
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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/ranging/BnBluetoothChannelSounding.h>

#include <vector>

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

using ::aidl::android::hardware::bluetooth::ranging::
    BluetoothChannelSoundingParameters;
using ::aidl::android::hardware::bluetooth::ranging::BnBluetoothChannelSounding;
using ::aidl::android::hardware::bluetooth::ranging::CsSecurityLevel;
using ::aidl::android::hardware::bluetooth::ranging::
    IBluetoothChannelSoundingSession;
using ::aidl::android::hardware::bluetooth::ranging::
    IBluetoothChannelSoundingSessionCallback;
using ::aidl::android::hardware::bluetooth::ranging::SessionType;
using ::aidl::android::hardware::bluetooth::ranging::VendorSpecificData;

class BluetoothChannelSounding : public BnBluetoothChannelSounding {
 public:
  BluetoothChannelSounding();
  ~BluetoothChannelSounding();  // Add the destructor declaration
  ndk::ScopedAStatus getVendorSpecificData(
      std::optional<std::vector<std::optional<VendorSpecificData>>>*
          _aidl_return) override;
  ndk::ScopedAStatus getSupportedSessionTypes(
      std::optional<std::vector<SessionType>>* _aidl_return) override;
  ndk::ScopedAStatus getMaxSupportedCsSecurityLevel(
      CsSecurityLevel* _aidl_return) override;
  ndk::ScopedAStatus openSession(
      const BluetoothChannelSoundingParameters& in_params,
      const std::shared_ptr<IBluetoothChannelSoundingSessionCallback>&
          in_callback,
      std::shared_ptr<IBluetoothChannelSoundingSession>* _aidl_return) override;
};

}  // namespace aidl::android::hardware::bluetooth::ranging::impl
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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 "BluetoothChannelSoundingSession.h"

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

BluetoothChannelSoundingSession::BluetoothChannelSoundingSession(
    std::shared_ptr<IBluetoothChannelSoundingSessionCallback> callback,
    Reason reason) {
  callback_ = callback;
  callback_->onOpened(reason);
}

ndk::ScopedAStatus BluetoothChannelSoundingSession::getVendorSpecificReplies(
    std::optional<
        std::vector<std::optional<VendorSpecificData>>>* /*_aidl_return*/) {
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSoundingSession::getSupportedResultTypes(
    std::vector<ResultType>* _aidl_return) {
  std::vector<ResultType> supported_result_types = {ResultType::RESULT_METERS};
  *_aidl_return = supported_result_types;
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSoundingSession::isAbortedProcedureRequired(
    bool* _aidl_return) {
  *_aidl_return = false;
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSoundingSession::writeRawData(
    const ChannelSoudingRawData& /*in_rawData*/) {
  RangingResult ranging_result;
  ranging_result.resultMeters = 0.0;
  callback_->onResult(ranging_result);
  return ::ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothChannelSoundingSession::close(Reason in_reason) {
  callback_->onClose(in_reason);
  return ::ndk::ScopedAStatus::ok();
}
}  // namespace aidl::android::hardware::bluetooth::ranging::impl
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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/ranging/BnBluetoothChannelSoundingSession.h>
#include <aidl/android/hardware/bluetooth/ranging/IBluetoothChannelSoundingSessionCallback.h>

#include <vector>

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

using ::aidl::android::hardware::bluetooth::ranging::ChannelSoudingRawData;
using ::aidl::android::hardware::bluetooth::ranging::Reason;
using ::aidl::android::hardware::bluetooth::ranging::ResultType;
using ::aidl::android::hardware::bluetooth::ranging::VendorSpecificData;

class BluetoothChannelSoundingSession
    : public BnBluetoothChannelSoundingSession {
 public:
  BluetoothChannelSoundingSession(
      std::shared_ptr<IBluetoothChannelSoundingSessionCallback> callback,
      Reason reason);

  ndk::ScopedAStatus getVendorSpecificReplies(
      std::optional<std::vector<std::optional<VendorSpecificData>>>*
          _aidl_return) override;
  ndk::ScopedAStatus getSupportedResultTypes(
      std::vector<ResultType>* _aidl_return) override;
  ndk::ScopedAStatus isAbortedProcedureRequired(bool* _aidl_return) override;
  ndk::ScopedAStatus writeRawData(
      const ChannelSoudingRawData& in_rawData) override;
  ndk::ScopedAStatus close(Reason in_reason) override;

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

}  // namespace aidl::android::hardware::bluetooth::ranging::impl
Loading