Skip to content

Commit

Permalink
Introduce DevSupportManager.openDebugger() method (#43685)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Apr 4, 2024
1 parent c84f5cb commit b309af7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public String getJSBundleURLForRemoteDebugging(String mainModuleName) {
}

/** 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,7 @@ public void onOptionSelected() {
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(
Expand Down Expand Up @@ -1163,4 +1158,10 @@ private void compatRegisterReceiver(
context.registerReceiver(receiver, filter);
}
}

@Override
public void openDebugger() {
mDevServerHelper.openDebugger(
mCurrentContext, mApplicationContext.getString(R.string.catalyst_open_debugger_error));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,7 @@ public void handleException(Exception e) {
public @Nullable SurfaceDelegate createSurfaceDelegate(String moduleName) {
return null;
}

@Override
public void openDebugger() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,7 @@ interface PackagerLocationCustomizer {
*/
@Nullable
SurfaceDelegate createSurfaceDelegate(String moduleName);

/** Attempt to open the JS debugger on the host machine. */
void openDebugger();
}

0 comments on commit b309af7

Please sign in to comment.