From 9274f67dd26fa0a2d548b4c0e6da69d9784f602d Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Fri, 10 May 2024 00:59:48 -0700 Subject: [PATCH] Remove deprecated dispatchCommand for INT 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 --- .../SampleNativeComponentViewManager.kt | 11 ---- .../ReactAndroid/api/ReactAndroid.api | 24 +-------- .../com/facebook/react/bridge/UIManager.java | 14 ----- .../react/fabric/FabricUIManager.java | 34 +------------ .../fabric/mounting/MountingManager.java | 8 --- .../mounting/SurfaceMountingManager.java | 29 ----------- .../mountitems/DispatchIntCommandMountItem.kt | 28 ---------- .../mounting/mountitems/MountItemFactory.kt | 10 ---- .../uimanager/NativeViewHierarchyManager.java | 24 --------- .../react/uimanager/UIImplementation.java | 12 ----- .../react/uimanager/UIManagerModule.java | 17 +------ .../react/uimanager/UIViewOperationQueue.java | 51 ------------------- .../facebook/react/uimanager/ViewManager.java | 14 ----- .../drawer/ReactDrawerLayoutManager.java | 13 ----- .../ReactHorizontalScrollViewManager.java | 6 --- .../scroll/ReactScrollViewCommandHelper.java | 31 ----------- .../views/scroll/ReactScrollViewManager.java | 6 --- .../textinput/ReactTextInputManager.java | 19 ------- .../react/views/view/ReactViewManager.java | 16 ------ .../react/fabric/FabricUIManagerTest.kt | 9 ---- .../facebook/testutils/fakes/FakeUIManager.kt | 4 -- 21 files changed, 5 insertions(+), 375 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchIntCommandMountItem.kt diff --git a/packages/react-native-test-library/android/src/main/java/com/facebook/react/osslibraryexample/SampleNativeComponentViewManager.kt b/packages/react-native-test-library/android/src/main/java/com/facebook/react/osslibraryexample/SampleNativeComponentViewManager.kt index 790b2eb01b9314..562fdcb9e7731e 100644 --- a/packages/react-native-test-library/android/src/main/java/com/facebook/react/osslibraryexample/SampleNativeComponentViewManager.kt +++ b/packages/react-native-test-library/android/src/main/java/com/facebook/react/osslibraryexample/SampleNativeComponentViewManager.kt @@ -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 = mapOf("changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index a3a849e0704358..350f13a56d9917 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -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 @@ -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 @@ -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; @@ -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 @@ -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; @@ -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 @@ -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 @@ -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; @@ -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 @@ -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 @@ -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 @@ -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 @@ -6843,7 +6828,6 @@ public class com/facebook/react/views/scroll/ReactScrollViewCommandHelper { public static final field COMMAND_SCROLL_TO_END I public fun ()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 } @@ -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 @@ -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 @@ -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 diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java index 9a9724b12cd9d4..e4fc2a98437645 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java @@ -48,20 +48,6 @@ 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. - * - *

Receiving commands as ints is deprecated and will be removed in a future release. - * - *

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. 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 a6fd6c05875d54..a706bfb05c22c0 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 @@ -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 @@ -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( @@ -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 { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 3aa8c930349271..d13e2825f0d4da 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -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(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index dc7179653fe8f4..32fff398b872e2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -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()) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchIntCommandMountItem.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchIntCommandMountItem.kt deleted file mode 100644 index 0e4a82c47daf48..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchIntCommandMountItem.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems - -import com.facebook.react.bridge.ReadableArray -import com.facebook.react.fabric.mounting.MountingManager - -internal class DispatchIntCommandMountItem( - private val surfaceId: Int, - private val reactTag: Int, - private val commandId: Int, - private val commandArgs: ReadableArray? -) : DispatchCommandMountItem() { - - override public fun getSurfaceId(): Int = surfaceId - - override public fun execute(mountingManager: MountingManager) { - @Suppress("DEPRECATION") - mountingManager.receiveCommand(surfaceId, reactTag, commandId, commandArgs) - } - - override public fun toString(): String = "DispatchIntCommandMountItem [$reactTag] $commandId" -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt index 15ab152d1ee6b4..5ac98e15822dec 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt @@ -14,16 +14,6 @@ import com.facebook.react.uimanager.StateWrapper /** Factory class that expose creation of [MountItem] */ public object MountItemFactory { - /** @return a [DispatchCommandMountItem] for commands identified by an int */ - @JvmStatic - public fun createDispatchCommandMountItem( - surfaceId: Int, - reactTag: Int, - commandId: Int, - commandArgs: ReadableArray? - ): DispatchCommandMountItem = - DispatchIntCommandMountItem(surfaceId, reactTag, commandId, commandArgs) - /** @return a [DispatchCommandMountItem] for commands identified by a String */ @JvmStatic public fun createDispatchCommandMountItem( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index d2ef20074c2a1f..83a5afafe03abe 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -811,30 +811,6 @@ void clearLayoutAnimation() { mLayoutAnimator.reset(); } - @Deprecated - public synchronized void dispatchCommand( - int reactTag, int commandId, @Nullable ReadableArray args) { - if (DEBUG_MODE) { - FLog.d( - TAG, - "dispatchCommand[%d]: %d %s", - reactTag, - commandId, - (args != null ? args.toString() : "")); - } - UiThreadUtil.assertOnUiThread(); - View view = mTagsToViews.get(reactTag); - if (view == null) { - throw new RetryableMountingLayerException( - "Trying to send command to a non-existing view with tag [" - + reactTag - + "] and command " - + commandId); - } - ViewManager viewManager = resolveViewManager(reactTag); - viewManager.receiveCommand(view, commandId, args); - } - public synchronized void dispatchCommand( int reactTag, String commandId, @Nullable ReadableArray args) { if (DEBUG_MODE) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index c8959a4c1fe1d2..03eab9ed8b81da 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -718,18 +718,6 @@ public void clearJSResponder() { mOperationsQueue.enqueueClearJSResponder(); } - @Deprecated - public void dispatchViewManagerCommand( - int reactTag, int commandId, @Nullable ReadableArray commandArgs) { - boolean viewExists = - checkOrAssertViewExists(reactTag, "dispatchViewManagerCommand: " + commandId); - if (!viewExists) { - return; - } - - mOperationsQueue.enqueueDispatchCommand(reactTag, commandId, commandArgs); - } - public void dispatchViewManagerCommand( int reactTag, String commandId, @Nullable ReadableArray commandArgs) { boolean viewExists = diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 09862f765d9de6..c9087ce66282ac 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -22,7 +22,6 @@ import com.facebook.debug.tags.ReactDebugOverlayTags; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; -import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.GuardedRunnable; import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.OnBatchCompleteListener; @@ -32,7 +31,6 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.ReadableType; import com.facebook.react.bridge.UIManager; import com.facebook.react.bridge.UIManagerListener; import com.facebook.react.bridge.UiThreadUtil; @@ -570,7 +568,7 @@ public void clearJSResponder() { @ReactMethod public void dispatchViewManagerCommand( - int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs) { + int reactTag, String commandId, @Nullable ReadableArray commandArgs) { // Fabric dispatchCommands should go through the JSI API - this will crash in Fabric. @Nullable UIManager uiManager = @@ -580,18 +578,7 @@ public void dispatchViewManagerCommand( return; } - if (commandId.getType() == ReadableType.Number) { - uiManager.dispatchCommand(reactTag, commandId.asInt(), commandArgs); - } else if (commandId.getType() == ReadableType.String) { - uiManager.dispatchCommand(reactTag, commandId.asString(), commandArgs); - } - } - - /** Deprecated, use {@link #dispatchCommand(int, String, ReadableArray)} instead. */ - @Deprecated - @Override - public void dispatchCommand(int reactTag, int commandId, @Nullable ReadableArray commandArgs) { - mUIImplementation.dispatchViewManagerCommand(reactTag, commandId, commandArgs); + uiManager.dispatchCommand(reactTag, commandId, commandArgs); } @Override diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index ad07257fb1bfdd..030384744c851f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -259,49 +259,6 @@ private interface DispatchCommandViewOperation { int getRetries(); } - @Deprecated - private final class DispatchCommandOperation extends ViewOperation - implements DispatchCommandViewOperation { - - private final int mCommand; - private final @Nullable ReadableArray mArgs; - - private int numRetries = 0; - - public DispatchCommandOperation(int tag, int command, @Nullable ReadableArray args) { - super(tag); - mCommand = command; - mArgs = args; - } - - @Override - public void execute() { - try { - mNativeViewHierarchyManager.dispatchCommand(mTag, mCommand, mArgs); - } catch (Throwable e) { - ReactSoftExceptionLogger.logSoftException( - TAG, new RuntimeException("Error dispatching View Command", e)); - } - } - - @Override - public void executeWithExceptions() { - mNativeViewHierarchyManager.dispatchCommand(mTag, mCommand, mArgs); - } - - @Override - @UiThread - public void incrementRetries() { - numRetries++; - } - - @Override - @UiThread - public int getRetries() { - return numRetries; - } - } - private final class DispatchStringCommandOperation extends ViewOperation implements DispatchCommandViewOperation { @@ -658,14 +615,6 @@ public void enqueueClearJSResponder() { mOperations.add(new ChangeJSResponderOperation(0, 0, true /*clearResponder*/, false)); } - @Deprecated - public void enqueueDispatchCommand( - int reactTag, int commandId, @Nullable ReadableArray commandArgs) { - final DispatchCommandOperation command = - new DispatchCommandOperation(reactTag, commandId, commandArgs); - mViewCommandOperations.add(command); - } - public void enqueueDispatchCommand( int reactTag, String commandId, @Nullable ReadableArray commandArgs) { final DispatchStringCommandOperation command = diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index aedc311fa381d5..259b465518d2fa 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -270,20 +270,6 @@ protected void onAfterUpdateTransaction(@NonNull T view) {} */ public abstract void updateExtraData(@NonNull T root, Object extraData); - /** - * Subclasses may use this method to receive events/commands directly from JS through the {@link - * UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates - * for a {@link ScrollView} instance. - * - *

This method is deprecated use {@link #receiveCommand(View, String, ReadableArray)} instead. - * - * @param root View instance that should receive the command - * @param commandId code of the command - * @param args optional arguments for the command - */ - @Deprecated - public void receiveCommand(@NonNull T root, int commandId, @Nullable ReadableArray args) {} - /** * Subclasses may use this method to receive events/commands directly from JS through the {@link * UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.java index 097f98882131c4..947f99ac992b79 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.java @@ -190,19 +190,6 @@ public boolean needsCustomLayoutForChildren() { return MapBuilder.of("openDrawer", OPEN_DRAWER, "closeDrawer", CLOSE_DRAWER); } - @Override - public void receiveCommand( - @NonNull ReactDrawerLayout root, int commandId, @Nullable ReadableArray args) { - switch (commandId) { - case OPEN_DRAWER: - root.openDrawer(); - break; - case CLOSE_DRAWER: - root.closeDrawer(); - break; - } - } - @Override public void receiveCommand( @NonNull ReactDrawerLayout root, String commandId, @Nullable ReadableArray args) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index 652039a27a26da..906e1629451880 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -184,12 +184,6 @@ public void setNestedScrollEnabled(ReactHorizontalScrollView view, boolean value ViewCompat.setNestedScrollingEnabled(view, value); } - @Override - public void receiveCommand( - ReactHorizontalScrollView scrollView, int commandId, @Nullable ReadableArray args) { - ReactScrollViewCommandHelper.receiveCommand(this, scrollView, commandId, args); - } - @Override public void receiveCommand( ReactHorizontalScrollView scrollView, String commandId, @Nullable ReadableArray args) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.java index 8b6641b25ed837..843bc24eb0e9e6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.java @@ -63,37 +63,6 @@ public static Map getCommandsMap() { COMMAND_FLASH_SCROLL_INDICATORS); } - public static void receiveCommand( - ScrollCommandHandler viewManager, - T scrollView, - int commandType, - @Nullable ReadableArray args) { - Assertions.assertNotNull(viewManager); - Assertions.assertNotNull(scrollView); - Assertions.assertNotNull(args); - switch (commandType) { - case COMMAND_SCROLL_TO: - { - scrollTo(viewManager, scrollView, args); - return; - } - case COMMAND_SCROLL_TO_END: - { - scrollToEnd(viewManager, scrollView, args); - return; - } - case COMMAND_FLASH_SCROLL_INDICATORS: - viewManager.flashScrollIndicators(scrollView); - return; - - default: - throw new IllegalArgumentException( - String.format( - "Unsupported command %d received by %s.", - commandType, viewManager.getClass().getSimpleName())); - } - } - public static void receiveCommand( ScrollCommandHandler viewManager, T scrollView, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index 0aec1b1a33899b..c4e4f3ff7f2be3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -198,12 +198,6 @@ public void setNestedScrollEnabled(ReactScrollView view, boolean value) { return ReactScrollViewCommandHelper.getCommandsMap(); } - @Override - public void receiveCommand( - ReactScrollView scrollView, int commandId, @Nullable ReadableArray args) { - ReactScrollViewCommandHelper.receiveCommand(this, scrollView, commandId, args); - } - @Override public void receiveCommand( ReactScrollView scrollView, String commandId, @Nullable ReadableArray args) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 39691c2f9f2c56..871164c27bf481 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -275,25 +275,6 @@ public Map getExportedCustomDirectEventTypeConstants() { return MapBuilder.of("focusTextInput", FOCUS_TEXT_INPUT, "blurTextInput", BLUR_TEXT_INPUT); } - @Override - public void receiveCommand( - ReactEditText reactEditText, int commandId, @Nullable ReadableArray args) { - switch (commandId) { - case FOCUS_TEXT_INPUT: - this.receiveCommand(reactEditText, "focus", args); - break; - case BLUR_TEXT_INPUT: - this.receiveCommand(reactEditText, "blur", args); - break; - case SET_MOST_RECENT_EVENT_COUNT: - // TODO: delete, this is no longer used from JS - break; - case SET_TEXT_AND_SELECTION: - this.receiveCommand(reactEditText, "setTextAndSelection", args); - break; - } - } - @Override public void receiveCommand( ReactEditText reactEditText, String commandId, @Nullable ReadableArray args) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java index df4b9c85ce4f9c..790504f9ccebe8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java @@ -333,22 +333,6 @@ public Map getCommandsMap() { return MapBuilder.of(HOTSPOT_UPDATE_KEY, CMD_HOTSPOT_UPDATE, "setPressed", CMD_SET_PRESSED); } - @Override - public void receiveCommand(ReactViewGroup root, int commandId, @Nullable ReadableArray args) { - switch (commandId) { - case CMD_HOTSPOT_UPDATE: - { - handleHotspotUpdate(root, args); - break; - } - case CMD_SET_PRESSED: - { - handleSetPressed(root, args); - break; - } - } - } - @Override public void receiveCommand(ReactViewGroup root, String commandId, @Nullable ReadableArray args) { switch (commandId) { diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricUIManagerTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricUIManagerTest.kt index c80567f4de4503..64030c9cf429cb 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricUIManagerTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricUIManagerTest.kt @@ -46,13 +46,4 @@ class FabricUIManagerTest { val className = command::class.java.name.substringAfterLast(".") assertEquals("DispatchStringCommandMountItem", className) } - - @Test - fun createDispatchCommandMountItemForInterop_withValidInt_returnsIntEvent() { - val command = underTest.createDispatchCommandMountItemForInterop(11, 1, "42", null) - - // DispatchIntCommandMountItem is package private so we can `as` check it. - val className = command::class.java.name.substringAfterLast(".") - assertEquals("DispatchIntCommandMountItem", className) - } } 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 520119603b66bf..a24e2b20f75233 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 @@ -60,10 +60,6 @@ class FakeUIManager : UIManager, UIBlockViewResolver { TODO("Not yet implemented") } - override fun dispatchCommand(reactTag: Int, commandId: Int, commandArgs: ReadableArray?) { - TODO("Not yet implemented") - } - override fun dispatchCommand(reactTag: Int, commandId: String?, commandArgs: ReadableArray?) { TODO("Not yet implemented") }