From 7d8af3b6acee3c65bdcbc232de5948b88f061bac Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Wed, 10 Jan 2024 04:51:38 -0800 Subject: [PATCH] Move InspectorFlags JNI wrapper into devsupport library (#42179) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42179 As titled, also moving `InspectorFlags.java` across packages. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D52367642 fbshipit-source-id: 01fabbb57942e8a61ce711e9e0beb564a30bbfbd --- .../com/facebook/react/devsupport/DevServerHelper.java | 1 - .../facebook/react/devsupport/DevSupportManagerBase.java | 1 - .../react/{bridge => devsupport}/InspectorFlags.java | 6 +++--- .../jni/react/{jni => devsupport}/JInspectorFlags.cpp | 8 ++++---- .../main/jni/react/{jni => devsupport}/JInspectorFlags.h | 8 ++++---- .../ReactAndroid/src/main/jni/react/devsupport/OnLoad.cpp | 2 ++ .../ReactAndroid/src/main/jni/react/jni/OnLoad.cpp | 2 -- 7 files changed, 13 insertions(+), 15 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/{bridge => devsupport}/InspectorFlags.java (78%) rename packages/react-native/ReactAndroid/src/main/jni/react/{jni => devsupport}/JInspectorFlags.cpp (81%) rename packages/react-native/ReactAndroid/src/main/jni/react/{jni => devsupport}/JInspectorFlags.h (72%) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index 31eb28004a0e3a..5b5e28c57bcfa4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -14,7 +14,6 @@ import androidx.annotation.Nullable; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; -import com.facebook.react.bridge.InspectorFlags; import com.facebook.react.bridge.ReactContext; import com.facebook.react.common.ReactConstants; import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index 7a4828e3a518fc..05bd027eaa10fc 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -33,7 +33,6 @@ import com.facebook.infer.annotation.Assertions; import com.facebook.react.R; import com.facebook.react.bridge.DefaultJSExceptionHandler; -import com.facebook.react.bridge.InspectorFlags; import com.facebook.react.bridge.JSBundleLoader; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactMarker; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/InspectorFlags.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorFlags.java similarity index 78% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/InspectorFlags.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorFlags.java index 1e7b7bb750c997..c227f1c82ff1b5 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/InspectorFlags.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorFlags.java @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.bridge; +package com.facebook.react.devsupport; import com.facebook.proguard.annotations.DoNotStrip; -/** fbjni interface for reading `jsinspector_modern::InspectorFlags`. */ +/** JNI wrapper for `jsinspector_modern::InspectorFlags`. */ @DoNotStrip public class InspectorFlags { static { - ReactBridge.staticInit(); + DevSupportSoLoader.staticInit(); } @DoNotStrip diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JInspectorFlags.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.cpp similarity index 81% rename from packages/react-native/ReactAndroid/src/main/jni/react/jni/JInspectorFlags.cpp rename to packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.cpp index 607aab0ac23b64..a826068d799823 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JInspectorFlags.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.cpp @@ -9,16 +9,16 @@ #include -namespace facebook::react { +namespace facebook::react::jsinspector_modern { bool JInspectorFlags::getEnableModernCDPRegistry(jni::alias_ref) { - auto& inspectorFlags = jsinspector_modern::InspectorFlags::getInstance(); + auto& inspectorFlags = InspectorFlags::getInstance(); return inspectorFlags.getEnableModernCDPRegistry(); } bool JInspectorFlags::getEnableCxxInspectorPackagerConnection( jni::alias_ref) { - auto& inspectorFlags = jsinspector_modern::InspectorFlags::getInstance(); + auto& inspectorFlags = InspectorFlags::getInstance(); return inspectorFlags.getEnableCxxInspectorPackagerConnection(); } @@ -33,4 +33,4 @@ void JInspectorFlags::registerNatives() { }); } -} // namespace facebook::react +} // namespace facebook::react::jsinspector_modern diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JInspectorFlags.h b/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.h similarity index 72% rename from packages/react-native/ReactAndroid/src/main/jni/react/jni/JInspectorFlags.h rename to packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.h index 7944f8360369c7..e91e7cc7d5d210 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JInspectorFlags.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.h @@ -9,15 +9,15 @@ #include -namespace facebook::react { +namespace facebook::react::jsinspector_modern { /** - * fbjni interface for reading `jsinspector_modern::InspectorFlags`. + * JNI wrapper for `jsinspector_modern::InspectorFlags`. */ class JInspectorFlags : public jni::JavaClass { public: static constexpr auto kJavaDescriptor = - "Lcom/facebook/react/bridge/InspectorFlags;"; + "Lcom/facebook/react/devsupport/InspectorFlags;"; static bool getEnableModernCDPRegistry(jni::alias_ref); @@ -29,4 +29,4 @@ class JInspectorFlags : public jni::JavaClass { JInspectorFlags(); }; -} // namespace facebook::react +} // namespace facebook::react::jsinspector_modern diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/OnLoad.cpp index b9f61a958ddb39..1a08e13bd30f59 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/devsupport/OnLoad.cpp @@ -7,6 +7,7 @@ #include "JCxxInspectorPackagerConnection.h" #include "JCxxInspectorPackagerConnectionWebSocketDelegate.h" +#include "JInspectorFlags.h" #include @@ -16,5 +17,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) { registerNatives(); facebook::react::jsinspector_modern:: JCxxInspectorPackagerConnectionWebSocketDelegate::registerNatives(); + facebook::react::jsinspector_modern::JInspectorFlags::registerNatives(); }); } diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index 389990e65ca10a..1a7e18b654fd6a 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -17,7 +17,6 @@ #include "CxxModuleWrapperBase.h" #include "JCallback.h" #include "JInspector.h" -#include "JInspectorFlags.h" #include "JReactMarker.h" #include "JavaScriptExecutorHolder.h" #include "ProxyExecutor.h" @@ -85,7 +84,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { WritableNativeMap::registerNatives(); JReactMarker::registerNatives(); JInspector::registerNatives(); - JInspectorFlags::registerNatives(); }); }