Skip to content

Commit

Permalink
Remove deprecated dispatchCommand for INT
Browse files Browse the repository at this point in the history
Summary:
D15955444 introduced support for View Manager Commands that are strings.

> We need to support ints and Strings to be backwards compatible, but ints will be deprecated.

This was deprecated 5 years ago in D16019254.

While on [backwards compatibility of UIManagerModule](https://docs.google.com/document/d/1PoFDF_Ek2U-u1BOgDCYx-EgvXMMiXsSAcBkamtMq5-M/edit#heading=h.txujclhzs5ov), this was identified as `Deprecated` method that we can get rid.


- dispatchCommand(int reactTag, ~~int~~ String commandId, Nullable ReadableArray commandArgs) ;

- receiveCommand(NonNull T root, ~~int~~ String commandId, Nullable ReadableArray args) 

- dispatchViewManagerCommand(
int reactTag, ~~Dynamic~~ String commandId, Nullable ReadableArray commandArgs)

NOTE: This might need more JS changes.

- In RNLiveMapsView & RNLMARStageView used the String directly in switch casing instead of Enum

- In fb4A removed all occurrences in ViewManagers.

**PENDING:**

I believe, post this, we can also get rid of `getCommandsMap() ` Over-ride as well however I see it's introduction [dates before](https://www.internalfb.com/code/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java?lines=303-313) adding Strings type, hence leaving that untouched.

Differential Revision: D57150941
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed May 10, 2024
1 parent 8c3260f commit 9274f67
Show file tree
Hide file tree
Showing 21 changed files with 5 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,6 @@ internal class SampleNativeComponentViewManager :
}
}

@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
@Suppress("DEPRECATION") // We intentionally want to test against the legacy API here.
override fun receiveCommand(view: SampleNativeView, commandId: Int, args: ReadableArray?) {
when (commandId) {
COMMAND_CHANGE_BACKGROUND_COLOR -> {
val sentColor: Int = Color.parseColor(args?.getString(0))
view.setBackgroundColor(sentColor)
}
}
}

