Граф коммитов

4805 Коммитов

Автор SHA1 Сообщение Дата
David Vacca a56c15894a Enable Fabric in logbox
Summary:
This diff enables  Fabric in logbox in the facebook app

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28031255

fbshipit-source-id: 8abc301651ad09e4e48c88961bc7f3b91e6c4ae3
2021-04-27 19:45:08 -07:00
David Vacca 3d0cf8dcf8 Fix IllegalArgumentException when creating layout with negative width
Summary:
This diff fixes an IllegalArgumentException that's thrown when creating layout with negative width.

This is not a new bug, but it started firing recently (probably caused by a change in text being measured)

stacktrace:
```
stack_trace:	java.lang.IllegalArgumentException: Layout: -2 < 0
	at android.text.Layout.<init>(Layout.java:265)
	at android.text.Layout.<init>(Layout.java:241)
	at android.text.BoringLayout.<init>(BoringLayout.java:179)
	at android.text.BoringLayout.make(BoringLayout.java:61)
	at com.facebook.react.views.text.TextLayoutManager.createLayout(TextLayoutManager.java:290)
	at com.facebook.react.views.text.TextLayoutManager.measureText(TextLayoutManager.java:384) [inlined]
	at com.facebook.react.views.text.ReactTextViewManager.measure(ReactTextViewManager.java:172) [inlined]
	at com.facebook.react.fabric.mounting.MountingManager.measure(MountingManager.java:349) [inlined]
	at com.facebook.react.fabric.FabricUIManager.measure(FabricUIManager.java:461)
	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

```

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28015820

fbshipit-source-id: 129cd2a4c492d95d57fcdf3883b967a0b5df639a
2021-04-27 19:45:08 -07:00
David Vacca 3178e80c88 Cleanup unused variables
Summary:
EZ cleanup of unused variables in TextLayoutManager
changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28015819

fbshipit-source-id: 8e380926ebff9256e89e6cd654fa96eeb938d797
2021-04-27 19:45:08 -07:00
Andrei Shikov 0aa7e5b5d4 Back out "Assign batch number to only batched animated instructions"
Summary:
This change broke some animations on non-Fabric surfaces due to inconsistent batching of animation operations.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D28013968

fbshipit-source-id: 2f65c799dbe00168f1e756ef0af60206df5a8fcc
2021-04-27 04:00:16 -07:00
Andrei Shikov ef0db95300 Back out "Adjust animation batch numbers to be consistent when controlled by native"
Summary:
This change caused crashes in animations on some surfaces.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D28013969

fbshipit-source-id: 95845c69d6e67d59582ea14ad08cbf42fd3e2f8f
2021-04-27 04:00:16 -07:00
Nadiia D 46ffe84453 Make RootTag an opaque type
Summary:
Changelog:
[General][Changed] Make the RootTag an opaque type

Reviewed By: yungsters

Differential Revision: D27992320

fbshipit-source-id: 2901f0e59f573106295b986fe04db227134235da
2021-04-26 22:57:55 -07:00
Samuel Susla 9cd98fa3ee Prevent redundant dispatches onto RuntimeExecutor queue in AsynchronousEventBeat::induce
Summary:
Changelog: [internal]

Prevent redundant calls to RuntimeExecutor by making sure no two calls to the executor are scheduled at the same time.

Reviewed By: mdvacca

Differential Revision: D27989412

fbshipit-source-id: 8f9b1591f7c9c2265fd4b05bf3dc5505ffc2568b
2021-04-25 16:15:25 -07:00
Ramanpreet Nara d48c2be46f Wire up RuntimeExecutorFlushing to MobileConfig
Summary:
With D27975839, RuntimeExecutor will be able to start flushing the queued up NativeModule calls in every call from C++ -> JavaScript. We're going to test this feature to measure its impact. In this diff, I wire up the the MobileConfig to ReactFeatureFlags.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D27978112

fbshipit-source-id: 47e1e74398c62755bb0fdc6b54b7fd3aa47eb877
2021-04-23 18:16:03 -07:00
Ramanpreet Nara c0ec82e61e Add flushing to RuntimeExecutor
Summary:
## Motivation
With the bridge, every call into JS flushes the queue of NativeModule calls. Fabric bypasses this mechanism, because it uses a RuntimeExecutor that schedules work directly on the JavaScript thread. This diff makes Fabric's RuntimeExecutor also flush the queue of NativeModule calls.

