mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add fbjni wrapper for InspectorFlags (#41913)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41913 Progress towards an opt-in setup for our new CDP backend. - Adds and configures an [fbjni](https://github.com/facebookincubator/fbjni) interface for reading `jsinspector_modern::InspectorFlags`, allowing access in Java contexts. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D52040150 fbshipit-source-id: 5459eda2747279633a8312a3979ba29a1e0d1bde
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f676f42c31
commit
7bdba281e7
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/** fbjni interface for reading `jsinspector_modern::InspectorFlags`. */
|
||||
@DoNotStrip
|
||||
public class InspectorFlags {
|
||||
static {
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public static native boolean getEnableModernCDPRegistry();
|
||||
|
||||
private InspectorFlags() {}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "JInspectorFlags.h"
|
||||
|
||||
#include <jsinspector-modern/InspectorFlags.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
bool JInspectorFlags::getEnableModernCDPRegistry(jni::alias_ref<jclass>) {
|
||||
auto& inspectorFlags = jsinspector_modern::InspectorFlags::getInstance();
|
||||
return inspectorFlags.getEnableModernCDPRegistry();
|
||||
}
|
||||
|
||||
void JInspectorFlags::registerNatives() {
|
||||
javaClassLocal()->registerNatives({
|
||||
makeNativeMethod(
|
||||
"getEnableModernCDPRegistry",
|
||||
JInspectorFlags::getEnableModernCDPRegistry),
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <fbjni/fbjni.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
/**
|
||||
* fbjni interface for reading `jsinspector_modern::InspectorFlags`.
|
||||
*/
|
||||
class JInspectorFlags : public jni::JavaClass<JInspectorFlags> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/bridge/InspectorFlags;";
|
||||
|
||||
static bool getEnableModernCDPRegistry(jni::alias_ref<jclass>);
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
private:
|
||||
JInspectorFlags();
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#ifdef WITH_INSPECTOR
|
||||
#include "JInspector.h"
|
||||
#include "JInspectorFlags.h"
|
||||
#endif
|
||||
|
||||
#ifndef WITH_GLOGINIT
|
||||
@@ -89,6 +90,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
|
||||
#ifdef WITH_INSPECTOR
|
||||
JInspector::registerNatives();
|
||||
JInspectorFlags::registerNatives();
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user