override fun getCommandsMap(): Map<String, Int> =
mapOf("changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR)

Expand Down
24 changes: 1 addition & 23 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,6 @@ public abstract interface class com/facebook/react/bridge/Systrace : com/faceboo
public abstract interface class com/facebook/react/bridge/UIManager : com/facebook/react/bridge/PerformanceCounter {
public abstract fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
public abstract fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public abstract fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public abstract fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public abstract fun getEventDispatcher ()Ljava/lang/Object;
public abstract fun initialize ()V
Expand Down Expand Up @@ -2581,8 +2580,6 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
public fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public fun attachRootView (Lcom/facebook/react/interfaces/fabric/SurfaceHandler;Landroid/view/View;)V
public fun clearJSResponder ()V
public fun dispatchCommand (IIILcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchCommand (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun getColor (I[Ljava/lang/String;)I
Expand Down Expand Up @@ -2742,7 +2739,6 @@ public class com/facebook/react/fabric/mounting/MountingManager {
public fun isWaitingForViewAttach (I)Z
public fun measure (Lcom/facebook/react/bridge/ReactContext;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;FLcom/facebook/yoga/YogaMeasureMode;FLcom/facebook/yoga/YogaMeasureMode;[F)J
public fun measureMapBuffer (Lcom/facebook/react/bridge/ReactContext;Ljava/lang/String;Lcom/facebook/react/common/mapbuffer/MapBuffer;Lcom/facebook/react/common/mapbuffer/MapBuffer;Lcom/facebook/react/common/mapbuffer/MapBuffer;FLcom/facebook/yoga/YogaMeasureMode;FLcom/facebook/yoga/YogaMeasureMode;[F)J
public fun receiveCommand (IIILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun sendAccessibilityEvent (III)V
public fun startSurface (ILcom/facebook/react/uimanager/ThemedReactContext;Landroid/view/View;)Lcom/facebook/react/fabric/mounting/SurfaceMountingManager;
Expand Down Expand Up @@ -2773,7 +2769,6 @@ public class com/facebook/react/fabric/mounting/SurfaceMountingManager {
public fun isStopped ()Z
public fun preallocateView (Ljava/lang/String;ILcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun printSurfaceState ()V
public fun receiveCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun removeDeleteTreeAt (III)V
public fun removeViewAt (III)V
Expand Down Expand Up @@ -2806,7 +2801,6 @@ public abstract interface class com/facebook/react/fabric/mounting/mountitems/Mo

public final class com/facebook/react/fabric/mounting/mountitems/MountItemFactory {
public static final field INSTANCE Lcom/facebook/react/fabric/mounting/mountitems/MountItemFactory;
public static final fun createDispatchCommandMountItem (IIILcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem;
public static final fun createDispatchCommandMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem;
public static final fun createIntBufferBatchMountItem (I[I[Ljava/lang/Object;I)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
public static final fun createPreAllocateViewMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
Expand Down Expand Up @@ -4263,7 +4257,6 @@ public class com/facebook/react/uimanager/NativeViewHierarchyManager {
protected final fun addRootViewGroup (ILandroid/view/View;)V
public fun clearJSResponder ()V
public fun createView (Lcom/facebook/react/uimanager/ThemedReactContext;ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
public fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
protected fun dropView (Landroid/view/View;)V
public fun findTargetTagForTouch (IFF)I
Expand Down Expand Up @@ -4993,7 +4986,6 @@ public class com/facebook/react/uimanager/UIImplementation {
protected fun createRootShadowNode ()Lcom/facebook/react/uimanager/ReactShadowNode;
protected fun createShadowNode (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactShadowNode;
public fun createView (ILjava/lang/String;ILcom/facebook/react/bridge/ReadableMap;)V
public fun dispatchViewManagerCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchViewManagerCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchViewUpdates (I)V
public fun findSubviewIn (IFFLcom/facebook/react/bridge/Callback;)V
Expand Down Expand Up @@ -5071,9 +5063,8 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public fun configureNextLayoutAnimation (Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
public static fun createConstants (Ljava/util/List;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
public fun createView (ILjava/lang/String;ILcom/facebook/react/bridge/ReadableMap;)V
public fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchViewManagerCommand (ILcom/facebook/react/bridge/Dynamic;Lcom/facebook/react/bridge/ReadableArray;)V
public fun dispatchViewManagerCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun findSubviewIn (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Callback;)V
public fun getConstants ()Ljava/util/Map;
public static fun getConstantsForViewManager (Lcom/facebook/react/uimanager/ViewManager;Ljava/util/Map;)Lcom/facebook/react/bridge/WritableMap;
Expand Down Expand Up @@ -5143,7 +5134,6 @@ public class com/facebook/react/uimanager/UIViewOperationQueue {
public fun enqueueClearJSResponder ()V
public fun enqueueConfigureLayoutAnimation (Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;)V
public fun enqueueCreateView (Lcom/facebook/react/uimanager/ThemedReactContext;ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
public fun enqueueDispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun enqueueDispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun enqueueFindTargetForTouch (IFFLcom/facebook/react/bridge/Callback;)V
public fun enqueueLayoutUpdateFinished (Lcom/facebook/react/uimanager/ReactShadowNode;Lcom/facebook/react/uimanager/UIImplementation$LayoutUpdateListener;)V
Expand Down Expand Up @@ -5243,7 +5233,6 @@ public abstract class com/facebook/react/uimanager/ViewManager : com/facebook/re
public fun onDropViewInstance (Landroid/view/View;)V
public fun onSurfaceStopped (I)V
protected fun prepareToRecycleView (Lcom/facebook/react/uimanager/ThemedReactContext;Landroid/view/View;)Landroid/view/View;
public fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
protected fun recycleView (Lcom/facebook/react/uimanager/ThemedReactContext;Landroid/view/View;)Landroid/view/View;
public fun setPadding (Landroid/view/View;IIII)V
Expand Down Expand Up @@ -6169,9 +6158,7 @@ public class com/facebook/react/views/drawer/ReactDrawerLayoutManager : com/face
public fun needsCustomLayoutForChildren ()Z
public synthetic fun openDrawer (Landroid/view/View;)V
public fun openDrawer (Lcom/facebook/react/views/drawer/ReactDrawerLayout;)V
public synthetic fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public synthetic fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/drawer/ReactDrawerLayout;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/drawer/ReactDrawerLayout;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public synthetic fun setDrawerBackgroundColor (Landroid/view/View;Ljava/lang/Integer;)V
public fun setDrawerBackgroundColor (Lcom/facebook/react/views/drawer/ReactDrawerLayout;Ljava/lang/Integer;)V
Expand Down Expand Up @@ -6716,9 +6703,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager :
public fun flashScrollIndicators (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;)V
public synthetic fun flashScrollIndicators (Ljava/lang/Object;)V
public fun getName ()Ljava/lang/String;
public synthetic fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public synthetic fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun scrollTo (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Lcom/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollToCommandData;)V
public synthetic fun scrollTo (Ljava/lang/Object;Lcom/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollToCommandData;)V
Expand Down Expand Up @@ -6843,7 +6828,6 @@ public class com/facebook/react/views/scroll/ReactScrollViewCommandHelper {
public static final field COMMAND_SCROLL_TO_END I
public fun <init> ()V
public static fun getCommandsMap ()Ljava/util/Map;
public static fun receiveCommand (Lcom/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollCommandHandler;Ljava/lang/Object;ILcom/facebook/react/bridge/ReadableArray;)V
public static fun receiveCommand (Lcom/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollCommandHandler;Ljava/lang/Object;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
}

Expand Down Expand Up @@ -6955,9 +6939,7 @@ public class com/facebook/react/views/scroll/ReactScrollViewManager : com/facebo
public fun getCommandsMap ()Ljava/util/Map;
public fun getExportedCustomDirectEventTypeConstants ()Ljava/util/Map;
public fun getName ()Ljava/lang/String;
public synthetic fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public synthetic fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/scroll/ReactScrollView;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/scroll/ReactScrollView;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun scrollTo (Lcom/facebook/react/views/scroll/ReactScrollView;Lcom/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollToCommandData;)V
public synthetic fun scrollTo (Ljava/lang/Object;Lcom/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollToCommandData;)V
Expand Down Expand Up @@ -7733,9 +7715,7 @@ public class com/facebook/react/views/textinput/ReactTextInputManager : com/face
public fun getShadowNodeClass ()Ljava/lang/Class;
protected synthetic fun onAfterUpdateTransaction (Landroid/view/View;)V
protected fun onAfterUpdateTransaction (Lcom/facebook/react/views/textinput/ReactEditText;)V
public synthetic fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public synthetic fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/textinput/ReactEditText;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/textinput/ReactEditText;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setAllowFontScaling (Lcom/facebook/react/views/textinput/ReactEditText;Z)V
public fun setAutoCapitalize (Lcom/facebook/react/views/textinput/ReactEditText;Lcom/facebook/react/bridge/Dynamic;)V
Expand Down Expand Up @@ -7954,9 +7934,7 @@ public class com/facebook/react/views/view/ReactViewManager : com/facebook/react
public fun nextFocusUp (Lcom/facebook/react/views/view/ReactViewGroup;I)V
protected synthetic fun prepareToRecycleView (Lcom/facebook/react/uimanager/ThemedReactContext;Landroid/view/View;)Landroid/view/View;
protected fun prepareToRecycleView (Lcom/facebook/react/uimanager/ThemedReactContext;Lcom/facebook/react/views/view/ReactViewGroup;)Lcom/facebook/react/views/view/ReactViewGroup;
public synthetic fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public synthetic fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/view/ReactViewGroup;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Lcom/facebook/react/views/view/ReactViewGroup;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setAccessible (Lcom/facebook/react/views/view/ReactViewGroup;Z)V
public fun setBackfaceVisibility (Lcom/facebook/react/views/view/ReactViewGroup;Ljava/lang/String;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ <T extends View> int startSurface(
void updateRootLayoutSpecs(
int rootTag, int widthMeasureSpec, int heightMeasureSpec, int offsetX, int offsetY);

/**
* Dispatches the commandId received by parameter to the view associated with the reactTag. The
* command will be processed in the UIThread.
*
* <p>Receiving commands as ints is deprecated and will be removed in a future release.
*
* <p>Pre-Fabric, this is only called on the Native Module Thread.
*
* @param reactTag {@link int} that identifies the view that will receive this command
* @param commandId {@link int} command id
* @param commandArgs {@link ReadableArray} parameters associated with the command
*/
void dispatchCommand(int reactTag, int commandId, @Nullable ReadableArray commandArgs);

/**
* Dispatches the commandId received by parameter to the view associated with the reactTag. The
* command will be processed in the UIThread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,17 +1037,6 @@ public void onHostPause() {
@Override
public void onHostDestroy() {}

@Override
@Deprecated
@AnyThread
@ThreadConfined(ANY)
public void dispatchCommand(
final int reactTag, final int commandId, @Nullable final ReadableArray commandArgs) {
throw new UnsupportedOperationException(
"dispatchCommand called without surfaceId - Fabric dispatchCommand must be called through"
+ " Fabric JSI API");
}

@Override
@Deprecated
@AnyThread
Expand All @@ -1059,19 +1048,6 @@ public void dispatchCommand(
+ " Fabric JSI API");
}

@Deprecated
@AnyThread
@ThreadConfined(ANY)
public void dispatchCommand(
final int surfaceId,
final int reactTag,
final int commandId,
@Nullable final ReadableArray commandArgs) {
mMountItemDispatcher.addViewCommandMountItem(
MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs));
}

@AnyThread
@ThreadConfined(ANY)
public void dispatchCommand(
Expand Down Expand Up @@ -1304,14 +1280,8 @@ public void didDispatchMountItems() {
final int reactTag,
final String commandId,
@Nullable final ReadableArray commandArgs) {
try {
int commandIdInteger = Integer.parseInt(commandId);
return MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandIdInteger, commandArgs);
} catch (NumberFormatException e) {
return MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs);
}
return MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs);
}

private class DispatchUIFrameCallback extends GuardedFrameCallback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,6 @@ public boolean getViewExists(int reactTag) {
return getSurfaceManagerForView(reactTag) != null;
}

@Deprecated
public void receiveCommand(
int surfaceId, int reactTag, int commandId, @Nullable ReadableArray commandArgs) {
UiThreadUtil.assertOnUiThread();
getSurfaceManagerEnforced(surfaceId, "receiveCommand:int")
.receiveCommand(reactTag, commandId, commandArgs);
}

public void receiveCommand(
int surfaceId, int reactTag, @NonNull String commandId, @Nullable ReadableArray commandArgs) {
UiThreadUtil.assertOnUiThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,35 +853,6 @@ public void updateProps(int reactTag, ReadableMap props) {
.updateProperties(view, viewState.mCurrentProps);
}

@Deprecated
public void receiveCommand(int reactTag, int commandId, @Nullable ReadableArray commandArgs) {
if (isStopped()) {
return;
}

ViewState viewState = getNullableViewState(reactTag);

// It's not uncommon for JS to send events as/after a component is being removed from the
// view hierarchy. For example, TextInput may send a "blur" command in response to the view
// disappearing. Throw `ReactNoCrashSoftException` so they're logged but don't crash in dev
// for now.
if (viewState == null) {
throw new RetryableMountingLayerException(
"Unable to find viewState for tag: [" + reactTag + "] for commandId: " + commandId);
}

if (viewState.mViewManager == null) {
throw new RetryableMountingLayerException("Unable to find viewManager for tag " + reactTag);
}

if (viewState.mView == null) {
throw new RetryableMountingLayerException(
"Unable to find viewState view for tag " + reactTag);
}

viewState.mViewManager.receiveCommand(viewState.mView, commandId, commandArgs);
}

public void receiveCommand(
int reactTag, @NonNull String commandId, @Nullable ReadableArray commandArgs) {
if (isStopped()) {
Expand Down

This file was deleted.

Loading

0 comments on commit 9274f67

Please sign in to comment.