Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2017 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 CONSCRYPT_JNICONSTANTS_H_
     18 #define CONSCRYPT_JNICONSTANTS_H_
     19 
     20 #include <jni.h>
     21 #include "JniUtil.h"
     22 
     23 namespace conscrypt {
     24 
     25 class JniConstants {
     26 private:
     27     JniConstants() {}
     28     ~JniConstants() {}
     29 
     30 public:
     31     /**
     32      * Initializes the JNI constants from the environment.
     33      */
     34     static void init(JavaVM* vm, JNIEnv* env);
     35 
     36     /**
     37      * Obtains the current thread's JNIEnv
     38      */
     39     static inline JNIEnv* getJNIEnv() {
     40         return JniUtil::getJNIEnv(gJavaVM);
     41     }
     42 
     43 public:
     44     static JavaVM* gJavaVM;
     45     static jclass cryptoUpcallsClass;
     46     static jclass openSslInputStreamClass;
     47     static jclass nativeRefClass;
     48 
     49     static jclass byteArrayClass;
     50     static jclass calendarClass;
     51     static jclass objectClass;
     52     static jclass objectArrayClass;
     53     static jclass integerClass;
     54     static jclass inputStreamClass;
     55     static jclass outputStreamClass;
     56     static jclass stringClass;
     57 
     58     static jfieldID nativeRef_context;
     59 
     60     static jmethodID calendar_setMethod;
     61     static jmethodID inputStream_readMethod;
     62     static jmethodID integer_valueOfMethod;
     63     static jmethodID openSslInputStream_readLineMethod;
     64     static jmethodID outputStream_writeMethod;
     65     static jmethodID outputStream_flushMethod;
     66 };
     67 
     68 }  // namespace conscrypt
     69 
     70 #endif  // CONSCRYPT_JNICONSTANTS_H_
     71