forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding BridgelessReleaseDevSupportManager
Summary: `handleReloadJS()` was a no-op for [ReleaseDevSupportManager](https://www.internalfb.com/code/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/ReleaseDevSupportManager.java?lines=139) which is why in order to fix reload() for Bridgeless in Android went through this path D55342296. However, this is the same case for [shouldShowDevMenuOrReload](https://www.internalfb.com/code/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java?lines=299) since `showDevOptionsDialog()` & `handleReloadJS()` were no-op for ReleaseDevSupportManager. Changelog: [ANDROID][ADDED] Add BridgelessReleaseDevSupportManager in order to handle APIs pertaining to Bridgeless in RELEASE(useDeveloperSupport = false)mode. Differential Revision: D56734242
- Loading branch information
1 parent
e498792
commit ff5af50
Showing
3 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
221 changes: 221 additions & 0 deletions
221
...tAndroid/src/main/java/com/facebook/react/runtime/BridgelessReleaseDevSupportManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/* | ||
* 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.runtime; | ||
|
||
import android.app.Activity; | ||
import android.util.Pair; | ||
import android.view.View; | ||
import androidx.annotation.Nullable; | ||
import com.facebook.react.bridge.DefaultJSExceptionHandler; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.bridge.ReadableArray; | ||
import com.facebook.react.common.SurfaceDelegate; | ||
import com.facebook.react.devsupport.interfaces.BundleLoadCallback; | ||
import com.facebook.react.devsupport.interfaces.DevOptionHandler; | ||
import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback; | ||
import com.facebook.react.devsupport.interfaces.DevSupportManager; | ||
import com.facebook.react.devsupport.interfaces.ErrorCustomizer; | ||
import com.facebook.react.devsupport.interfaces.ErrorType; | ||
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback; | ||
import com.facebook.react.devsupport.interfaces.RedBoxHandler; | ||
import com.facebook.react.devsupport.interfaces.StackFrame; | ||
import com.facebook.react.modules.debug.interfaces.DeveloperSettings; | ||
import java.io.File; | ||
|
||
/** | ||
* A dummy implementation of {@link DevSupportManager} to be used in production mode where | ||
* development features aren't needed. | ||
*/ | ||
public class BridgelessReleaseDevSupportManager implements DevSupportManager { | ||
|
||
private final DefaultJSExceptionHandler mDefaultJSExceptionHandler; | ||
private final ReactHostImpl mReactHost; | ||
|
||
public BridgelessReleaseDevSupportManager(ReactHostImpl host) { | ||
mDefaultJSExceptionHandler = new DefaultJSExceptionHandler(); | ||
mReactHost = host; | ||
} | ||
|
||
@Override | ||
public void showNewJavaError(String message, Throwable e) {} | ||
|
||
@Override | ||
public void addCustomDevOption(String optionName, DevOptionHandler optionHandler) {} | ||
|
||
@Override | ||
public void showNewJSError(String message, ReadableArray details, int errorCookie) {} | ||
|
||
@Override | ||
public @Nullable View createRootView(String appKey) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void destroyRootView(View rootView) {} | ||
|
||
@Override | ||
public void updateJSError(String message, ReadableArray details, int errorCookie) {} | ||
|
||
@Override | ||
public void hideRedboxDialog() {} | ||
|
||
@Override | ||
public void showDevOptionsDialog() {} | ||
|
||
@Override | ||
public void setDevSupportEnabled(boolean isDevSupportEnabled) {} | ||
|
||
@Override | ||
public void startInspector() {} | ||
|
||
@Override | ||
public void stopInspector() {} | ||
|
||
@Override | ||
public void setHotModuleReplacementEnabled(boolean isHotModuleReplacementEnabled) {} | ||
|
||
@Override | ||
public void setRemoteJSDebugEnabled(boolean isRemoteJSDebugEnabled) {} | ||
|
||
@Override | ||
public void setFpsDebugEnabled(boolean isFpsDebugEnabled) {} | ||
|
||
@Override | ||
public void toggleElementInspector() {} | ||
|
||
@Override | ||
public boolean getDevSupportEnabled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public DeveloperSettings getDevSettings() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public RedBoxHandler getRedBoxHandler() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onNewReactContextCreated(ReactContext reactContext) {} | ||
|
||
@Override | ||
public void onReactInstanceDestroyed(ReactContext reactContext) {} | ||
|
||
@Override | ||
public String getSourceMapUrl() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getSourceUrl() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getJSBundleURLForRemoteDebugging() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDownloadedJSBundleFile() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean hasUpToDateJSBundleInCache() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void reloadSettings() {} | ||
|
||
@Override | ||
public void handleReloadJS() { | ||
mReactHost.reload("BridgelessReleaseDevSupportManager.handleReloadJS()"); | ||
} | ||
|
||
@Override | ||
public void reloadJSFromServer(String bundleURL) {} | ||
|
||
@Override | ||
public void reloadJSFromServer(final String bundleURL, final BundleLoadCallback callback) {} | ||
|
||
@Override | ||
public void loadSplitBundleFromServer(String bundlePath, DevSplitBundleCallback callback) {} | ||
|
||
@Override | ||
public void isPackagerRunning(final PackagerStatusCallback callback) { | ||
callback.onPackagerStatusFetched(false); | ||
} | ||
|
||
@Override | ||
public @Nullable File downloadBundleResourceFromUrlSync( | ||
final String resourceURL, final File outputFile) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable String getLastErrorTitle() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable StackFrame[] getLastErrorStack() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable ErrorType getLastErrorType() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getLastErrorCookie() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void registerErrorCustomizer(ErrorCustomizer errorCustomizer) {} | ||
|
||
@Override | ||
public Pair<String, StackFrame[]> processErrorCustomizers(Pair<String, StackFrame[]> errorInfo) { | ||
return errorInfo; | ||
} | ||
|
||
@Override | ||
public void setPackagerLocationCustomizer( | ||
DevSupportManager.PackagerLocationCustomizer packagerLocationCustomizer) {} | ||
|
||
@Override | ||
public void handleException(Exception e) { | ||
mDefaultJSExceptionHandler.handleException(e); | ||
} | ||
|
||
@Override | ||
public @Nullable Activity getCurrentActivity() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable SurfaceDelegate createSurfaceDelegate(String moduleName) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void openDebugger() {} | ||
|
||
@Override | ||
public void showPausedInDebuggerOverlay( | ||
String message, PausedInDebuggerOverlayCommandListener listener) {} | ||
|
||
@Override | ||
public void hidePausedInDebuggerOverlay() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters