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

Commit 6d103415 authored by William Escande's avatar William Escande
Browse files

Add GetSystemPropertyUint32Base

Yes I assumed the int could be written as hexa in properties.
Yes I merged a change adding an hexa property
Yes I broke multiples devices
ヾ(_ _。)

Breakage was happening when you set these properties using hexa num
  bluetooth.l2cap.le.credit_default.value
  bluetooth.l2cap.le.credit_threshold.value

Dirty-cherry because of include conflict in l2c_api.cc

Bug: 263323082
Test: atest net_test_osi
Merged-In: Ie58c1bc0d637fc0fabd9797813187d1897c0df51
(cherry picked from commit 03ca4858)
Change-Id: Ib9d65164728254ead696187793b01151d04ee469
parent 008aec6a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -30,6 +30,12 @@ std::optional<std::string> GetSystemProperty(const std::string& property);
// does not exist or if the platform does not support system property
uint32_t GetSystemPropertyUint32(const std::string& property, uint32_t default_value);

// Get |property| keyed system property as uint32_t from supported platform, return |default_value|
// if the property does not exist or if the platform does not support system property if property is
// found it will call stoul with |base|
uint32_t GetSystemPropertyUint32Base(
    const std::string& property, uint32_t default_value, int base = 0);

// Get |property| keyed property as bool from supported platform, return
// |default_value| if the property does not exist or if the platform
// does not support system property
+6 −1
Original line number Diff line number Diff line
@@ -23,9 +23,14 @@ namespace bluetooth {
namespace os {

uint32_t GetSystemPropertyUint32(const std::string& property, uint32_t default_value) {
  return GetSystemPropertyUint32Base(property, default_value, 10);
}

uint32_t GetSystemPropertyUint32Base(
    const std::string& property, uint32_t default_value, int base) {
  std::optional<std::string> result = GetSystemProperty(property);
  if (result.has_value()) {
    return static_cast<uint32_t>(std::stoul(*result));
    return static_cast<uint32_t>(std::stoul(*result, nullptr, base));
  }
  return default_value;
}
+3 −3
Original line number Diff line number Diff line
@@ -34,10 +34,10 @@

#include "device/include/controller.h"  // TODO Remove
#include "gd/common/init_flags.h"
#include "gd/os/system_properties.h"
#include "main/shim/shim.h"
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_sec.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btu.h"  // do_in_main_thread
@@ -68,14 +68,14 @@ uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,

uint16_t L2CA_LeCreditDefault() {
  static const uint16_t sL2CAP_LE_CREDIT_DEFAULT =
      (uint16_t)osi_property_get_int32(
      bluetooth::os::GetSystemPropertyUint32Base(
          "bluetooth.l2cap.le.credit_default.value", 0xffff);
  return sL2CAP_LE_CREDIT_DEFAULT;
}

uint16_t L2CA_LeCreditThreshold() {
  static const uint16_t sL2CAP_LE_CREDIT_THRESHOLD =
      (uint16_t)osi_property_get_int32(
      bluetooth::os::GetSystemPropertyUint32Base(
          "bluetooth.l2cap.le.credit_threshold.value", 0x0040);
  return sL2CAP_LE_CREDIT_THRESHOLD;
}