Skip to content

Commit

Permalink
Revert D50926218: Adding getFabricUIManager() APIs to ReactContext
Browse files Browse the repository at this point in the history
Differential Revision:
D50926218

Original commit changeset: f311affb0f82

Original Phabricator Diff: D50926218

fbshipit-source-id: 313fd5aff1314860994487d1f4d17d2a2d5fe8c1
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Nov 29, 2023
1 parent 93be030 commit c8db60c
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArraySet;
Expand Down Expand Up @@ -555,25 +554,6 @@ public boolean isBridgeless() {
return mCatalystInstance.getJSIModule(moduleType);
}

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
/**
* Get the UIManager for Fabric from the CatalystInstance.
*
* @return The UIManager when CatalystInstance is active.
*/
public @Nullable UIManager getFabricUIManager() {
if (!hasActiveReactInstance()) {
throw new IllegalStateException(
"Unable to retrieve a UIManager if CatalystInstance is not active.");
}
UIManager uiManager = mCatalystInstance.getFabricUIManager();
return uiManager != null
? uiManager
: (UIManager) mCatalystInstance.getJSIModule(JSIModuleType.UIManager);
}

/**
* Get the sourceURL for the JS bundle from the CatalystInstance. This method is needed for
* compatibility with bridgeless mode, which has no CatalystInstance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactNoCrashBridgeNotAllowedSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
Expand Down Expand Up @@ -85,11 +84,6 @@ public void setSourceURL(String sourceURL) {
+ moduleType.name());
}

@Override
public @Nullable UIManager getFabricUIManager() {
return mReactHost.getUIManager();
}

@Override
public CatalystInstance getCatalystInstance() {
ReactSoftExceptionLogger.logSoftExceptionVerbose(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UIManager;

/**
* Wraps {@link ReactContext} with the base {@link Context} passed into the constructor. It provides
Expand Down Expand Up @@ -117,12 +116,4 @@ public JSIModule getJSIModule(JSIModuleType moduleType) {
}
return super.getJSIModule(moduleType);
}

@Override
public UIManager getFabricUIManager() {
if (isBridgeless()) {
return mReactApplicationContext.getFabricUIManager();
}
return super.getFabricUIManager();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
Expand Down Expand Up @@ -52,7 +53,7 @@ private static UIManager getUIManager(
@UIManagerType int uiManagerType,
boolean returnNullIfCatalystIsInactive) {
if (context.isBridgeless()) {
@Nullable UIManager uiManager = context.getFabricUIManager();
@Nullable UIManager uiManager = (UIManager) context.getJSIModule(JSIModuleType.UIManager);
if (uiManager == null) {
ReactSoftExceptionLogger.logSoftException(
TAG,
Expand Down Expand Up @@ -84,7 +85,7 @@ private static UIManager getUIManager(
CatalystInstance catalystInstance = context.getCatalystInstance();
try {
return uiManagerType == FABRIC
? context.getFabricUIManager()
? (UIManager) catalystInstance.getJSIModule(JSIModuleType.UIManager)
: catalystInstance.getNativeModule(UIManagerModule.class);
} catch (IllegalArgumentException ex) {
// TODO T67518514 Clean this up once we migrate everything over to bridgeless mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class NativeAnimatedNodeTraversalTest {
whenever(catalystInstanceMock.getJSIModule(any(JSIModuleType::class.java))).thenAnswer {
uiManagerMock
}
whenever(reactApplicationContextMock.getFabricUIManager()).thenAnswer { uiManagerMock }
whenever(catalystInstanceMock.getNativeModule(UIManagerModule::class.java)).thenAnswer {
uiManagerMock
}
Expand Down

0 comments on commit c8db60c

Please sign in to comment.