Skip to content

Commit

Permalink
Rename Binding to FabricUIManagerBinding (#46705)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46705

We have multiple classes in React Native Android acting as a binding layer (between C++ and Java, between C++ and JS). Make it more obvious this Binding is for (Android) FabricUIManager and flatten the (now) unused Binding interface.

Changelog: [Android][Removed] BindingImpl is no longer part of the public interface

Reviewed By: cortinico

Differential Revision: D63536329

fbshipit-source-id: 329d184c1889fbe804995211cdd339b50a7c9234
  • Loading branch information
javache authored and facebook-github-bot committed Sep 30, 2024
1 parent 8dd6164 commit 18faf68
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 206 deletions.
35 changes: 1 addition & 34 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -2578,39 +2578,6 @@ public abstract interface class com/facebook/react/devsupport/interfaces/StackFr
public abstract fun toJSON ()Lorg/json/JSONObject;
}

public abstract interface class com/facebook/react/fabric/Binding {
public abstract fun drainPreallocateViewsQueue ()V
public abstract fun driveCxxAnimations ()V
public abstract fun getInspectorDataForInstance (Lcom/facebook/react/fabric/events/EventEmitterWrapper;)Lcom/facebook/react/bridge/ReadableNativeMap;
public abstract fun register (Lcom/facebook/react/bridge/RuntimeExecutor;Lcom/facebook/react/bridge/RuntimeScheduler;Lcom/facebook/react/fabric/FabricUIManager;Lcom/facebook/react/fabric/events/EventBeatManager;Lcom/facebook/react/fabric/ComponentFactory;Lcom/facebook/react/fabric/ReactNativeConfig;)V
public abstract fun reportMount (I)V
public abstract fun setConstraints (IFFFFFFZZ)V
public abstract fun setPixelDensity (F)V
public abstract fun startSurface (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;)V
public abstract fun startSurfaceWithConstraints (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;FFFFFFZZ)V
public abstract fun startSurfaceWithSurfaceHandler (ILcom/facebook/react/fabric/SurfaceHandlerBinding;Z)V
public abstract fun stopSurface (I)V
public abstract fun stopSurfaceWithSurfaceHandler (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
public abstract fun unregister ()V
}

public final class com/facebook/react/fabric/BindingImpl : com/facebook/react/fabric/Binding {
public fun <init> ()V
public fun drainPreallocateViewsQueue ()V
public fun driveCxxAnimations ()V
public fun getInspectorDataForInstance (Lcom/facebook/react/fabric/events/EventEmitterWrapper;)Lcom/facebook/react/bridge/ReadableNativeMap;
public fun register (Lcom/facebook/react/bridge/RuntimeExecutor;Lcom/facebook/react/bridge/RuntimeScheduler;Lcom/facebook/react/fabric/FabricUIManager;Lcom/facebook/react/fabric/events/EventBeatManager;Lcom/facebook/react/fabric/ComponentFactory;Lcom/facebook/react/fabric/ReactNativeConfig;)V
public fun reportMount (I)V
public fun setConstraints (IFFFFFFZZ)V
public fun setPixelDensity (F)V
public fun startSurface (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;)V
public fun startSurfaceWithConstraints (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;FFFFFFZZ)V
public fun startSurfaceWithSurfaceHandler (ILcom/facebook/react/fabric/SurfaceHandlerBinding;Z)V
public fun stopSurface (I)V
public fun stopSurfaceWithSurfaceHandler (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
public fun unregister ()V
}

public final class com/facebook/react/fabric/ComponentFactory {
public fun <init> ()V
}
Expand Down Expand Up @@ -2715,7 +2682,7 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
public fun resolveView (I)Landroid/view/View;
public fun sendAccessibilityEvent (II)V
public fun sendAccessibilityEventFromJS (IILjava/lang/String;)V
public fun setBinding (Lcom/facebook/react/fabric/Binding;)V
public fun setBinding (Lcom/facebook/react/fabric/FabricUIManagerBinding;)V
public fun setJSResponder (IIIZ)V
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
public fun startSurface (Lcom/facebook/react/interfaces/fabric/SurfaceHandler;Landroid/content/Context;Landroid/view/View;)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public class FabricUIManager
FabricSoLoader.staticInit();
}

@Nullable private Binding mBinding;
@Nullable private FabricUIManagerBinding mBinding;
@NonNull private final ReactApplicationContext mReactApplicationContext;
@NonNull private final MountingManager mMountingManager;
@NonNull private final EventDispatcher mEventDispatcher;
Expand Down Expand Up @@ -872,7 +872,7 @@ public void runGuarded() {
}
}

