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