mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Ensure TurboModuleManager.getModule also queries CxxModuleWrappers
Summary:
We should also call `TurboModuleManager.getLegacyCxxModule('foo')` when we call `TurboModuleManager.getModule('foo')` is called.
This fixes a Marketplace crash. See: D19432594
Changelog:
[Android][Fixed] - Ensure TMM.getModule also queries CxxModuleWrappers
Reviewed By: ejanzer
Differential Revision: D19434549
fbshipit-source-id: cff741cf1587d2a0dbcdc5eb95016c8aa283b727
This commit is contained in:
committed by
Facebook Github Bot
parent
434526e13d
commit
ce18521c9e
+27
-3
@@ -10,6 +10,7 @@ package com.facebook.react.turbomodule.core;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.CxxModuleWrapper;
|
||||
import com.facebook.react.bridge.JSIModule;
|
||||
import com.facebook.react.bridge.JavaScriptContextHolder;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
@@ -55,9 +56,8 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry {
|
||||
return mTurbomoduleManagerDelegate.getEagerInitModuleNames();
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@Nullable
|
||||
protected TurboModule getJavaModule(String name) {
|
||||
private TurboModule getJavaModule(String name) {
|
||||
if (!mTurboModules.containsKey(name)) {
|
||||
final TurboModule turboModule = mTurbomoduleManagerDelegate.getModule(name);
|
||||
|
||||
@@ -75,9 +75,33 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry {
|
||||
return mTurboModules.get(name);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@Nullable
|
||||
private TurboModule getLegacyCxxModule(String name) {
|
||||
if (!mTurboModules.containsKey(name)) {
|
||||
final CxxModuleWrapper turboModule = mTurbomoduleManagerDelegate.getLegacyCxxModule(name);
|
||||
|
||||
if (turboModule instanceof TurboModule) {
|
||||
/**
|
||||
* TurboModuleManager is initialized after ReactApplicationContext has been setup.
|
||||
* Therefore, it's safe to call initialize on the TurboModule.
|
||||
*/
|
||||
((NativeModule) turboModule).initialize();
|
||||
|
||||
mTurboModules.put(name, (TurboModule) turboModule);
|
||||
}
|
||||
}
|
||||
|
||||
return mTurboModules.get(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TurboModule getModule(String name) {
|
||||
return getJavaModule(name);
|
||||
TurboModule javaModule = getJavaModule(name);
|
||||
if (javaModule != null) {
|
||||
return javaModule;
|
||||
}
|
||||
return getLegacyCxxModule(name);
|
||||
}
|
||||
|
||||
public Collection<TurboModule> getModules() {
|
||||
|
||||
Reference in New Issue
Block a user