diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-07-18 07:32:10 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-07-18 07:32:10 +0000 |
commit | 5d88fd6351b0e07be26d6e865569e7fdca7c77ce (patch) | |
tree | 56a4a425f954b26c84b83af8ac8943eab878a2ab | |
parent | 77b41c02f39b043d10f062d399d727aa26199782 (diff) | |
parent | 1715b9cfd880f4cbcc137f1753c28f041a8a4e1d (diff) | |
download | libnativehelper-5d88fd6351b0e07be26d6e865569e7fdca7c77ce.tar.gz |
release-request-e04bb055-13fc-41a1-8a9f-7fb10894ec3d-for-git_oc-mr1-release-4189380 snap-temp-L90600000083186678
Change-Id: Iab66ca90c389a8d38da0b2b2416bcd4fe4b2a251
-rw-r--r-- | Android.bp | 13 | ||||
-rw-r--r-- | JNIHelp.cpp | 4 | ||||
-rw-r--r-- | JniConstants.cpp | 2 | ||||
-rw-r--r-- | include/nativehelper/JNIHelp.h | 16 | ||||
-rw-r--r-- | include/nativehelper/JniConstants.h | 1 | ||||
l--------- | include_jni/jni.h | 1 |
6 files changed, 36 insertions, 1 deletions
@@ -12,6 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +cc_library_headers { + name: "jni_headers", + host_supported: true, + export_include_dirs: ["include_jni"], + vendor_available: true, +} + cc_library { name: "libnativehelper", host_supported: true, @@ -31,7 +38,10 @@ cc_library { srcs: ["AsynchronousCloseMonitor.cpp"], host_ldlibs: ["-ldl"], }, - }, + }, + + header_libs: ["jni_headers"], + export_header_lib_headers: ["jni_headers"], shared_libs: [ "liblog", @@ -41,6 +51,7 @@ cc_library { "-Werror", "-fvisibility=protected", ], + export_include_dirs: ["include", "platform_include"], } diff --git a/JNIHelp.cpp b/JNIHelp.cpp index 2ab6ed5..54012b8 100644 --- a/JNIHelp.cpp +++ b/JNIHelp.cpp @@ -362,3 +362,7 @@ jobject jniGetReferent(C_JNIEnv* env, jobject ref) { return (*env)->CallObjectMethod(e, ref, get); } +jstring jniCreateString(C_JNIEnv* env, const jchar* unicodeChars, jsize len) { + JNIEnv* e = reinterpret_cast<JNIEnv*>(env); + return (*env)->NewString(e, unicodeChars, len); +} diff --git a/JniConstants.cpp b/JniConstants.cpp index cfea131..bf8a955 100644 --- a/JniConstants.cpp +++ b/JniConstants.cpp @@ -64,6 +64,7 @@ jclass JniConstants::structPollfdClass; jclass JniConstants::structStatClass; jclass JniConstants::structStatVfsClass; jclass JniConstants::structTimevalClass; +jclass JniConstants::structTimespecClass; jclass JniConstants::structUcredClass; jclass JniConstants::structUtsnameClass; jclass JniConstants::unixSocketAddressClass; @@ -129,6 +130,7 @@ void JniConstants::init(JNIEnv* env) { structStatClass = findClass(env, "android/system/StructStat"); structStatVfsClass = findClass(env, "android/system/StructStatVfs"); structTimevalClass = findClass(env, "android/system/StructTimeval"); + structTimespecClass = findClass(env, "android/system/StructTimespec"); structUcredClass = findClass(env, "android/system/StructUcred"); structUtsnameClass = findClass(env, "android/system/StructUtsname"); unixSocketAddressClass = findClass(env, "android/system/UnixSocketAddress"); diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h index bf01986..6c7da34 100644 --- a/include/nativehelper/JNIHelp.h +++ b/include/nativehelper/JNIHelp.h @@ -104,6 +104,12 @@ void jniSetFileDescriptorOfFD(C_JNIEnv* env, jobject fileDescriptor, int value); jobject jniGetReferent(C_JNIEnv* env, jobject ref); /* + * Returns a Java String object created from UTF-16 data either from jchar or, + * if called from C++11, char16_t (a bitwise identical distinct type). + */ +jstring jniCreateString(C_JNIEnv* env, const jchar* unicodeChars, jsize len); + +/* * Log a message and an exception. * If exception is NULL, logs the current exception in the JNI environment. */ @@ -168,6 +174,16 @@ inline jobject jniGetReferent(JNIEnv* env, jobject ref) { return jniGetReferent(&env->functions, ref); } +inline jstring jniCreateString(JNIEnv* env, const jchar* unicodeChars, jsize len) { + return jniCreateString(&env->functions, unicodeChars, len); +} + +#if __cplusplus >= 201103L +inline jstring jniCreateString(JNIEnv* env, const char16_t* unicodeChars, jsize len) { + return jniCreateString(&env->functions, reinterpret_cast<const jchar*>(unicodeChars), len); +} +#endif // __cplusplus >= 201103L + inline void jniLogException(JNIEnv* env, int priority, const char* tag, jthrowable exception = NULL) { jniLogException(&env->functions, priority, tag, exception); } diff --git a/include/nativehelper/JniConstants.h b/include/nativehelper/JniConstants.h index a4ce4fc..266fccd 100644 --- a/include/nativehelper/JniConstants.h +++ b/include/nativehelper/JniConstants.h @@ -75,6 +75,7 @@ struct JniConstants { static jclass structStatClass; static jclass structStatVfsClass; static jclass structTimevalClass; + static jclass structTimespecClass; static jclass structUcredClass; static jclass structUtsnameClass; static jclass unixSocketAddressClass; diff --git a/include_jni/jni.h b/include_jni/jni.h new file mode 120000 index 0000000..88d1a00 --- /dev/null +++ b/include_jni/jni.h @@ -0,0 +1 @@ +../include/nativehelper/jni.h
\ No newline at end of file |