Remove unnecessary BridgeDevSupportManager (#54683)

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

This class is no longer needed and can be removed.
This is a breaking change, but the class was long deprecated so we should be fine removing it.

Changelog:
[Android] [Removed] - Remove unnecessary and unused BridgeDevSupportManager

Reviewed By: javache

Differential Revision: D87859861

fbshipit-source-id: f77d7121ace072b2c37408b0d81d84309692e05a
This commit is contained in:
Nicola Corti authored and meta-codesync[bot] committed 2025-11-25 10:32:59 -08:00
1 parent 8beb46dfdb
commit 13da82a337
7 files changed
+17 -181

No files matched your search

@@ -1833,11 +1833,6 @@ public final class com/facebook/react/defaults/DefaultTurboModuleManagerDelegate
public synthetic fun build (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/util/List;)Lcom/facebook/react/ReactPackageTurboModuleManagerDelegate;
}
public final class com/facebook/react/devsupport/BridgeDevSupportManager : com/facebook/react/devsupport/DevSupportManagerBase {
public fun <init> (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;)V
public fun handleReloadJS ()V
}
public final class com/facebook/react/devsupport/BundleDownloader {
public static final field Companion Lcom/facebook/react/devsupport/BundleDownloader$Companion;
public fun <init> (Lokhttp3/OkHttpClient;)V
@@ -1,105 +0,0 @@
/*
* 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.devsupport
import android.content.Context
import com.facebook.debug.holder.PrinterHolder.printer
import com.facebook.debug.tags.ReactDebugOverlayTags
import com.facebook.infer.annotation.Assertions
import com.facebook.react.bridge.ReactMarker
import com.facebook.react.bridge.ReactMarkerConstants
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.common.SurfaceDelegateFactory
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger.assertLegacyArchitecture
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
import com.facebook.react.devsupport.interfaces.DevLoadingViewManager
import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager
import com.facebook.react.devsupport.interfaces.RedBoxHandler
import com.facebook.react.packagerconnection.RequestHandler
/**
* Interface for accessing and interacting with development features. Following features are
* supported through this manager class:
* 1) Displaying JS errors (aka RedBox)
* 2) Displaying developers menu (Reload JS, Debug JS)
* 3) Communication with developer server in order to download updated JS bundle
* 4) Starting/stopping broadcast receiver for js reload signals
* 5) Starting/stopping motion sensor listener that recognize shake gestures which in turn may
* trigger developers menu.
* 6) Launching developers settings view
*
* This class automatically monitors the state of registered views and activities to which they are
* bound to make sure that we don't display overlay or that we we don't listen for sensor events
* when app is backgrounded.
*
* [com.facebook.react.ReactInstanceManager] implementation is responsible for instantiating this
* class as well as for populating with a reference to [com.facebook.react.bridge.CatalystInstance]
* whenever instance manager recreates it (through [onNewReactContextCreated]). Also, instance
* manager is responsible for enabling/disabling dev support in case when app is backgrounded or
* when all the views has been detached from the instance (through `setDevSupportEnabled` method).
*/
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING,
)
public class BridgeDevSupportManager(
applicationContext: Context,
reactInstanceManagerHelper: ReactInstanceDevHelper,
packagerPathForJSBundleName: String?,
enableOnCreate: Boolean,
redBoxHandler: RedBoxHandler?,
devBundleDownloadListener: DevBundleDownloadListener?,
minNumShakes: Int,
customPackagerCommandHandlers: Map<String, RequestHandler>?,
surfaceDelegateFactory: SurfaceDelegateFactory?,
devLoadingViewManager: DevLoadingViewManager?,
pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?,
) :
DevSupportManagerBase(
applicationContext,
reactInstanceManagerHelper,
packagerPathForJSBundleName,
enableOnCreate,
redBoxHandler,
devBundleDownloadListener,
minNumShakes,
customPackagerCommandHandlers,
surfaceDelegateFactory,
devLoadingViewManager,
pausedInDebuggerOverlayManager,
) {
override val uniqueTag: String
get() = "Bridge"
override fun handleReloadJS() {
UiThreadUtil.assertOnUiThread()
ReactMarker.logMarker(
ReactMarkerConstants.RELOAD,
devSettings.packagerConnectionSettings.debugServerHost,
)
// dismiss redbox if exists
hideRedboxDialog()
printer.logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: load from Server")
val bundleURL = devServerHelper.getDevServerBundleURL(Assertions.assertNotNull(jsAppBundleName))
reloadJSFromServer(bundleURL) {
UiThreadUtil.runOnUiThread { reactInstanceDevHelper.onJSBundleLoadedFromServer() }
}
}
private companion object {
init {
assertLegacyArchitecture("BridgeDevSupportManager", LegacyArchitectureLogLevel.ERROR)
}
}
}
@@ -23,9 +23,8 @@ import com.facebook.react.packagerconnection.RequestHandler
* [DevSupportManagerBase] with some additional, more flexible APIs for asynchronously loading the
* JS bundle.
*
* @constructor The primary constructor mirrors the same constructor we have for
* [BridgeDevSupportManager] and
* * is kept for backward compatibility.
* @constructor The primary constructor mirrors the same constructor we had for
* `BridgeDevSupportManager` and is kept for backward compatibility.
*/
internal class BridgelessDevSupportManager(
applicationContext: Context,
@@ -18,10 +18,10 @@ import com.facebook.react.devsupport.interfaces.RedBoxHandler
import com.facebook.react.packagerconnection.RequestHandler
/**
* A simple factory that creates instances of [DevSupportManager] implementations. Uses reflection
* to create BridgeDevSupportManager if it exists. This allows ProGuard to strip that class and its
* dependencies in release builds. If the class isn't found, [PerftestDevSupportManager] is returned
* instead.
* A simple factory that creates instances of [DevSupportManager] implementations.
*
* The first create() method is for the Old Architecture flow and is deprecated and should not be
* used anymore. The second create() method is for the New Architecture/Bridgeless flow.
*/
internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
@@ -44,57 +44,12 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
surfaceDelegateFactory: SurfaceDelegateFactory?,
devLoadingViewManager: DevLoadingViewManager?,
pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?,
): DevSupportManager {
return if (!enableOnCreate) {
ReleaseDevSupportManager()
} else
try {
// Developer support is enabled, we now must choose whether to return a DevSupportManager,
// or a more lean profiling-only PerftestDevSupportManager. We make the choice by first
// trying to return the full support DevSupportManager and if it fails, then just
// return PerftestDevSupportManager.
// ProGuard is surprisingly smart in this case and will keep a class if it detects a call
// to
// Class.forName() with a static string. So instead we generate a quasi-dynamic string to
// confuse it.
val className =
StringBuilder(DEVSUPPORT_IMPL_PACKAGE)
.append(".")
.append(DEVSUPPORT_IMPL_CLASS)
.toString()
val devSupportManagerClass = Class.forName(className)
val constructor =
devSupportManagerClass.getConstructor(
Context::class.java,
ReactInstanceDevHelper::class.java,
String::class.java,
Boolean::class.javaPrimitiveType,
RedBoxHandler::class.java,
DevBundleDownloadListener::class.java,
Int::class.javaPrimitiveType,
MutableMap::class.java,
SurfaceDelegateFactory::class.java,
DevLoadingViewManager::class.java,
PausedInDebuggerOverlayManager::class.java,
)
constructor.newInstance(
applicationContext,
reactInstanceManagerHelper,
packagerPathForJSBundleName,
true,
redBoxHandler,
devBundleDownloadListener,
minNumShakes,
customPackagerCommandHandlers,
surfaceDelegateFactory,
devLoadingViewManager,
pausedInDebuggerOverlayManager,
) as DevSupportManager
} catch (e: Exception) {
PerftestDevSupportManager(applicationContext)
}
}
): DevSupportManager =
if (!enableOnCreate) {
ReleaseDevSupportManager()
} else {
PerftestDevSupportManager(applicationContext)
}
override fun create(
applicationContext: Context,
@@ -129,9 +84,4 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
} else {
ReleaseDevSupportManager()
}
private companion object {
private const val DEVSUPPORT_IMPL_PACKAGE = "com.facebook.react.devsupport"
private const val DEVSUPPORT_IMPL_CLASS = "BridgeDevSupportManager"
}
}
@@ -18,10 +18,7 @@ import com.facebook.react.packagerconnection.RequestHandler
public interface DevSupportManagerFactory {
/**
* Factory used by the Old Architecture flow to create a [DevSupportManager] and a
* [BridgeDevSupportManager]
*/
/** Factory used by the Old Architecture flow to create a [DevSupportManager]. */
@Deprecated(
message =
"Use the other create() method with useDevSupport parameter for New Architecture. This method will be removed in a future release.",
@@ -19,8 +19,8 @@ import java.io.File
/**
* Interface for accessing and interacting with development features. In dev mode, use the
* implementation [com.facebook.react.devsupport.BridgeDevSupportManager]. In production mode, use
* the dummy implementation [com.facebook.react.devsupport.ReleaseDevSupportManager].
* implementation [com.facebook.react.devsupport.BridgelessDevSupportManager]. In production mode,
* use the dummy implementation [com.facebook.react.devsupport.ReleaseDevSupportManager].
*/
public interface DevSupportManager : JSExceptionHandler {
@@ -11,8 +11,8 @@ import android.content.Context
import android.text.SpannedString
/**
* Interface used by [com.facebook.react.devsupport.BridgeDevSupportManager] to allow interception
* on any redboxes during development and handling the information from the redbox. The
* Interface used by [com.facebook.react.devsupport.interfaces.DevSupportManager] to allow
* interception on any redboxes during development and handling the information from the redbox. The
* implementation should be passed by setRedBoxHandler in ReactInstanceManager.
*/
public interface RedBoxHandler {