blob: 3e7c039e2129c7d83a432e65f9ac4d56b0473ba8 [file] [log] [blame]
Dimitry Ivanov09979082016-04-19 11:11:01 -07001/*
2 * Copyright 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Chia-I Wu15e74c92016-06-28 08:39:33 +080017#define LOG_TAG "ApplicationLoaders"
18
Dimitry Ivanov09979082016-04-19 11:11:01 -070019#include <nativehelper/ScopedUtfChars.h>
20#include <nativeloader/native_loader.h>
21#include <vulkan/vulkan_loader_data.h>
22
23#include "core_jni_helpers.h"
24
25static void setupVulkanLayerPath_native(JNIEnv* env, jobject clazz,
26 jobject classLoader, jstring librarySearchPath) {
Chia-I Wu15e74c92016-06-28 08:39:33 +080027 android_namespace_t* ns = android::FindNamespaceByClassLoader(env, classLoader);
Dimitry Ivanov09979082016-04-19 11:11:01 -070028 ScopedUtfChars layerPathChars(env, librarySearchPath);
Chia-I Wu15e74c92016-06-28 08:39:33 +080029
Dimitry Ivanov09979082016-04-19 11:11:01 -070030 vulkan::LoaderData& loader_data = vulkan::LoaderData::GetInstance();
Chia-I Wu15e74c92016-06-28 08:39:33 +080031 if (loader_data.layer_path.empty()) {
32 loader_data.layer_path = layerPathChars.c_str();
33 loader_data.app_namespace = ns;
34 } else {
35 ALOGD("ignored Vulkan layer search path %s for namespace %p",
36 layerPathChars.c_str(), ns);
37 }
Dimitry Ivanov09979082016-04-19 11:11:01 -070038}
39
40static const JNINativeMethod g_methods[] = {
41 { "setupVulkanLayerPath", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V",
42 reinterpret_cast<void*>(setupVulkanLayerPath_native) },
43};
44
45static const char* const kApplicationLoadersName = "android/app/ApplicationLoaders";
46
47namespace android
48{
49
50int register_android_app_ApplicationLoaders(JNIEnv* env) {
51 return RegisterMethodsOrDie(env, kApplicationLoadersName, g_methods, NELEM(g_methods));
52}
53
54} // namespace android