vibrator/cs40l26: update default scales of click, tick and long vib

Flow:
1. If the calibration file exist, use the value.
2. If no property, use the default setting {5,95}.

Bug: 356823441
Bug: 322937989
Test: Check dumpsys records for the scaling results.
  case1: no calibration file and properties.
  case2: valid property range
  case3: float property (invalid)
Flag: EXEMPT bugfix
Change-Id: Ia3e89f34189e9725ab01d85d931925129745608c
(cherry picked from commit 4063493a64fcd0f20b49a492106f58b0e3349c5c)
This commit is contained in:
Tai Kuo 2024-02-01 15:22:37 +08:00
parent 03e46a5e0f
commit 46065a4462
3 changed files with 22 additions and 12 deletions

View file

@ -103,6 +103,19 @@ inline Enable_If_Unsigned<T, T> getProperty(const std::string &key, const T def)
return ::android::base::GetUintProperty(key, def);
}
template <typename T, size_t N>
inline std::array<T, N> getProperty(const std::string &key, const std::array<T, N> &def) {
std::string value = ::android::base::GetProperty(key, "");
if (!value.empty()) {
std::array<T, N> result{0};
std::stringstream stream{value};
utils::unpack(stream, &result);
if (stream && stream.eof())
return result;
}
return def;
}
template <>
inline bool getProperty<bool>(const std::string &key, const bool def) {
return ::android::base::GetBoolProperty(key, def);