1 /* 2 * Copyright (C) 2009 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 #include <cutils/log.h> 18 #include <jni.h> 19 #include <stdlib.h> 20 21 /* 22 * This function is called automatically by the system when this 23 * library is loaded. We use it to register all our native functions, 24 * which is the recommended practice for Android. 25 */ 26 jint JNI_OnLoad(JavaVM *vm, void *reserved) { 27 JNIEnv *env = NULL; 28 29 if ((*vm)->GetEnv(vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) { 30 return JNI_ERR; 31 } 32 33 extern int register_InstanceNonce(JNIEnv *); 34 if (register_InstanceNonce(env)) { 35 LOGE("failed to register InstanceNonce"); 36 return JNI_ERR; 37 } 38 39 extern int register_StaticNonce(JNIEnv *); 40 if (register_StaticNonce(env)) { 41 LOGE("failed to register StaticNonce"); 42 return JNI_ERR; 43 } 44 45 extern int register_JniCTest(JNIEnv *); 46 if (register_JniCTest(env)) { 47 LOGE("failed to register JniCTest"); 48 return JNI_ERR; 49 } 50 51 extern int register_JniCppTest(JNIEnv *); 52 if (register_JniCppTest(env)) { 53 LOGE("failed to register JniCppTest"); 54 return JNI_ERR; 55 } 56 57 return JNI_VERSION_1_4; 58 } 59