This likely won't fix anything in Fabric, because we don't execute any async NativeModule calls on Fb4a. However, this is necessary for the drainMicrotask work we're doing in D27729702 (7310847758), because (1) we need to drain the Hermes microtask queue on every call from C++ -> JavaScript (2) we drain the microtask queue [inside JSIExecutor::flush()](de477a0df6/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp (L427),L445).

Changelog: [Android][Fixed] - Flush JSIExecutor in Fabric's RuntimeExecutor

Reviewed By: JoshuaGross

Differential Revision: D27975839

fbshipit-source-id: 27f031fb36593253da116a033e30998475eb1473
2021-04-23 18:16:03 -07:00
Ramanpreet Nara 090196f330 ReactContext: Fail fast when NativeModules thread is null
Summary:
By the time that we call [ReactContext.assertOnNativeModulesQueueThread()](https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java?commit=747a25280435d276fb975ccfe36fd5e60254c4e4&lines=355%2C359), ReactContext.mNativeModulesMessageQueueThread must be non-null. This implies that two things must have happened:
1. We initialized the ReactContext
2. After initialization, ReactContext.mNativeModulesMessageQueueThread must be non-null.

According to T85807990, ReactContext.mNativeModulesMessageQueueThread is null. Since ReactContext doesn't ever write to ReactContext.mNativeModulesMessageQueueThread aside from during initialization, it must mean that we either didn't initialize properly, or we initialized, but set the NativeModules thread to null. This diff throws IllegalStateExceptions inside ReactContext initialization, which should help narrow down the crash in T85807990.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D27729355

fbshipit-source-id: e39030b7db8862ae76fb644efaafb382a79b8ad0
2021-04-23 15:12:46 -07:00
Andrei Shikov bda032af6e Adjust animation batch numbers to be consistent when controlled by native
Summary:
D27682424 (ea1ff374de) updated how animated node batches are executed in Fabric. On Paper, these batches were controlled by native module in some places (batch was executed ~every 2 frames), but some animations were switching animation batching control to JS globally there as well.

This change updates two things:
- If batching is controlled by native, it makes sure batches are calculated correctly.
- At the same time, this change switches control for animation node batching to JS, aligning it with Fabric.

Changelog: [Internal]

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D27939659

fbshipit-source-id: d6251bce2a303a4a007dc10297edc0175cc4b348
2021-04-23 15:07:35 -07:00
Peter Laraia 42b6e6682c Fix crash - check if backgroundColor is null before trying to fetch it in ViewProps isLayoutOnly
Summary:
Noticed while working in MobileHome with android device, when interacting with the Tasks change progress/priority components (MobileHomeTasksDetailsSelectorToken), which provides `borderRadius` style and `backgroundColor: ifSelected ? value : null`, and when `backgroundColor` is `null`, the line changed in this diff crashes (throwing the `NoSuchKeyException` at `ReadableNativeMap:110` [because of isNull check on `ReadableNativeMap:107`])

Changelog:
[Android][Fixed] - Fixed crash when using style borderRadius: any with backgroundColor: null

Reviewed By: JoshuaGross

Differential Revision: D27932828

fbshipit-source-id: 801b04c856ee9dc5a36bbf3e6e3d81de9b1e81a1
2021-04-22 10:41:38 -07:00
David Vacca b67dc01d1d Replace int -> int32_t
Summary:
This diff replaces all usages of int by int32_t. This is to ensure we always use a fixed size for int that matches what's expected on Java.

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27915608

fbshipit-source-id: 634c45796dda1d4434c3ad6ff3e199931c22940b
2021-04-22 09:50:23 -07:00
Andrei Shikov 6fda118116 Show surfaceId when logging IntBufferBatchMountItem
Summary:
Adds surface id for string logs of the IntBufferBatchMountItem to help debug updates with multiple surfaces.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D27884232

fbshipit-source-id: c5ec65585830f7aa5b902603bcd1e91b61cfe4c1
2021-04-21 10:32:18 -07:00
David Vacca b614afc613 Refactor MapBufferBuilder to use int to store size of Mapbuffer data
Summary:
Refactor MapBufferBuilder to use int to store size of Mapbuffer data

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27904646

