Skip to content

Commit 34ee77d

Browse files
committed
Changed to be complaint with API levels below 26
1 parent a82516f commit 34ee77d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

packages/react-native-executorch/android/src/main/cpp/EmulatorDetection.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
#pragma once
22

3-
#include <sys/system_properties.h>
43
#include <string>
4+
#include <sys/system_properties.h>
55

66
namespace rnexecutorch {
77

88
inline bool isEmulator() {
99
auto readProp = [](const char *key) -> std::string {
10+
#if __ANDROID_API__ >= 26
1011
const prop_info *pi = __system_property_find(key);
11-
if (pi == nullptr) return "";
12+
if (pi == nullptr)
13+
return "";
1214
std::string result;
1315
__system_property_read_callback(
1416
pi,
15-
[](void *cookie, const char * /*__name*/, const char *value, uint32_t /*__serial*/) {
17+
[](void *cookie, const char * /*__name*/, const char *value,
18+
uint32_t /*__serial*/) {
1619
*static_cast<std::string *>(cookie) = value;
1720
},
1821
&result);
1922
return result;
23+
#else
24+
char value[PROP_VALUE_MAX] = {0};
25+
__system_property_get(key, value);
26+
return std::string(value);
27+
#endif
2028
};
2129

2230
std::string fp = readProp("ro.build.fingerprint");

0 commit comments

Comments
 (0)