diff --git a/ReactAndroid/src/main/jni/first-party/fb/Android.mk b/ReactAndroid/src/main/jni/first-party/fb/Android.mk index aaf198bce..4540eef1d 100644 --- a/ReactAndroid/src/main/jni/first-party/fb/Android.mk +++ b/ReactAndroid/src/main/jni/first-party/fb/Android.mk @@ -13,6 +13,7 @@ LOCAL_SRC_FILES:= \ jni/jni_helpers.cpp \ jni/LocalString.cpp \ jni/OnLoad.cpp \ + jni/ReadableByteChannel.cpp \ jni/References.cpp \ jni/WeakReference.cpp \ log.cpp \ diff --git a/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReadableByteChannel.h b/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReadableByteChannel.h new file mode 100644 index 000000000..f895a3e6f --- /dev/null +++ b/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReadableByteChannel.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace jni { + +class JReadableByteChannel : public JavaClass { +public: + static constexpr const char* kJavaDescriptor = "Ljava/nio/channels/ReadableByteChannel;"; + + int read(alias_ref dest) const; +}; + +}} diff --git a/ReactAndroid/src/main/jni/first-party/fb/jni/ReadableByteChannel.cpp b/ReactAndroid/src/main/jni/first-party/fb/jni/ReadableByteChannel.cpp new file mode 100644 index 000000000..9c67df3fa --- /dev/null +++ b/ReactAndroid/src/main/jni/first-party/fb/jni/ReadableByteChannel.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include + +namespace facebook { +namespace jni { + +int JReadableByteChannel::read(alias_ref dest) const { + if (!self()) { + throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); + } + static auto method = javaClassStatic()->getMethod)>("read"); + return method(self(), dest); +} + +}}