fbshipit-source-id: 6b8b96fdd30184b6d35c1d612743eae653854d6d
2021-04-21 10:27:57 -07:00
David Vacca 668d71aa0b Refactor dataSize to use int instead of short
Summary:
DynamicData can contain a big amount of data, refactoring type to use int instead of short

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27904643

fbshipit-source-id: 157064b280e27a9c7c4a4f55af310392b178feda
2021-04-21 10:27:57 -07:00
David Vacca e92be1c14b Add extra asserts and early deallocation in ReadableMapBuffer::importByteBufferAllocateDirect
Summary:
Add extra asserts and early deallocation in ReadableMapBuffer::importByteBufferAllocateDirect

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27904645

fbshipit-source-id: 075a007c4ec5e005b839add054bd68c233b65801
2021-04-21 10:27:57 -07:00
David Vacca 64844d900a Refactor names of ReadableMapBuffer class variables
Summary:
Refactor names of ReadableMapBuffer class variables

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27867056

fbshipit-source-id: de96429cbd1142e14fa74f7f953d560ba5918954
2021-04-21 10:27:57 -07:00
David Vacca 69a48ec9d4 Fix importByteBufferAllocateDirect method
Summary:
This diff fixes the importByteBufferAllocateDirect method.
This was tested enabling importByteBufferAllocateDirect in ReadableMapBuffer.java

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27867055

fbshipit-source-id: 9ef5e93ff6c7903782598dde1c499daa82cd467b
2021-04-20 12:13:48 -07:00
David Vacca 19d881d838 integrate asserts in ReadableMapBuffer
Summary:
This diff integrates asserts in ReadableMapBuffer

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27864305

fbshipit-source-id: 0e7802a33cbf5ccfb4b845fffd14f8517bed70ec
2021-04-20 12:13:48 -07:00
Lulu Wu 49af5e7385 Create and show DatePickerDialogFragment in UI thread
Summary:
Fix 'An Unexpected error occurred' in Messenger Kids caused by DatePickerDialog.

Changelog:
[Android][Fixed] - Create and show DatePickerDialogFragment in UI thread

Differential Revision: D27882121

fbshipit-source-id: 2490a8178e5986222105bfbc16e7c0de471baa02
2021-04-20 09:27:02 -07:00
CodemodService FBSourceBuckFormatLinterBot 73b9f78e33 Daily `arc lint --take BUCKFORMAT`
Reviewed By: zertosh

Differential Revision: D27761011