public void setBinding(Binding binding) {
public void setBinding(FabricUIManagerBinding binding) {
mBinding = binding;
}

Expand Down Expand Up @@ -1271,7 +1271,7 @@ public void didMountItems(@Nullable List<MountItem> mountItems) {
public void run() {
mMountNotificationScheduled = false;

final @Nullable Binding binding = mBinding;
final @Nullable FabricUIManagerBinding binding = mBinding;
if (binding == null || mDestroyed) {
mMountedSurfaceIds.clear();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package com.facebook.react.fabric

import android.annotation.SuppressLint
import com.facebook.jni.HybridData
import com.facebook.jni.HybridClassBase
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.NativeMap
import com.facebook.react.bridge.ReadableNativeMap
Expand All @@ -21,8 +21,12 @@ import com.facebook.react.uimanager.PixelUtil.getDisplayMetricDensity

@DoNotStrip
@SuppressLint("MissingNativeLoadLibrary")
public class BindingImpl : Binding {
@DoNotStrip @Suppress("NoHungarianNotation") private val mHybridData: HybridData = initHybrid()
internal class FabricUIManagerBinding : HybridClassBase() {
init {
initHybrid()
}

private external fun initHybrid()

private external fun installFabricUIManager(
runtimeExecutor: RuntimeExecutor,
Expand All @@ -33,9 +37,9 @@ public class BindingImpl : Binding {
reactNativeConfig: Any
)

external override fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)
public external fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)

external override fun startSurfaceWithConstraints(
public external fun startSurfaceWithConstraints(
surfaceId: Int,
moduleName: String,
initialProps: NativeMap,
Expand All @@ -49,19 +53,19 @@ public class BindingImpl : Binding {
doLeftAndRightSwapInRTL: Boolean
)

external override fun startSurfaceWithSurfaceHandler(
public external fun startSurfaceWithSurfaceHandler(
surfaceId: Int,
surfaceHandler: SurfaceHandlerBinding,
isMountable: Boolean
)

external override fun stopSurface(surfaceId: Int)
public external fun stopSurface(surfaceId: Int)

external override fun stopSurfaceWithSurfaceHandler(surfaceHandler: SurfaceHandlerBinding)
public external fun stopSurfaceWithSurfaceHandler(surfaceHandler: SurfaceHandlerBinding)

external override fun setPixelDensity(pointScaleFactor: Float)
public external fun setPixelDensity(pointScaleFactor: Float)

external override fun setConstraints(
public external fun setConstraints(
surfaceId: Int,
minWidth: Float,
maxWidth: Float,
Expand All @@ -73,17 +77,17 @@ public class BindingImpl : Binding {
doLeftAndRightSwapInRTL: Boolean
)

external override fun driveCxxAnimations()
public external fun driveCxxAnimations()

external override fun drainPreallocateViewsQueue()
public external fun drainPreallocateViewsQueue()

external override fun reportMount(surfaceId: Int)
public external fun reportMount(surfaceId: Int)

external override fun getInspectorDataForInstance(
public external fun getInspectorDataForInstance(
eventEmitterWrapper: EventEmitterWrapper?
): ReadableNativeMap?

override fun register(
public fun register(
runtimeExecutor: RuntimeExecutor,
runtimeScheduler: RuntimeScheduler,
fabricUIManager: FabricUIManager,
Expand All @@ -104,7 +108,7 @@ public class BindingImpl : Binding {

private external fun uninstallFabricUIManager()

override fun unregister() {
public fun unregister() {
uninstallFabricUIManager()
}

Expand All @@ -113,7 +117,5 @@ public class BindingImpl : Binding {
FabricSoLoader.staticInit()
MapBufferSoLoader.staticInit()
}

@JvmStatic private external fun initHybrid(): HybridData
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public UIManager createUIManager(ReactApplicationContext reactApplicationContext

Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManagerProviderImpl.registerBinding");
final Binding binding = new BindingImpl();
final FabricUIManagerBinding binding = new FabricUIManagerBinding();

CatalystInstance catalystInstance = reactApplicationContext.getCatalystInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.devsupport.StackTraceHelper;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.fabric.Binding;
import com.facebook.react.fabric.BindingImpl;
import com.facebook.react.fabric.ComponentFactory;
import com.facebook.react.fabric.FabricUIManager;
import com.facebook.react.fabric.FabricUIManagerBinding;
import com.facebook.react.fabric.events.EventBeatManager;
import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler;
import com.facebook.react.internal.AndroidChoreographerProvider;
Expand Down Expand Up @@ -272,7 +271,7 @@ final class ReactInstance {
// Misc initialization that needs to be done before Fabric init
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(mBridgelessReactContext);

Binding binding = new BindingImpl();
FabricUIManagerBinding binding = new FabricUIManagerBinding();
binding.register(
getBufferedRuntimeExecutor(),
getRuntimeScheduler(),
Expand Down
Loading

0 comments on commit 18faf68

Please sign in to comment.