blob: 2b149870093c3f915272c2ceaaae223ca8eedac3 [file] [log] [blame]
Andreas Huber78253342014-02-06 15:25:25 -08001/*
2 * Copyright (C) 2014 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 _RUNTIME_ANDROID_RUNTIME_BASE_H
18#define _RUNTIME_ANDROID_RUNTIME_BASE_H
19
20#include <nativehelper/jni.h>
21
22namespace android {
23
24struct AndroidRuntimeBase {
25 /** return a pointer to the VM running in this process */
26 static JavaVM* getJavaVM() { return mJavaVM; }
27
28 /** return a pointer to the JNIEnv pointer for this thread */
29 static JNIEnv* getJNIEnv();
30
31 /**
32 * Register a set of methods in the specified class.
33 */
34 static int registerNativeMethods(JNIEnv* env,
35 const char* className, const JNINativeMethod* gMethods, int numMethods);
36
37protected:
38 /* JNI JavaVM pointer */
39 static JavaVM* mJavaVM;
40
41 AndroidRuntimeBase() {}
42 virtual ~AndroidRuntimeBase() {}
43
44 AndroidRuntimeBase(const AndroidRuntimeBase &);
45 AndroidRuntimeBase &operator=(const AndroidRuntimeBase &);
46};
47
48} // namespace android
49
50#endif // _RUNTIME_ANDROID_RUNTIME_BASE_H