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

Commit 04ca92c7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add function to get the HAL version." into main

parents 0022c7b7 0ea25cb0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,12 @@
namespace bluetooth {
namespace hal {

enum RangingHalVersion {
  V_UNKNOWN = 0,
  V_1 = 1,
  V_2 = 2,
};

struct VendorSpecificCharacteristic {
  std::array<uint8_t, 16> characteristicUuid_;
  std::vector<uint8_t> value_;
+17 −0
Original line number Diff line number Diff line
@@ -109,6 +109,8 @@ class RangingHalAndroid : public RangingHal {
public:
  bool IsBound() override { return bluetooth_channel_sounding_ != nullptr; }

  RangingHalVersion GetRangingHalVersion() { return hal_ver_; }

  void RegisterCallback(RangingHalCallback* callback) { ranging_hal_callback_ = callback; }

  std::vector<VendorSpecificCharacteristic> GetVendorSpecificCharacteristics() override {
@@ -248,6 +250,17 @@ public:
protected:
  void ListDependencies(ModuleList* /*list*/) const {}

  RangingHalVersion get_ranging_hal_version() {
    int ver = 0;
    auto aidl_ret = bluetooth_channel_sounding_->getInterfaceVersion(&ver);
    if (aidl_ret.isOk()) {
      log::info("ranging HAL version - {}", ver);
      return static_cast<RangingHalVersion>(ver);
    }
    log::warn("ranging HAL version is not available.");
    return RangingHalVersion::V_UNKNOWN;
  }

  void Start() override {
    std::string instance = std::string() + IBluetoothChannelSounding::descriptor + "/default";
    log::info("AServiceManager_isDeclared {}", AServiceManager_isDeclared(instance.c_str()));
@@ -255,6 +268,9 @@ protected:
      ::ndk::SpAIBinder binder(AServiceManager_waitForService(instance.c_str()));
      bluetooth_channel_sounding_ = IBluetoothChannelSounding::fromBinder(binder);
      log::info("Bind IBluetoothChannelSounding {}", IsBound() ? "Success" : "Fail");
      if (bluetooth_channel_sounding_ != nullptr) {
        hal_ver_ = get_ranging_hal_version();
      }
    }
  }

@@ -267,6 +283,7 @@ private:
  RangingHalCallback* ranging_hal_callback_;
  std::unordered_map<uint16_t, std::shared_ptr<BluetoothChannelSoundingSessionTracker>>
          session_trackers_;
  RangingHalVersion hal_ver_;
};

const ModuleFactory RangingHal::Factory = ModuleFactory([]() { return new RangingHalAndroid(); });
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ namespace hal {
class RangingHalHost : public RangingHal {
public:
  bool IsBound() override { return false; }
  RangingHalVersion GetRangingHalVersion() { return V_UNKNOWN; }
  void RegisterCallback(RangingHalCallback* /* callback */) override {}
  std::vector<VendorSpecificCharacteristic> GetVendorSpecificCharacteristics() override {
    std::vector<VendorSpecificCharacteristic> vendor_specific_characteristics = {};