Skip to content

Commit 36cb957

Browse files
committed
Enable read environment variable on Android
This fixs: #430
1 parent 8270b15 commit 36cb957

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/common/platform_utils.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,18 @@ static inline bool PlatformUtilsSetEnv(const char* name, const char* value) {
347347
}
348348

349349
#elif defined(XR_OS_ANDROID)
350+
namespace detail {
350351

351-
static inline bool PlatformUtilsGetEnvSet(const char* /* name */) {
352-
// Stub func
353-
return false;
354-
}
352+
static inline char* ImplGetEnv(const char* name) { return getenv(name); }
353+
} // namespace detail
354+
static inline bool PlatformUtilsGetEnvSet(const char* name) { return detail::ImplGetEnv(name) != nullptr; }
355355

356-
static inline std::string PlatformUtilsGetEnv(const char* /* name */) {
357-
// Stub func
358-
return {};
356+
static inline std::string PlatformUtilsGetEnv(const char* name) {
357+
auto str = detail::ImplGetEnv(name);
358+
if (str == nullptr) {
359+
return {};
360+
}
361+
return str;
359362
}
360363

361364
static inline std::string PlatformUtilsGetSecureEnv(const char* /* name */) {

0 commit comments

Comments
 (0)