diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index d5c2c739c..c35b3dfc1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -234,6 +234,7 @@ public abstract class ReactInstanceManager { protected @Nullable Activity mCurrentActivity; protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler; protected @Nullable RedBoxHandler mRedBoxHandler; + protected boolean mLazyNativeModulesEnabled; protected Builder() { } @@ -366,6 +367,11 @@ public abstract class ReactInstanceManager { return this; } + public Builder setLazyNativeModulesEnabled(boolean lazyNativeModulesEnabled) { + mLazyNativeModulesEnabled = lazyNativeModulesEnabled; + return this; + } + /** * Instantiates a new {@link ReactInstanceManagerImpl}. * Before calling {@code build}, the following must be called: @@ -378,16 +384,16 @@ public abstract class ReactInstanceManager { */ public ReactInstanceManager build() { Assertions.assertNotNull( - mApplication, - "Application property has not been set with this builder"); + mApplication, + "Application property has not been set with this builder"); Assertions.assertCondition( - mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null, - "JS Bundle File or Asset URL has to be provided when dev support is disabled"); + mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null, + "JS Bundle File or Asset URL has to be provided when dev support is disabled"); Assertions.assertCondition( - mJSMainModuleName != null || mJSBundleAssetUrl != null || mJSBundleLoader != null, - "Either MainModuleName or JS Bundle File needs to be provided"); + mJSMainModuleName != null || mJSBundleAssetUrl != null || mJSBundleLoader != null, + "Either MainModuleName or JS Bundle File needs to be provided"); if (mUIImplementationProvider == null) { // create default UIImplementationProvider if the provided one is null. @@ -395,20 +401,21 @@ public abstract class ReactInstanceManager { } return new XReactInstanceManagerImpl( - mApplication, - mCurrentActivity, - mDefaultHardwareBackBtnHandler, - (mJSBundleLoader == null && mJSBundleAssetUrl != null) ? - JSBundleLoader.createAssetLoader(mApplication, mJSBundleAssetUrl) : mJSBundleLoader, - mJSMainModuleName, - mPackages, - mUseDeveloperSupport, - mBridgeIdleDebugListener, - Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"), - mUIImplementationProvider, - mNativeModuleCallExceptionHandler, - mJSCConfig, - mRedBoxHandler); + mApplication, + mCurrentActivity, + mDefaultHardwareBackBtnHandler, + (mJSBundleLoader == null && mJSBundleAssetUrl != null) ? + JSBundleLoader.createAssetLoader(mApplication, mJSBundleAssetUrl) : mJSBundleLoader, + mJSMainModuleName, + mPackages, + mUseDeveloperSupport, + mBridgeIdleDebugListener, + Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"), + mUIImplementationProvider, + mNativeModuleCallExceptionHandler, + mJSCConfig, + mRedBoxHandler, + mLazyNativeModulesEnabled); } } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java index 618cf61a5..239e2e5b3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java @@ -132,6 +132,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; private final MemoryPressureRouter mMemoryPressureRouter; private final @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler; private final JSCConfig mJSCConfig; + private final boolean mLazyNativeModulesEnabled; private final ReactInstanceDevCommandsHandler mDevInterface = new ReactInstanceDevCommandsHandler() { @@ -289,7 +290,8 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; UIImplementationProvider uiImplementationProvider, NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler, JSCConfig jscConfig, - @Nullable RedBoxHandler redBoxHandler) { + @Nullable RedBoxHandler redBoxHandler, + boolean lazyNativeModulesEnabled) { initializeSoLoaderIfNecessary(applicationContext); @@ -316,6 +318,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; mMemoryPressureRouter = new MemoryPressureRouter(applicationContext); mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler; mJSCConfig = jscConfig; + mLazyNativeModulesEnabled = lazyNativeModulesEnabled; } @Override