10997908c95151ce24609c10731990e648156b95dDimitry Ivanov/*
20997908c95151ce24609c10731990e648156b95dDimitry Ivanov * Copyright 2016 The Android Open Source Project
30997908c95151ce24609c10731990e648156b95dDimitry Ivanov *
40997908c95151ce24609c10731990e648156b95dDimitry Ivanov * Licensed under the Apache License, Version 2.0 (the "License");
50997908c95151ce24609c10731990e648156b95dDimitry Ivanov * you may not use this file except in compliance with the License.
60997908c95151ce24609c10731990e648156b95dDimitry Ivanov * You may obtain a copy of the License at
70997908c95151ce24609c10731990e648156b95dDimitry Ivanov *
80997908c95151ce24609c10731990e648156b95dDimitry Ivanov *      http://www.apache.org/licenses/LICENSE-2.0
90997908c95151ce24609c10731990e648156b95dDimitry Ivanov *
100997908c95151ce24609c10731990e648156b95dDimitry Ivanov * Unless required by applicable law or agreed to in writing, software
110997908c95151ce24609c10731990e648156b95dDimitry Ivanov * distributed under the License is distributed on an "AS IS" BASIS,
120997908c95151ce24609c10731990e648156b95dDimitry Ivanov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130997908c95151ce24609c10731990e648156b95dDimitry Ivanov * See the License for the specific language governing permissions and
140997908c95151ce24609c10731990e648156b95dDimitry Ivanov * limitations under the License.
150997908c95151ce24609c10731990e648156b95dDimitry Ivanov */
160997908c95151ce24609c10731990e648156b95dDimitry Ivanov
170997908c95151ce24609c10731990e648156b95dDimitry Ivanov#include <nativehelper/ScopedUtfChars.h>
180997908c95151ce24609c10731990e648156b95dDimitry Ivanov#include <nativeloader/native_loader.h>
190997908c95151ce24609c10731990e648156b95dDimitry Ivanov#include <vulkan/vulkan_loader_data.h>
200997908c95151ce24609c10731990e648156b95dDimitry Ivanov
210997908c95151ce24609c10731990e648156b95dDimitry Ivanov#include "core_jni_helpers.h"
220997908c95151ce24609c10731990e648156b95dDimitry Ivanov
230997908c95151ce24609c10731990e648156b95dDimitry Ivanovstatic void setupVulkanLayerPath_native(JNIEnv* env, jobject clazz,
240997908c95151ce24609c10731990e648156b95dDimitry Ivanov        jobject classLoader, jstring librarySearchPath) {
250997908c95151ce24609c10731990e648156b95dDimitry Ivanov    ScopedUtfChars layerPathChars(env, librarySearchPath);
260997908c95151ce24609c10731990e648156b95dDimitry Ivanov    vulkan::LoaderData& loader_data = vulkan::LoaderData::GetInstance();
270997908c95151ce24609c10731990e648156b95dDimitry Ivanov    loader_data.layer_path = layerPathChars.c_str();
280997908c95151ce24609c10731990e648156b95dDimitry Ivanov    loader_data.app_namespace = android::FindNamespaceByClassLoader(env, classLoader);
290997908c95151ce24609c10731990e648156b95dDimitry Ivanov}
300997908c95151ce24609c10731990e648156b95dDimitry Ivanov
310997908c95151ce24609c10731990e648156b95dDimitry Ivanovstatic const JNINativeMethod g_methods[] = {
320997908c95151ce24609c10731990e648156b95dDimitry Ivanov    { "setupVulkanLayerPath", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V",
330997908c95151ce24609c10731990e648156b95dDimitry Ivanov      reinterpret_cast<void*>(setupVulkanLayerPath_native) },
340997908c95151ce24609c10731990e648156b95dDimitry Ivanov};
350997908c95151ce24609c10731990e648156b95dDimitry Ivanov
360997908c95151ce24609c10731990e648156b95dDimitry Ivanovstatic const char* const kApplicationLoadersName = "android/app/ApplicationLoaders";
370997908c95151ce24609c10731990e648156b95dDimitry Ivanov
380997908c95151ce24609c10731990e648156b95dDimitry Ivanovnamespace android
390997908c95151ce24609c10731990e648156b95dDimitry Ivanov{
400997908c95151ce24609c10731990e648156b95dDimitry Ivanov
410997908c95151ce24609c10731990e648156b95dDimitry Ivanovint register_android_app_ApplicationLoaders(JNIEnv* env) {
420997908c95151ce24609c10731990e648156b95dDimitry Ivanov    return RegisterMethodsOrDie(env, kApplicationLoadersName, g_methods, NELEM(g_methods));
430997908c95151ce24609c10731990e648156b95dDimitry Ivanov}
440997908c95151ce24609c10731990e648156b95dDimitry Ivanov
450997908c95151ce24609c10731990e648156b95dDimitry Ivanov} // namespace android
46