34std::string
GetProperty(
const std::string& key,
const std::string& default_value);
46 T max = std::numeric_limits<T>::max());
53 T max = std::numeric_limits<T>::max());
56bool SetProperty(
const std::string& key,
const std::string& value);
61#if defined(__BIONIC__)
62bool WaitForProperty(
const std::string& key,
const std::string& expected_value,
63 std::chrono::milliseconds relative_timeout = std::chrono::milliseconds::max());
69#if defined(__BIONIC__)
70bool WaitForPropertyCreation(
const std::string& key, std::chrono::milliseconds relative_timeout =
71 std::chrono::milliseconds::max());
74#if defined(__BIONIC__) && __cplusplus >= 201703L
79 explicit CachedProperty(std::string property_name);
82 explicit CachedProperty(
const char* property_name);
91 const char* Get(
bool* changed =
nullptr);
98 const char* WaitForChange(
99 std::chrono::milliseconds relative_timeout = std::chrono::milliseconds::max());
102 std::string property_name_;
104 std::optional<uint32_t> cached_area_serial_;
105 std::optional<uint32_t> cached_property_serial_;
106 char cached_value_[92];
108 const char* read_only_property_;
113template <
typename Parser>
114class CachedParsedProperty {
116 using value_type = std::remove_reference_t<std::invoke_result_t<Parser, const char*>>;
118 CachedParsedProperty(std::string property_name, Parser parser)
119 : cached_property_(
std::move(property_name)), parser_(
std::move(parser)) {}
124 value_type Get(
bool* changed =
nullptr) {
125 std::lock_guard<std::mutex> lock(mutex_);
126 bool local_changed =
false;
127 const char* value = cached_property_.Get(&local_changed);
128 if (!cached_result_ || local_changed) {
129 cached_result_ = parser_(value);
132 if (changed) *changed = local_changed;
133 return *cached_result_;
138 CachedProperty cached_property_;
139 std::optional<value_type> cached_result_;
145class CachedBoolProperty {
147 explicit CachedBoolProperty(std::string property_name);
153 bool Get(
bool default_value);
156 CachedParsedProperty<std::optional<bool> (*)(
const char*)> cached_parsed_property_;
168#if !defined(__BIONIC__)
177 void (*)(
void*,
const char*,
const char*, uint32_t),
#define min(a, b)
Definition: ext4_utils.h:44
std::string GetProperty(const std::string &key, const std::string &default_value)
Definition: properties.cpp:159
bool GetBoolProperty(const std::string &key, bool default_value)
Definition: properties.cpp:121
T GetIntProperty(const std::string &key, T default_value, T min=std::numeric_limits< T >::min(), T max=std::numeric_limits< T >::max())
Definition: properties.cpp:134
T GetUintProperty(const std::string &key, T default_value, T max=std::numeric_limits< T >::max())
Definition: properties.cpp:142
static int HwTimeoutMultiplier()
Definition: properties.h:161
bool SetProperty(const std::string &key, const std::string &value)
Definition: properties.cpp:177
std::optional< T > GetOptional(const std::vector< T > &vector, size_t i)
Definition: get_optional.h:24
Definition: logging.h:464
int __system_property_set(const char *, const char *)
Definition: properties.cpp:71
const prop_info * __system_property_find(const char *)
Definition: properties.cpp:98
void __system_property_read_callback(const prop_info *, void(*)(void *, const char *, const char *, uint32_t), void *)
Definition: properties.cpp:108
int __system_property_get(const char *, char *)
Definition: properties.cpp:87
Definition: properties.cpp:53