As of the Android L NDK, __system_property_get is removed (https://groups.google.com/a/chromium.org/forum/#!topic/chromium-reviews/keQP6L9aVyU). Is there another API in the Android L NDK to access the same property values?
Replacement for `__system_property_get` in Android L NDK
7.6k views Asked by aschmied At
3
There are 3 answers
0
On
You can use __system_property_read / __system_property_read_callback (__ANDROID_API__ >= 26). I couldn't find official doc about it but it's well documented in system_properties.h.
I know it's not for Android L but I think a more modern solution should be written.
#include <sys/system_properties.h>
const prop_info* pi = __system_property_find("persist.sys.locale");
std::string prop; // Not local, it will be modified by the callback.
if (pi != nullptr) {
__system_property_read_callback(
pi,
[](void* cookie, const char*, const char* value, unsigned int) {
*prop = value;
},
&prop);
}
I went with
popenas detailed in the answer at https://stackoverflow.com/a/478960/2833126 to rungetprop. Something like