/*
 * Copyright (c) Facebook, Inc. and its 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.uimanager;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.events.EventDispatcher;
import java.util.List;

/** Provides UIImplementation to use in {@link UIManagerModule}. */
@Deprecated
public class UIImplementationProvider {

  public UIImplementation createUIImplementation(
      ReactApplicationContext reactContext,
      UIManagerModule.ViewManagerResolver viewManagerResolver,
      EventDispatcher eventDispatcher,
      int minTimeLeftInFrameForNonBatchedOperationMs) {
    return new UIImplementation(
        reactContext,
        viewManagerResolver,
        eventDispatcher,
        minTimeLeftInFrameForNonBatchedOperationMs);
  }

  public UIImplementation createUIImplementation(
      ReactApplicationContext reactContext,
      List<ViewManager> viewManagerList,
      EventDispatcher eventDispatcher,
      int minTimeLeftInFrameForNonBatchedOperationMs) {
    return new UIImplementation(
        reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
  }

  UIImplementation createUIImplementation(
      ReactApplicationContext reactContext,
      ViewManagerRegistry viewManagerRegistry,
      EventDispatcher eventDispatcher,
      int minTimeLeftInFrameForNonBatchedOperationMs) {
    return new UIImplementation(
        reactContext,
        viewManagerRegistry,
        eventDispatcher,
        minTimeLeftInFrameForNonBatchedOperationMs);
  }
}

@@ -339,16 +339,55 @@
 atcher;%0A
+import com.facebook.systrace.Systrace;%0A
 import j
@@ -767,32 +767,172 @@
 dOperationMs) %7B%0A
+    Systrace.beginSection(%0A        Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, %22UIImplementationProvider.createUIImplementation%5B1%5D%22);%0A    try %7B%0A  
     return new U
@@ -948,32 +948,34 @@
 tation(%0A        
+  
 reactContext,%0A  
@@ -964,32 +964,34 @@
   reactContext,%0A
+  
         viewMana
@@ -1003,32 +1003,34 @@
 solver,%0A        
+  
 eventDispatcher,
@@ -1022,32 +1022,34 @@
 ventDispatcher,%0A
+  
         minTimeL
@@ -1081,24 +1081,111 @@
 erationMs);%0A
+    %7D finally %7B%0A      Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);%0A    %7D%0A
   %7D%0A%0A  publi
@@ -1399,32 +1399,172 @@
 dOperationMs) %7B%0A
+    Systrace.beginSection(%0A        Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, %22UIImplementationProvider.createUIImplementation%5B2%5D%22);%0A    try %7B%0A  
     return new U
@@ -1572,32 +1572,34 @@
 Implementation(%0A
+  
         reactCon
@@ -1603,16 +1603,26 @@
 Context,
+%0A         
  viewMan
@@ -1630,16 +1630,26 @@
 gerList,
+%0A         
  eventDi
@@ -1657,16 +1657,26 @@
 patcher,
+%0A         
  minTime
@@ -1709,24 +1709,111 @@
 erationMs);%0A
+    %7D finally %7B%0A      Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);%0A    %7D%0A
   %7D%0A%0A  UIImp
@@ -2030,24 +2030,164 @@
 rationMs) %7B%0A
+    Systrace.beginSection(%0A        Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, %22UIImplementationProvider.createUIImplementation%5B3%5D%22);%0A    try %7B%0A  
     return n
@@ -2207,32 +2207,34 @@
 tation(%0A        
+  
 reactContext,%0A  
@@ -2223,32 +2223,34 @@
   reactContext,%0A
+  
         viewMana
@@ -2262,32 +2262,34 @@
 gistry,%0A        
+  
 eventDispatcher,
@@ -2281,32 +2281,34 @@
 ventDispatcher,%0A
+  
         minTimeL
@@ -2344,14 +2344,101 @@
 ionMs);%0A
+    %7D finally %7B%0A      Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);%0A    %7D%0A
   %7D%0A%7D%0A

Add Systrace sections to UIImplementationProvider