MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / CheckAndroidVersion

Function CheckAndroidVersion

layers/vk_layer_config.cpp:169–191  ·  view source on GitHub ↗

This catches before dlopen fails if the default Android-26 layers are being used and attempted to be ran on Android 25 or below

Source from the content-addressed store, hash-verified

167
168// This catches before dlopen fails if the default Android-26 layers are being used and attempted to be ran on Android 25 or below
169void __attribute__((constructor)) CheckAndroidVersion() {
170 const std::string version = GetEnvironment("ro.build.version.sdk");
171
172 if (version.empty()) {
173 return;
174 }
175
176 constexpr uint32_t target_android_api = 26;
177 constexpr uint32_t android_api = __ANDROID_API__;
178
179 static_assert(android_api >= target_android_api, "Vulkan-ValidationLayers is not supported on Android 25 and below");
180
181 uint32_t queried_version{};
182
183 if (std::from_chars(version.data(), version.data() + version.size(), queried_version).ec != std::errc()) {
184 return;
185 }
186
187 if (queried_version < target_android_api) {
188 __android_log_print(ANDROID_LOG_FATAL, "VALIDATION", "ERROR - Android version is %d and needs to be 26 or above.",
189 queried_version);
190 }
191}
192
193#endif

Callers

nothing calls this directly

Calls 5

GetEnvironmentFunction · 0.85
__android_log_printFunction · 0.85
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected