diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt index cdc8be7862de..7587d9cc7a89 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt @@ -16,14 +16,29 @@ import com.facebook.react.uimanager.events.EventDispatcher @OptIn(UnstableReactNativeAPI::class) public interface UIManager : PerformanceCounter { - /** Registers a new root view. @Deprecated call startSurface instead */ + /** + * Registers a new root view. + * + * @deprecated Use `ReactHost.createSurface(...)` and `ReactSurface.start()` instead. + */ @UiThread @ThreadConfined(ThreadConfined.UI) - @Deprecated("") + @Deprecated( + "This legacy surface API will be removed in a future release. " + + "Use ReactHost.createSurface(...) and ReactSurface.start() instead." + ) public fun addRootView(rootView: T, initialProps: WritableMap?): Int - /** Registers a new root view with width and height. */ + /** + * Registers a new root view with width and height. + * + * @deprecated Use `ReactHost.createSurface(...)` and `ReactSurface.start()` instead. + */ @AnyThread + @Deprecated( + "This legacy surface API will be removed in a future release. " + + "Use ReactHost.createSurface(...) and ReactSurface.start() instead." + ) public fun startSurface( rootView: T, moduleName: String, @@ -35,8 +50,14 @@ public interface UIManager : PerformanceCounter { /** * Stop a surface from running in JS and clears up native memory usage. Assumes that the native * View hierarchy has already been cleaned up. Fabric-only. + * + * @deprecated Use `ReactSurface.stop()` instead. */ - @AnyThread public fun stopSurface(surfaceId: Int) + @AnyThread + @Deprecated( + "This legacy surface API will be removed in a future release. Use ReactSurface.stop() instead." + ) + public fun stopSurface(surfaceId: Int) /** * Updates the layout specs of the RootShadowNode based on the Measure specs received by diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index a3cca69f4bfd..97de9935b8cf 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -262,6 +262,9 @@ public FabricUIManager( mReactApplicationContext.registerComponentCallbacks(viewManagerRegistry); } + /** + * @deprecated Use {@code ReactHost.createSurface(...)} and {@code ReactSurface.start()} instead. + */ @Override @UiThread @ThreadConfined(UI) @@ -271,7 +274,8 @@ public int addRootView( ReactSoftExceptionLogger.logSoftException( TAG, new IllegalViewOperationException( - "Do not call addRootView in Fabric; it is unsupported. Call startSurface instead.")); + "Do not call addRootView in Fabric; it is unsupported. Use ReactHost.createSurface(...)" + + " and ReactSurface.start() instead.")); ReactRoot reactRootView = (ReactRoot) rootView; final int rootTag = reactRootView.getRootViewTag(); @@ -341,6 +345,10 @@ public int addRootView( return mBinding != null ? mBinding.getRelativeAncestorList(rootTag, childTag) : null; } + /** + * @deprecated Use {@code ReactHost.createSurface(...)} and {@code ReactSurface.start()} instead. + */ + @Deprecated @Override @AnyThread @ThreadConfined(ANY) @@ -430,6 +438,10 @@ public void onRequestEventBeat() { mEventDispatcher.dispatchAllEvents(); } + /** + * @deprecated Use {@code ReactSurface.stop()} instead. + */ + @Deprecated @AnyThread @ThreadConfined(ANY) @Override diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt index 057006764a20..e1e708edcd1b 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt @@ -34,6 +34,7 @@ class FakeUIManager : UIManager, UIBlockViewResolver { error("Not yet implemented") } + @Deprecated("") override fun startSurface( rootView: T, moduleName: String, @@ -44,6 +45,7 @@ class FakeUIManager : UIManager, UIBlockViewResolver { error("Not yet implemented") } + @Deprecated("") override fun stopSurface(surfaceId: Int) { error("Not yet implemented") }