fbshipit-source-id: 6231e04819b758d0daa1c78b412742be9b23cf3f
2021-04-14 04:05:56 -07:00
Kudo Chien e57de5f32f Fix CI "Build Tests: Android Instrumentation Tests" errors (#31352)
Summary:
To fix [the CI error](https://app.circleci.com/pipelines/github/facebook/react-native/8708/workflows/d584348e-941f-4653-96c2-46375894dfaa/jobs/196410)
  There are two errors:
  `error: undefined reference to '__android_log_write'` which solved by adding `-llog` linker flag.

  `ld: error: cannot find -lc++` which workaround by static linking.
  For the root cause, I am thinking that is after [NDK r19](https://developer.android.com/ndk/guides/other_build_systems),
  the `-target` should specificy api level.
  However, buck does not add this accordingly, e.g. `-target armv7-none-linux-androideabi`
  Given wrong target will make NDK to have `cannot find -lc++` error.
  The workaround is to use static linking.
  Since it was an oss_cxx_library, the change should not have impact to Facebook internal testing.

## Changelog

[Internal] [Fixed] - Fix CI "Build Tests: Android Instrumentation Tests" errors

Pull Request resolved: https://github.com/facebook/react-native/pull/31352

Test Plan: Make CI green

Reviewed By: JoshuaGross

Differential Revision: D27757838

Pulled By: fkgozali

fbshipit-source-id: 8f9c80a89c6240938218abacb8a82e3e2e71adbc
2021-04-13 21:25:31 -07:00
Mike 1b0683533a Android: Fix switch ripple color (#30685)
Summary:
fix https://github.com/facebook/react-native/issues/22370

Use `RippleDrawable` to change ripple color.
According to the [document](https://developer.android.com/reference/android/graphics/drawable/RippleDrawable?hl=en), `RippleDrawable` is added in API 21, so warped the code in the `if` statement for version checking.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix wrong ripple color on Switch component

Pull Request resolved: https://github.com/facebook/react-native/pull/30685

Test Plan:
1. Create an empty app with react-native 0.63.4, copy&paste the App.js from issue https://github.com/facebook/react-native/issues/22370
2. Apply the code for fixing to `node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java`
3. Configure the project to let it Build from ReactAndroid
4. Check if ripple color has changed correctly
5. Use different color on each state and check if it is working

Test device: Android emulator, Pixel 4, API 30

## Screenshot

### Before
Ripple is always in default color

https://user-images.githubusercontent.com/48589760/103573532-5b4cec80-4f09-11eb-96d7-f75efa6779d9.mov

### After
Ripple color has changed with thumb color

https://user-images.githubusercontent.com/48589760/103573216-d95cc380-4f08-11eb-98fb-494e28c12a9f.mov

Check different color on each state

https://user-images.githubusercontent.com/48589760/103573227-de217780-4f08-11eb-8992-ede5d1dd89c1.mov

Reviewed By: mdvacca

Differential Revision: D27636802

Pulled By: lunaleaps

fbshipit-source-id: fa23cc8b51c642e5e5d9c73371c8ccef3741fd14
2021-04-12 13:57:27 -07:00
Andrei Shikov 214aaf2703 Move surface handler registration to Binding.cpp
Summary:
Changelog: [Internal]

Inverts registration of a SurfaceHandler with the scheduler: instead of passing a scheduler to the SurfaceHandlerBinding, we can now query the SurfaceHandler and register it in place.

Reviewed By: JoshuaGross

Differential Revision: D27624541

fbshipit-source-id: db5d7f1375fad72a805309a3fcd5a33080e4a4a7
2021-04-12 13:17:52 -07:00
Andrei Shikov 5cba7c0ce7 Add a way to prerender the surface
Summary:
Changelog: [Internal]

Links APIs in Fabric and Venice to create a surface without a view and mount it separately when surface is started the usual way.

Reviewed By: mdvacca

Differential Revision: D27339365

fbshipit-source-id: d1b674ce856957465eb6f3a5d7f26eb0ab625353
2021-04-12 13:17:52 -07:00
Andrei Shikov ea1ff374de Assign batch number to only batched animated instructions
Summary:
Changelog: [Internal]

`NativeAnimatedModule` on Android currently enforces all animation operations to be processed in batches to ensure that all associated operations are processed at the same time.
Some operations, however, can be triggered outside of the batching calls (e.g. when using `Animated` for tracking touches `PanResponder`), and they are not processed until the next batch.

This change tracks if we are currently processing a batch and doesn't assign a batch number if an operation was triggered outside of `startOperationBatch`/`finishOperationBatch` pair.

Reviewed By: mdvacca

Differential Revision: D27682424

fbshipit-source-id: 2ea8737c353c81557fa586b15aa5760db3e8813f
2021-04-12 09:18:47 -07:00
David Vacca 2793bba278 Move DisplayMode out of SurfaceHandler
Summary:
This diff moves DisplayMode out of SurfaceHandler, this is necessary in order to use it from react/uimanager package

changelog: [internal] internal

Reviewed By: ShikaSD

Differential Revision: D27669846

fbshipit-source-id: 274869d8f2907b1b159f51240440acece09a746f
2021-04-12 00:05:43 -07:00
David Vacca 84c70b2a7f Introduce setDisplayMode method in SurfaceHandler
Summary:
This diff introduces the new setDisplayMode java method in SurfaceHandler classes

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27607585

fbshipit-source-id: aac0def4136cf70e99ef7b20eba85e3e975b72d9
2021-04-12 00:05:43 -07:00
Araz Abishov 8207e97f91 Android: upgrading to OkHttp from v3 to v4 (#31084)
Summary:
Extends https://github.com/facebook/react-native/pull/30694 to fix tests.

OkHttp v4 was released almost a year ago. Even though v3 is still receiving security and bug fixes, most of the new improvements and features are landing in v4. This PR bumps OkHttp from v3 to v4 and addresses backward-incompatible changes.

Side effects of this upgrade:
 - OkHttp v4 depends on Kotlin's standard library, so react-native will have a transitive dependency on it.
 - The dex method count of test apk has exceeded the maximum, so multidexing had to be enabled for android tests.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Changed] - Bumping OkHttp from v3 to v4.

Pull Request resolved: https://github.com/facebook/react-native/pull/31084

Test Plan: Automated (relying on the test suite) and manual testing.

Reviewed By: fkgozali

Differential Revision: D27597430

Pulled By: ShikaSD

fbshipit-source-id: 967379b41c2bcd7cfd4083f65059f5da467b8a91
2021-04-08 10:45:53 -07:00
Ramanpreet Nara 5f0bf8b2e9 Refactor: Remove AsyncDevSupportManager.loadJSBundleFromServer
Summary:
## Rationale
- AsyncDevSupportManager.loadSplitBundleFromServer() is an override of DevSupportManager.loadSplitBundleFromServer(), which is used by the bridge. However, AsyncDevSupportManager.loadJSBundleFromServer() has no bridge analogue. This is confusing: Are the methods in AsyncDevSupportManager Venice overrides for bridge related methods? It's easy to think yes, but the answer is no.
- AsyncDevSupportManager.loadJSBundleFromServer() is an additional layer of indirection that provides very little value: all it does it create the JSBundleLoader, and call onReactContextCreated. However, it does so in 11 lines of very confusing code.

A discussion we don't have to have now: Inheritance hierarchies are very difficult to understand and de-tangle. So, instead of using inheritance to make DevSupportManager work with Venice (via AsyncDevSupportManager), should we just refactor DevSupportManager so that it can be customized to work with Venice?

Changelog: [Internal]

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D27577591

fbshipit-source-id: b64dcd65e9a7c85b89443d860d441a0635547916
2021-04-07 19:37:59 -07:00
grgr-dkrk d29a7e7a89 add getRecommendedTimeoutMillis to AccessibilityInfo (#31063)
Summary:
resolve https://github.com/facebook/react-native/issues/30866

This PR is for using `getRecommendedTimeoutMillis` with React Native, which is available on Android 10 and above.
This allows the Android "Time to take action (Accessibility timeout)" setting to be reflected in the app.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Added] - Add `getRecommendedTimeoutMillis` to AccessibilityInfo

Pull Request resolved: https://github.com/facebook/react-native/pull/31063

Test Plan:
I couldn't find any tests at the code level, so I tested them on my Android device.

 ---

### Android 10 (Pixel4a)
#### Settings
<img src="https://user-images.githubusercontent.com/40130327/109322854-210f2400-7896-11eb-9f3b-b88afa27abfb.png" width="400" alt="Set the timeout to 1 minute on the settings screen." />

#### App
<img src="https://user-images.githubusercontent.com/40130327/109322895-32583080-7896-11eb-9c48-c4aa9afb94d9.png" width="400" alt="The baseline timeout is 3000 ms, but the result of `getRecommendedTimeoutMillis` returns 60000 ms." />

 ---

### Android 7, iOS(Simulator)
Return the original timeout.
<img src="https://user-images.githubusercontent.com/40130327/109323217-911daa00-7896-11eb-9eba-659bc623f2ac.png" width="400" alt="Return the original timeout on Android 7." />

<img src="https://user-images.githubusercontent.com/40130327/109323357-b7dbe080-7896-11eb-89e9-305eea8b801b.png" width="400" alt="Return the original timeout on iOS simulator." />

Reviewed By: lunaleaps

Differential Revision: D27475370

Pulled By: nadiia

fbshipit-source-id: 4cdd9eb5ddb20d89c1d870e640b4b7e3c3c1b14d
2021-04-06 13:48:24 -07:00
Andrei Shikov d97350dcbc Queue mount items executed before root view is attached
Summary:
Changelog: [Internal]

After D27016919, some mounting instructions can be executed before the view is attached, which is invalid. This change adds additional queue for such items, which can be later dispatched after view is ready.

The new queue is expected to be empty for usual rendering and used in prerendering flows only. In case of prerendering, it should only hold intermediate items between early start of `SurfaceHandler` and view attach.

Reviewed By: mdvacca

Differential Revision: D27291706

fbshipit-source-id: f383c1d0d7050f271993553b51bf2e387efe1e9e
2021-04-06 11:19:57 -07:00
Andrei Shikov 2c0a0a7c25 Allow starting surface without a view in Fabric
Summary:
Changelog: [Internal]

Adjusts SurfaceMountingManager to allow starting surface without a view and attaching the view while surface is active.
This change is only meant to work with ReactSurface to allow creating `SurfaceHandler` without mounting views.

Reviewed By: mdvacca

Differential Revision: D27016919

fbshipit-source-id: 995383bc4f1bd298953516007743ffae0edf17c2
2021-04-06 11:19:57 -07:00
Tim Yung 73bc96ecf9 RN: Announce "unselected" Accessibility State (Android)
Summary:
Changes React Native so that when `accessibilityState` is used to change a view from `selected: true` to `selected: false`, the change in state is announced.

This is how `checked` works; it is unclear why Android does not do this for `selected`, too.

Changelog:
[Android][Added] - TalkBack now announces "unselected" when changing `accessibilityState.selected` to false.

Reviewed By: blavalla

Differential Revision: D27449293

fbshipit-source-id: a6d77b55d63655973ad93c4d5e3743742501f378
2021-04-05 17:45:29 -07:00
fabriziobertoglio1987 7ee2acc6c8 Selected State does not annonce when TextInput Component selected (#31144)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/30955 and is a follow up to pr https://github.com/facebook/react-native/pull/24608 which added the basic Accessibility functionalities to React Native.

TextInput should announce "selected" to the user when screenreader focused.
The focus is moved to the TextInput by navigating with the screenreader to the TextInput.

This PR adds call to View#setSelected in BaseViewManager https://developer.android.com/reference/android/view/View#setSelected(boolean)
The View#setSelected method definition https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/view/View.java
```java
/**
 * Changes the selection state of this view. A view can be selected or not.
 * Note that selection is not the same as focus. Views are typically
 * selected in the context of an AdapterView like ListView or GridView;
 * the selected view is the view that is highlighted.
 *
 * param selected true if the view must be selected, false otherwise
 */
public void setSelected(boolean selected) {
  if (((mPrivateFlags & PFLAG_SELECTED) != 0) != selected) {
    // ... hidden logic
    if (selected) {
      sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
    } // ... hidden logic
  }
}
```

VoiceOver and TalkBack was tested with video samples included below.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix Selected State does not announce when TextInput Component selected on Android

Pull Request resolved: https://github.com/facebook/react-native/pull/31144

Test Plan:
**<details><summary>CLICK TO OPEN TESTS RESULTS</summary>**
<p>

**ENABLE THE AUDIO** to hear the TalkBack announcing **SELECTED** when the user taps on the TextInput

```javascript
        <TextInput
          accessibilityLabel="element 20"
          accessibilityState={{
            selected: true,
          }} />
```

| selected is true |
|:-------------------------:|
| <video src="https://user-images.githubusercontent.com/24992535/111652826-afc4f000-8807-11eb-9c79-8c51d7bf455b.mp4" width="700" height="" /> |

```javascript
        <TextInput
          accessibilityLabel="element 20"
          accessibilityState={{
            selected: false,
          }} />
```

| selected is false |
|:-------------------------:|
| <video src="https://user-images.githubusercontent.com/24992535/111652919-c10dfc80-8807-11eb-8244-83db6c327bcd.mp4" width="700" height="" /> |

The functionality does not present issues on iOS

| iOS testing |
|:-------------------------:|
| <video src="https://user-images.githubusercontent.com/24992535/111647656-f401c180-8802-11eb-9fa9-a4c211cf1665.mp4" width="400" height="" /> |

</p>
</details>

</p>
</details>

Reviewed By: blavalla

Differential Revision: D27306166

Pulled By: kacieb

fbshipit-source-id: 1b3cb37b2d0875cf53f6f1bff4bf095a877b2f0e
2021-04-05 11:51:12 -07:00
Lulu Wu 1b50722a7e Add back hasActiveCatalystInstance() and mark it as Deprecated
Summary:
Previously I renamed hasActiveCatalystInstance() API in D27335055 (dfa8eb0558), however this API is still used in an OSS class.

In this diff hasActiveCatalystInstance() is added back and marked as Deprecated to avoid breakages and leave the migration choice to OSS users.

Changelog:
[Android][Changed] Mark hasActiveCatalystInstance() as Deprecated

Reviewed By: yungsters

Differential Revision: D27538449

fbshipit-source-id: 30f2f890580ad7f8b41908e18013234b5bac72e9
2021-04-02 12:32:02 -07:00
Joshua Gross 3d1afbbda3 destroy callbacks even if they aren't called, when java object is destroyed
Summary:
JSI callbacks are only destroyed if the callback is called. If the callback is never called, we're potentially leaking a lot of callbacks.

To mitigate this, we add a wrapper object that is owned by the std::function. Whenever the std::function is destroyed, the wrapper is destroyed and it deallocates the callback as well.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D27436402

fbshipit-source-id: d153640d5d7988c7fadaf2cb332ec00dadd0689a
2021-04-01 16:28:26 -07:00
Lulu Wu 5a793cee77 Remove previous fix in D26581756
Summary:
D26581756 (86321a35c0) was hacked for fixing T85822390, which was later properly fixed in D27369721, so I removed it in this diff.

Changelog:
[Android][Fixed] -  Remove previous fix for "Fix text in ReactTextView sometimes being vertically displayed"

Reviewed By: mdvacca

Differential Revision: D27501405

fbshipit-source-id: 81417069d355936721868ce659b3fe8ce916302e
2021-04-01 09:37:17 -07:00
Samuel Susla 9ef995a14a Enable C++ 17 in React Native
Summary:
Changelog: [Internal] enable support for C++ 17.

C++ 17 in React Native targets.

Short and comprehensive list of C++ features:
https://github.com/AnthonyCalandra/modern-cpp-features#c17-language-features

Reviewed By: JoshuaGross

Differential Revision: D27431145

fbshipit-source-id: e8da6fe9d70e9b7343a8caec21cdbeb043478575
2021-04-01 04:50:59 -07:00
Lulu Wu 10830f4db9 Remove redundant isBridgeless() checking
Summary:
3rd step of following 3 steps:

1, Rename hasActiveCatalystInstance() to hasActiveReactInstance() so it won't sounds like CatalystInstance-only. D27335055 (dfa8eb0558)
2, Implement hasActiveReactInstance() for Venice. D27343867
3, Remove previous mitigation. D27343952

Changelog:
[Category][Type] - Remove isBridgeless() mitigation

Reviewed By: mdvacca

Differential Revision: D27343952

fbshipit-source-id: 158175e58d0f4248623d369793e919e43e8ad972
2021-03-31 09:39:40 -07:00
Lulu Wu dfa8eb0558 Rename "hasActiveCatalystInstance" to "hasActiveReactInstance" for clarification
Summary:
Sometimes ```hasActiveCatalystInstance()``` is used to check if it's safe to access the CatalystInstance, which will still crash in Venice.

Previously we mitigate this by changing ```reactContext.hasActiveCatalystInstance()``` to ```reactContext.hasActiveCatalystInstance() || reactContext.isBridgeless()```.

To solve this for all and good the plan is:
1, Rename ```hasActiveCatalystInstance()``` to ```hasActiveReactInstance()``` so it won't sounds like CatalystInstance-only.
2, Implement hasActiveReactInstance() for Venice. D27343867
3, Remove previous mitigation. D27343952

This diff is the first step, by xbgs there are **58** non-generated callsites of  ```hasActiveCatalystInstance()``` in code base which are all renamed in this diff.

Changelog:
[Android][Changed] - Rename "hasActiveCatalystInstance" to "hasActiveReactInstance"

Reviewed By: mdvacca

Differential Revision: D27335055

fbshipit-source-id: 5b8ff5e09b79a492e910bb8f197e70fa1360bcef
2021-03-31 06:33:23 -07:00
Aditya Sharat 24bfa463a7 Refactor YogaNode.Inputs freeze API
Summary:
`InternalNode` will eventually not have a pointer to its parent. This diff removes one of the usages of the `InternalNode#getParent()` API. `InternalNode` will also not host the `YogaNode` eventually; so this diff also removes one of the usages of the `InternalNode#getYogaNode()` api.

Now the `Inputs#freeze` api will pass the parent's `YogaNode` and the `YogaNode` of the node (this) being measured.

Changelog: [Internal] Passes The YogaNode and parent YogaNode in the Inputs.freeze API

Reviewed By: SidharthGuglani

Differential Revision: D27240229

fbshipit-source-id: efc4ec3249a963c3181111f9b989d8ed9e17feb4
2021-03-30 05:42:57 -07:00
Samuel Susla 79090c4802 Fabric: Decoupling Telemetry aggregation classes into a separate module
Summary:
We need to do this to break a dependency cycle that would happen if we try to have `view` depend on `mounting` just to add some telemetry to `view`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D26827446

fbshipit-source-id: 4c415ebf5be3a02c18c80ea8a4a77068cae0f0fe
2021-03-29 05:12:42 -07:00
Aditya Sharat e27ca7f24e Create YogaProps Interface
Summary:
Create YogaProps Interface; this interface represents the inputs to YogaNode for layout calculation.

Changelog: [Internal] Create YogaProps Interface; this interface represents the inputs to YogaNode for layout calculation.

Reviewed By: mihaelao

Differential Revision: D27229274

fbshipit-source-id: 5205caf2384661369d7a2d7e7f3e49ff831a1c92
2021-03-26 10:05:46 -07:00
David Vacca 386a72464f Use DoNotStripAny in ComponentNameResolver classes
Summary:
This diff adds the DoNotStripAny annotation for the ComponentNameResolver classes

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27336874

fbshipit-source-id: d3bc404b12cc94fe8b4df61ff851e4fd9bcb5141
2021-03-26 00:09:40 -07:00
Joshua Gross e1b6cd3f75 ProGuard: Do not strip anything from FabricUIManager
Summary:
Instead of annotating individual methods with DoNotStrip, we actually want to ensure that nothing in this class gets stripped out.

This also upgrades the yoga/proguard-annotations package for Gradle builds.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27335181

fbshipit-source-id: 5b696c26faf4d1b32a3fd885e42a996aff23f0be
2021-03-25 17:40:34 -07:00
Ivan Kobzarev 24f9f75bf6 fbjni version to 0.2.2 (#31191)
Summary:
android fbjni dependency bump to 0.2.2

The motivation is to address https://github.com/pytorch/pytorch/issues/34682 that pytorch_android and react-native use different versions of fbjni with the same name libfbjni.so

In case of loading 0.0.2 version it is missing functions in binary

Fbjni is not changing much, that's why this will solve that problem for a long time (Until fbjni changed and versions will not be aligned)

## Changelog

[Android][Added] fbjni version bump to 0.0.3

Pull Request resolved: https://github.com/facebook/react-native/pull/31191

Test Plan: Automated (relying on the test suite) and manual testing.

Reviewed By: passy

Differential Revision: D27330370

Pulled By: IvanKobzarev

fbshipit-source-id: 2ea07d80d23f8dbc80e946a8818c1ecb8eb746e8
2021-03-25 11:28:00 -07:00
Andrei Shikov 35b575fefd Refactor mount logic into MountItemDispatcher
Summary:
Changelog: [Internal]

FabricUIManager contains a lot of logic related to mounting items and manipulating dispatch queues, which can be safely extracted outside. Apart from decreased logical complexity, this change enables easier modification of the queuing behavior later in this stack.

Majority of the changes is caused by moving existing logic to a different class, no change in behavior expected.

Reviewed By: JoshuaGross

Differential Revision: D27271116

fbshipit-source-id: 86fe45b19bb839f96fde8ba607f72006f6401cc7
2021-03-24 13:55:46 -07:00
David Vacca 91b3f5d48a Implement and integrate Mapbuffer
Summary:
This diff contains the code from the 35 diff stack  - D27210587

This diff implement and integrates Mapbuffer into Fabric text measure system

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27241836

fbshipit-source-id: f40a780df0723f27da440f709a8676cfcca63953
2021-03-24 03:52:31 -07:00