Introduce DevSupportManager.openDebugger() method (#43685)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43685

Changelog: [Changed][Android] Expose `openDebugger()` method on `DevSupportManager`

Exposes the `openDebugger()` method on `DevSupportManager` for ease of integration by RN Android frameworks.

Reviewed By: cortinico, arushikesarwani94

Differential Revision: D55408820

fbshipit-source-id: f06684de47cee23642bf893afaedb2755453f253
This commit is contained in:
Moti Zilberman
2024-04-04 11:19:54 -07:00
committed by Facebook GitHub Bot
parent c84f5cb5cd
commit b309af79e8
5 changed files with 17 additions and 7 deletions
@@ -2131,6 +2131,7 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
public fun isPackagerRunning (Lcom/facebook/react/devsupport/interfaces/PackagerStatusCallback;)V
public fun onNewReactContextCreated (Lcom/facebook/react/bridge/ReactContext;)V
public fun onReactInstanceDestroyed (Lcom/facebook/react/bridge/ReactContext;)V
public fun openDebugger ()V
public fun processErrorCustomizers (Landroid/util/Pair;)Landroid/util/Pair;
public fun registerErrorCustomizer (Lcom/facebook/react/devsupport/interfaces/ErrorCustomizer;)V
public fun reloadJSFromServer (Ljava/lang/String;)V
@@ -2295,6 +2296,7 @@ public class com/facebook/react/devsupport/ReleaseDevSupportManager : com/facebo
public fun loadSplitBundleFromServer (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/DevSplitBundleCallback;)V
public fun onNewReactContextCreated (Lcom/facebook/react/bridge/ReactContext;)V
public fun onReactInstanceDestroyed (Lcom/facebook/react/bridge/ReactContext;)V
public fun openDebugger ()V
public fun processErrorCustomizers (Landroid/util/Pair;)Landroid/util/Pair;
public fun registerErrorCustomizer (Lcom/facebook/react/devsupport/interfaces/ErrorCustomizer;)V
public fun reloadJSFromServer (Ljava/lang/String;)V
@@ -2404,6 +2406,7 @@ public abstract interface class com/facebook/react/devsupport/interfaces/DevSupp
public abstract fun loadSplitBundleFromServer (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/DevSplitBundleCallback;)V
public abstract fun onNewReactContextCreated (Lcom/facebook/react/bridge/ReactContext;)V
public abstract fun onReactInstanceDestroyed (Lcom/facebook/react/bridge/ReactContext;)V
public abstract fun openDebugger ()V
public abstract fun processErrorCustomizers (Landroid/util/Pair;)Landroid/util/Pair;
public abstract fun registerErrorCustomizer (Lcom/facebook/react/devsupport/interfaces/ErrorCustomizer;)V
public abstract fun reloadJSFromServer (Ljava/lang/String;)V
@@ -491,7 +491,7 @@ public class DevServerHelper {
}
/** Attempt to open the JS debugger on the host machine (on-device CDP debugging). */
public void openDebugger(final ReactContext context, final String errorMessage) {
public void openDebugger(@Nullable final ReactContext context, final String errorMessage) {
// TODO(huntie): Requests to dev server should not assume 'http' URL scheme
String requestUrl =
String.format(
@@ -384,12 +384,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
if (!isConnected) {
disabledItemKeys.add(debuggerItemString);
}
options.put(
debuggerItemString,
() ->
mDevServerHelper.openDebugger(
mCurrentContext,
mApplicationContext.getString(R.string.catalyst_open_debugger_error)));
options.put(debuggerItemString, () -> openDebugger());
}
options.put(
@@ -1163,4 +1158,10 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
context.registerReceiver(receiver, filter);
}
}
@Override
public void openDebugger() {
mDevServerHelper.openDebugger(
mCurrentContext, mApplicationContext.getString(R.string.catalyst_open_debugger_error));
}
}
@@ -204,4 +204,7 @@ public class ReleaseDevSupportManager implements DevSupportManager {
public @Nullable SurfaceDelegate createSurfaceDelegate(String moduleName) {
return null;
}
@Override
public void openDebugger() {}
}
@@ -128,4 +128,7 @@ public interface DevSupportManager extends JSExceptionHandler {
*/
@Nullable
SurfaceDelegate createSurfaceDelegate(String moduleName);
/** Attempt to open the JS debugger on the host machine. */
void openDebugger();
}