The open source OpenXR runtime

u/debug: Use system property on Android for debug settings

Co-authored-by: Jakob Bornecrantz <jakob@collabora.com>

authored by

Jarvis Huang
Jakob Bornecrantz
and committed by
Jakob Bornecrantz
a8df7dcb 2f3f5330

+37
+37
src/xrt/auxiliary/util/u_debug.c
··· 19 19 #include <stdlib.h> 20 20 #include <string.h> 21 21 22 + #ifdef XRT_OS_ANDROID 23 + #include <sys/system_properties.h> 24 + #endif 25 + 22 26 23 27 DEBUG_GET_ONCE_BOOL_OPTION(print, "XRT_PRINT_OPTIONS", false) 24 28 ··· 40 44 if (required_size == 0) { 41 45 return NULL; 42 46 } 47 + 48 + return chars; 49 + } 50 + 51 + #elif defined XRT_OS_ANDROID 52 + 53 + struct android_read_arg 54 + { 55 + char *chars; 56 + size_t char_count; 57 + }; 58 + 59 + static void 60 + android_on_property_read(void *cookie, const char *name, const char *value, uint32_t serial) 61 + { 62 + struct android_read_arg *a = (struct android_read_arg *)cookie; 63 + 64 + snprintf(a->chars, a->char_count, "%s", value); 65 + } 66 + 67 + static const char * 68 + get_option_raw(char *chars, size_t char_count, const char *name) 69 + { 70 + char prefixed[1024]; 71 + snprintf(prefixed, ARRAY_SIZE(prefixed), "debug.xrt.%s", name); 72 + 73 + const struct prop_info *pi = __system_property_find(prefixed); 74 + if (pi == NULL) { 75 + return NULL; 76 + } 77 + 78 + struct android_read_arg a = {.chars = chars, .char_count = char_count}; 79 + __system_property_read_callback(pi, &android_on_property_read, &a); 43 80 44 81 return chars; 45 82 }