diff --git a/RNTester/android/app/BUCK b/RNTester/android/app/BUCK index 5e839d5e9153ca..ceb05c3e109291 100644 --- a/RNTester/android/app/BUCK +++ b/RNTester/android/app/BUCK @@ -25,7 +25,6 @@ rn_android_library( react_native_target("java/com/facebook/react:react"), react_native_target("java/com/facebook/react/common:build_config"), react_native_target("java/com/facebook/react/modules/core:core"), - react_native_target("java/com/facebook/react/views/text:text"), react_native_target("java/com/facebook/react/shell:shell"), react_native_target("jni/prebuilt:android-jsc"), # .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck` diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 0c119f5abc6114..0859fcd88a7444 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -243,7 +243,6 @@ def getNdkBuildFullPath() { task buildReactNdkLib(dependsOn: [prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type: Exec) { inputs.dir("$projectDir/../ReactCommon") inputs.dir("src/main/jni") - inputs.dir("src/main/java/com/facebook/react/modules/blob") outputs.dir("$buildDir/react-ndk/all") commandLine(getNdkBuildFullPath(), "NDK_PROJECT_PATH=null", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK index 72c927348f08e4..ac8fbcbc9f87ec 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK @@ -16,7 +16,6 @@ rn_android_library( ], deps = [ react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), - react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/okhttp:okhttp3"), @@ -25,7 +24,6 @@ rn_android_library( react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), - react_native_target("java/com/facebook/react/modules/blob/jni:jni"), react_native_target("java/com/facebook/react/modules/network:network"), react_native_target("java/com/facebook/react/modules/websocket:websocket"), ], diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobCollector.java b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobCollector.java deleted file mode 100644 index a4fca0d95ef75b..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobCollector.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.facebook.react.modules.blob; - -import com.facebook.react.bridge.JavaScriptContextHolder; -import com.facebook.react.bridge.ReactContext; -import com.facebook.soloader.SoLoader; - -/* package */ class BlobCollector { - static { - SoLoader.loadLibrary("reactnativeblob"); - } - - static void install(final ReactContext reactContext, final BlobModule blobModule) { - reactContext.runOnJSQueueThread( - new Runnable() { - @Override - public void run() { - JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder(); - synchronized (jsContext) { - nativeInstall(blobModule, jsContext.get()); - } - } - }); - } - - private static native void nativeInstall(Object blobModule, long jsContext); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java index 811155d451c011..830180c6ffc308 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java @@ -15,7 +15,6 @@ import androidx.annotation.Nullable; import android.webkit.MimeTypeMap; -import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -152,11 +151,6 @@ public BlobModule(ReactApplicationContext reactContext) { super(reactContext); } - @Override - public void initialize() { - BlobCollector.install(getReactApplicationContext(), this); - } - @Override public String getName() { return NAME; @@ -184,16 +178,11 @@ public String store(byte[] data) { } public void store(byte[] data, String blobId) { - synchronized (mBlobs) { - mBlobs.put(blobId, data); - } + mBlobs.put(blobId, data); } - @DoNotStrip public void remove(String blobId) { - synchronized (mBlobs) { - mBlobs.remove(blobId); - } + mBlobs.remove(blobId); } public @Nullable byte[] resolve(Uri uri) { @@ -212,19 +201,17 @@ public void remove(String blobId) { } public @Nullable byte[] resolve(String blobId, int offset, int size) { - synchronized (mBlobs) { - byte[] data = mBlobs.get(blobId); - if (data == null) { - return null; - } - if (size == -1) { - size = data.length - offset; - } - if (offset > 0 || size != data.length) { - data = Arrays.copyOfRange(data, offset, offset + size); - } - return data; + byte[] data = mBlobs.get(blobId); + if (data == null) { + return null; + } + if (size == -1) { + size = data.length - offset; + } + if (offset > 0 || size != data.length) { + data = Arrays.copyOfRange(data, offset, offset + size); } + return data; } public @Nullable byte[] resolve(ReadableMap blob) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk deleted file mode 100644 index b0ef370c574413..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := reactnativeblob - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti - -LOCAL_STATIC_LIBRARIES := libjsi libjsireact jscruntime -LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK deleted file mode 100644 index c02646779b63f8..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK +++ /dev/null @@ -1,22 +0,0 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_native_target", "react_native_xplat_target", "rn_xplat_cxx_library") - -rn_xplat_cxx_library( - name = "jni", - srcs = glob(["*.cpp"]), - headers = glob(["*.h"]), - header_namespace = "", - compiler_flags = ["-fexceptions"], - fbandroid_allow_jni_merging = True, - platforms = ANDROID, - soname = "libreactnativeblob.$(ext)", - visibility = [ - "PUBLIC", - ], - deps = [ - "fbsource//xplat/folly:molly", - FBJNI_TARGET, - react_native_target("jni/react/jni:jni"), - react_native_xplat_target("jsi:JSCRuntime"), - react_native_xplat_target("jsiexecutor:jsiexecutor"), - ], -) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.cpp b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.cpp deleted file mode 100644 index b529f68710e059..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2004-present Facebook. All Rights Reserved. -// This source code is licensed under the MIT license found in the -// LICENSE file in the root directory of this source tree. - -#include "BlobCollector.h" - -#include -#include -#include - -using namespace facebook; - -namespace facebook { -namespace react { - -static constexpr auto kBlobModuleJavaDescriptor = - "com/facebook/react/modules/blob/BlobModule"; - -BlobCollector::BlobCollector( - jni::global_ref blobModule, - const std::string &blobId) - : blobModule_(blobModule), blobId_(blobId) {} - -BlobCollector::~BlobCollector() { - jni::ThreadScope::WithClassLoader([&] { - static auto removeMethod = jni::findClassStatic(kBlobModuleJavaDescriptor) - ->getMethod("remove"); - removeMethod(blobModule_, jni::make_jstring(blobId_).get()); - }); -} - -void BlobCollector::nativeInstall( - jni::alias_ref jThis, - jni::alias_ref blobModule, - jlong jsContextNativePointer) { - auto &runtime = *((jsi::Runtime *) jsContextNativePointer); - auto blobModuleRef = jni::make_global(blobModule); - runtime.global().setProperty( - runtime, - "__blobCollectorProvider", - jsi::Function::createFromHostFunction( - runtime, - jsi::PropNameID::forAscii(runtime, "__blobCollectorProvider"), - 1, - [blobModuleRef]( - jsi::Runtime &rt, - const jsi::Value &thisVal, - const jsi::Value *args, - size_t count) { - auto blobId = args[0].asString(rt).utf8(rt); - auto blobCollector = - std::make_shared(blobModuleRef, blobId); - return jsi::Object::createFromHostObject(rt, blobCollector); - })); -} - -void BlobCollector::registerNatives() { - registerHybrid( - {makeNativeMethod("nativeInstall", BlobCollector::nativeInstall)}); -} - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.h b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.h deleted file mode 100644 index b013cf8bf665c7..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2004-present Facebook. All Rights Reserved. -// 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 react { - -class BlobCollector : public jni::HybridClass, - public jsi::HostObject { - public: - BlobCollector( - jni::global_ref blobManager, - const std::string &blobId); - ~BlobCollector(); - - static constexpr auto kJavaDescriptor = - "Lcom/facebook/react/modules/blob/BlobCollector;"; - - static void nativeInstall( - jni::alias_ref jThis, - jni::alias_ref blobModule, - jlong jsContextNativePointer); - - static void registerNatives(); - - private: - friend HybridBase; - - jni::global_ref blobModule_; - const std::string blobId_; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/OnLoad.cpp b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/OnLoad.cpp deleted file mode 100644 index 3707d02665e44a..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/OnLoad.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2004-present Facebook. All Rights Reserved. - -// This source code is licensed under the MIT license found in the -// LICENSE file in the root directory of this source tree. - -#include - -#include "BlobCollector.h" - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { - return facebook::jni::initialize( - vm, [] { facebook::react::BlobCollector::registerNatives(); }); -} diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index f8cbffb83193ab..0e99e4490e43c1 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -70,5 +70,3 @@ include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk include $(REACT_SRC_DIR)/jscexecutor/Android.mk include $(REACT_SRC_DIR)/../hermes/reactexecutor/Android.mk - -include $(REACT_SRC_DIR)/modules/blob/jni/Android.mk