DevSupportManagerBase: Rename getCurrentContext() -> getCurrentReactContext() (#47390)

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

getCurrentContext() is very ambiguous.

Changelog: [Android][Breaking] - Make DevSupportManagerBase.getCurrentReactContext() public

Reviewed By: mdvacca

Differential Revision: D65433217

fbshipit-source-id: a739d206de8085fc5b47b2a31c7e94fe6e71852f
This commit is contained in:
Ramanpreet Nara authored and Facebook GitHub Bot committed 2024-11-04 18:46:35 -08:00
1 parent fe656be26e
commit 5a6a42c7d0
3 files changed
+22 -20

No files matched your search

@@ -2161,7 +2161,7 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
public fun fetchSplitBundleAndCreateBundleLoader (Ljava/lang/String;Lcom/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader;)V
protected fun getApplicationContext ()Landroid/content/Context;
public fun getCurrentActivity ()Landroid/app/Activity;
protected fun getCurrentContext ()Lcom/facebook/react/bridge/ReactContext;
protected fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
public fun getDevLoadingViewManager ()Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;
public fun getDevServerHelper ()Lcom/facebook/react/devsupport/DevServerHelper;
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
@@ -97,8 +97,8 @@ public final class BridgeDevSupportManager extends DevSupportManagerBase {
new CallbackWithBundleLoader() {
@Override
public void onSuccess(JSBundleLoader bundleLoader) {
bundleLoader.loadScript(getCurrentContext().getCatalystInstance());
getCurrentContext()
bundleLoader.loadScript(getCurrentReactContext().getCatalystInstance());
getCurrentReactContext()
.getJSModule(HMRClient.class)
.registerBundle(getDevServerHelper().getDevServerSplitBundleURL(bundlePath));
callback.onSuccess();
@@ -107,7 +107,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
private @Nullable DebugOverlayController mDebugOverlayController;
private boolean mDevLoadingViewVisible = false;
private int mPendingJSSplitBundleRequests = 0;
private @Nullable ReactContext mCurrentContext;
private @Nullable ReactContext mCurrentReactContext;
private final DeveloperSettings mDevSettings;
private boolean mIsReceiverRegistered = false;
private boolean mIsShakeDetectorStarted = false;
@@ -429,11 +429,11 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
() -> {
boolean nextEnabled = !mDevSettings.isHotModuleReplacementEnabled();
mDevSettings.setHotModuleReplacementEnabled(nextEnabled);
if (mCurrentContext != null) {
if (mCurrentReactContext != null) {
if (nextEnabled) {
mCurrentContext.getJSModule(HMRClient.class).enable();
mCurrentReactContext.getJSModule(HMRClient.class).enable();
} else {
mCurrentContext.getJSModule(HMRClient.class).disable();
mCurrentReactContext.getJSModule(HMRClient.class).disable();
}
}
if (nextEnabled && !mDevSettings.isJSDevModeEnabled()) {
@@ -542,8 +542,10 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
.setOnCancelListener(dialog -> mDevOptionsDialog = null)
.create();
mDevOptionsDialog.show();
if (mCurrentContext != null) {
mCurrentContext.getJSModule(RCTNativeAppEventEmitter.class).emit("RCTDevMenuShown", null);
if (mCurrentReactContext != null) {
mCurrentReactContext
.getJSModule(RCTNativeAppEventEmitter.class)
.emit("RCTDevMenuShown", null);
}
}
@@ -588,7 +590,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
@Override
public void onReactInstanceDestroyed(ReactContext reactContext) {
if (reactContext == mCurrentContext) {
if (reactContext == mCurrentReactContext) {
// only call reset context when the destroyed context matches the one that is currently set
// for this manager
resetCurrentContext(null);
@@ -664,12 +666,12 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
private void resetCurrentContext(@Nullable ReactContext reactContext) {
if (mCurrentContext == reactContext) {
if (mCurrentReactContext == reactContext) {
// new context is the same as the old one - do nothing
return;
}
mCurrentContext = reactContext;
mCurrentReactContext = reactContext;
// Recreate debug overlay controller with new CatalystInstance object
if (mDebugOverlayController != null) {
@@ -679,13 +681,13 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
mDebugOverlayController = new DebugOverlayController(reactContext);
}
if (mCurrentContext != null) {
if (mCurrentReactContext != null) {
try {
URL sourceUrl = new URL(getSourceUrl());
String path = sourceUrl.getPath().substring(1); // strip initial slash in path
String host = sourceUrl.getHost();
int port = sourceUrl.getPort() != -1 ? sourceUrl.getPort() : sourceUrl.getDefaultPort();
mCurrentContext
mCurrentReactContext
.getJSModule(HMRClient.class)
.setup("android", path, host, port, mDevSettings.isHotModuleReplacementEnabled());
} catch (MalformedURLException e) {
@@ -705,8 +707,8 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
}
protected @Nullable ReactContext getCurrentContext() {
return mCurrentContext;
protected @Nullable ReactContext getCurrentReactContext() {
return mCurrentReactContext;
}
public @Nullable String getJSAppBundleName() {
@@ -783,7 +785,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
public void onSuccess() {
UiThreadUtil.runOnUiThread(() -> hideSplitBundleDevLoadingView());
@Nullable ReactContext context = mCurrentContext;
@Nullable ReactContext context = mCurrentReactContext;
if (context == null || !context.hasActiveReactInstance()) {
return;
}
@@ -864,10 +866,10 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
private void handleCaptureHeap(final Responder responder) {
if (mCurrentContext == null) {
if (mCurrentReactContext == null) {
return;
}
JSCHeapCapture heapCapture = mCurrentContext.getNativeModule(JSCHeapCapture.class);
JSCHeapCapture heapCapture = mCurrentReactContext.getNativeModule(JSCHeapCapture.class);
if (heapCapture != null) {
heapCapture.captureHeap(
@@ -1160,7 +1162,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
@Override
public void openDebugger() {
mDevServerHelper.openDebugger(
mCurrentContext, mApplicationContext.getString(R.string.catalyst_open_debugger_error));
mCurrentReactContext, mApplicationContext.getString(R.string.catalyst_open_debugger_error));
}
@Override