• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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                                    jstring library_path,
38                                    jstring permitted_path);
39 
40 __attribute__((visibility("default")))
41 void* OpenNativeLibrary(JNIEnv* env,
42                         int32_t target_sdk_version,
43                         const char* path,
44                         jobject class_loader,
45                         jstring library_path,
46                         bool* needs_native_bridge,
47                         std::string* error_msg);
48 
49 __attribute__((visibility("default")))
50 bool CloseNativeLibrary(void* handle, const bool needs_native_bridge);
51 
52 #if defined(__ANDROID__)
53 // Look up linker namespace by class_loader. Returns nullptr if
54 // there is no namespace associated with the class_loader.
55 __attribute__((visibility("default")))
56 android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader);
57 #endif
58 
59 __attribute__((visibility("default")))
60 void ResetNativeLoader();
61 
62 };  // namespace android
63 
64 #endif  // NATIVE_BRIDGE_H_
65