1 /* 2 * Copyright (C) 2015 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 17 #ifndef NATIVE_LOADER_H_ 18 #define NATIVE_LOADER_H_ 19 20 #include "jni.h" 21 #include <stdint.h> 22 #if defined(__ANDROID__) 23 #include <android/dlext.h> 24 #endif 25 26 namespace android { 27 28 __attribute__((visibility("default"))) 29 void InitializeNativeLoader(); 30 31 __attribute__((visibility("default"))) 32 jstring CreateClassLoaderNamespace(JNIEnv* env, 33 int32_t target_sdk_version, 34 jobject class_loader, 35 bool is_shared, 36 jstring library_path, 37 jstring permitted_path); 38 39 __attribute__((visibility("default"))) 40 void* OpenNativeLibrary(JNIEnv* env, 41 int32_t target_sdk_version, 42 const char* path, 43 jobject class_loader, 44 jstring library_path); 45 46 __attribute__((visibility("default"))) 47 bool CloseNativeLibrary(void* handle); 48 49 #if defined(__ANDROID__) 50 // Look up linker namespace by class_loader. Returns nullptr if 51 // there is no namespace associated with the class_loader. 52 __attribute__((visibility("default"))) 53 android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader); 54 #endif 55 56 __attribute__((visibility("default"))) 57 void ResetNativeLoader(); 58 59 }; // namespace android 60 61 #endif // NATIVE_BRIDGE_H_ 62