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

23510 Коммитов

Автор SHA1 Сообщение Дата
Nicola Corti b0711f1d35 Update ReactAndroid to use the AGP NDK Apis (#32443)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32443

This diff removes all the custom Gradle machinery to build the native code and delegates to AGP
the triggering of the `ndk-build` command. This means that the native build will be now invoked
with the `:ReactAndroid:externalNativeBuild<Variant>` task.

An important thing to notice is that that task will always run, and will delegate to Make the
compilation avoidance. If you invoke the task twice, the second time it will be significantly faster.
On my machine this takes ~6/7 mins the first time, and 30 seconds the second time.

There are some gotchas that are worth noting:
* The native build will run on every build now. Given the complexity of our native build graph,
even with an up-to-date build, Make will still take ~30 seconds on my machine to analyse all the
targets and mention that there is no work to be done. I believe this could be impactful for local
development experience. The mitigation I found was to apply an `abiFilter` to build only the ABI
of the target device (e.g. arm64 for a real device and so on).
This reduces the native build to ~10 seconds.
* All the change to the `react-native-gradle-plugin` source will cause the Gradle tasks to be
considered invalid. Therefore they will re-extract the header files inside the folders that are
used by Make to compile, triggering a near-full rebuild. This can be a bit painful when building
 locally, if you plan to edit react-native-gradle-plugin and relaunch
 rn-tester (seems to be like an edge case scenario but worth pointing out). The mitigation here
 would be to invoke the tasks like

```
gw :packages:rn-tester:android:app:installHermesDebug -x prepareBoost -x prepareLibevent -x prepareGlog \
   -x prepareJSC -x extractNativeDependencies -x generateCodegenArtifactsFromSchema \
   -x generateCodegenSchemaFromJavaScript
```

Changelog:
[Internal] [Changed] - Refactor Extract Headers and JNI from AARs to an internal task

Reviewed By: ShikaSD

Differential Revision: D31683721

fbshipit-source-id: fa85793c567796f4e04751e10503717a88cb0620
2021-11-01 05:59:15 -07:00
George Zahariev 6790cf137f Change usages of `exports.foo` and `module.exports.foo` to just `foo`
Summary:
Change usages of `exports.foo` and `module.exports.foo` to just `foo`.

This will fix future errors when Flow no longer allows reads from `exports`/`module.exports`.

Changelog: [Internal]

Reviewed By: bradzacher

Differential Revision: D32009490

fbshipit-source-id: bb609b37ba948b44c3877f8dbbfa9137b963586b
2021-10-29 20:09:13 -07:00
Marshall Roch d150529656 Deploy 0.163.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: evanyeung

Differential Revision: D32025457

fbshipit-source-id: f2c08e4baa9a39731ab970b917d2c67c852e9603
2021-10-29 19:06:23 -07:00
grgr-dkrk c8b83d4e0b feat: add `isAccessibilityServiceEnabled` (#31396)
Summary:
fix https://github.com/facebook/react-native/issues/30863

This PR adds `isAccessibilityServiceEnabled` to get if accessibility services are enabled on Android.

## 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] - Added `isAccessibilityServiceEnabled` to get if accessibility services are enabled

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

Test Plan: ![accessibilityService](https://user-images.githubusercontent.com/40130327/115560972-11d5b100-a2f0-11eb-8aa2-7c52dc71ca59.gif)

Reviewed By: yungsters

Differential Revision: D31911880

Pulled By: lunaleaps

fbshipit-source-id: 9ae294999a6d46bf051ab658507bf97764a945d2
2021-10-29 18:40:59 -07:00
Ken Tominaga bbb52aa276 Fix Fabric debug message when we set `fabric_enabled = false` in `rn-tester` (#32502)
Summary:
The debug message stays `Building RNTester with Fabric enabled.` even if we set `fabric_enabled = false`

This pull request changes the message like below when `fabric_enabled = false`

`Building RNTester with Fabric disabled.`

## 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
-->

[iOS] [Fixed] - Fix the debug message for Fabric in rn-tester

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

Reviewed By: sota000

Differential Revision: D32027858

Pulled By: lunaleaps

fbshipit-source-id: baf5301581e354f588830acd12a5e8171799b1ca
2021-10-29 15:13:09 -07:00
Héctor Ramos 70785e3d5a generate-specs-cli: Parse arguments using yargs
Summary:
Make `generate-specs-cli.js` use named arguments.

Updated all `generate-specs-cli.js` callsites to make use of named arguments.

Changelog: [Internal]

Reviewed By: sota000

Differential Revision: D31908041

fbshipit-source-id: f2cb5967db3c3b847e1095e35e8d5d21585be27b
2021-10-29 11:07:38 -07:00
Ramanpreet Nara 58c9d8eda7 Fix "Duplicate license header lint error" in Component generators
Summary:
See title.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D32019151

fbshipit-source-id: aea69a6c032cef1c99cd7641bdc10e730076e781
2021-10-29 10:43:39 -07:00
Luna Wei a6d8a9970d Add ios template build test
Summary: Changelog: [Internal] - Add iOS template app test

Reviewed By: sota000

Differential Revision: D31747179

fbshipit-source-id: d49c32c7652f91bdfd463509787096a41bbcc7b0
2021-10-28 15:48:29 -07:00
Xin Chen 61e1b6f86c Fix #flingAndSnap to check all the scroll item for offset range
Summary:
When calculating the offset range, we assume the first item is always at offset zero position and skipped that (as the smallerOffset is zero). However, this may not be the case in some situations. This diff changes the range measuring loop to always start from the first item.

Changelog:
[Android][Fixed] - Do NOT skip the first child view in the scroll view group when measuring the lower and upper bounds for snapping.

Reviewed By: mdvacca

Differential Revision: D31887086

fbshipit-source-id: af7221a621b2719d057afa6b64aa91c94ac01295
2021-10-27 13:59:12 -07:00
Nicola Corti 25605fb6c5 Bump version to 0.0.2
Summary:
Publishing a new version of the Gradle plugin as we need to distribute some
changes before releasing the playbook to the public.

Changelog:
[Internal] [Changed] - Bump react-native-gradle-plugin to 0.0.2

Reviewed By: ShikaSD

Differential Revision: D31957686

fbshipit-source-id: ef6742a205f2b568714c349dcb6481af33254b9b
2021-10-27 10:20:14 -07:00
Nicola Corti 3dff1fabdd Do not publish tests inside the npm package
Summary:
I'm removing the `src/test` folder from the npm bundle as it's not really
needed for the sake of distributing the gradle plugin.

Changelog:
[Internal] [Changed] - Do not publish tests inside the react-native-gradle-plugin npm package

Reviewed By: ShikaSD

Differential Revision: D31956449

fbshipit-source-id: b84138d24a7c51c44b92ebfc84f35afb3668dee5
2021-10-27 09:48:08 -07:00
Sota Ogo 9c4c12722a Fix a build issue where codegen order is incorrect (#32480)
Summary:
D31809012 (f7e4c07c84) introduced a condition where codegen files weren't generated in a correct order so the build fails in `yarn test-ios` if it was a first time to run the command. So it broke ci/circleci: test_ios_unit_hermes.

In this diff

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

Changelog: [intermal]

Reviewed By: cortinico

Differential Revision: D31953580

fbshipit-source-id: db854d6cfed8167dc4aae2667d379738bc261cfe
2021-10-27 09:45:25 -07:00
Nicola Corti a9fc0c5a9c Re-add libreact_debug to codegen makefile and add prebuilts for them
Summary:
While working updating the codeden Makefile template for Android, I've removed
the `libreact_debug` and `libreact_render_debug` dependencies as they were unused in a
simple turbomodule. Turns out that `:ReactAndroid` is depending on having those dependencies.

Moving the build file to use AGP APIs, triggers this scenario and is making `ReactAndroid`
failing to build (see the build status for https://github.com/facebook/react-native/pull/32443).

I'm updating the codegen Makefile template to reintrodce the two libraries + I've update the prebuilt
makefile (used in the playbook) to include `react_debug` prebuilts as they were missing.

Changelog:
[Internal] [Changed] - Re-add libreact_debug to codegen makefile and add prebuilts for them

Reviewed By: ShikaSD

Differential Revision: D31900675

fbshipit-source-id: ff188c0498a0dca4a951a548a580ca8dd0674782
2021-10-27 09:20:35 -07:00
Moshe Berman fdd744f013 Enable complete_nullability on //xplat/js/react-native-github:RCTTypeSafety (#32473)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32473

Reviewed By: AdamCmiel

Differential Revision: D31775069

fbshipit-source-id: f3aaee36c1ca8a209610f8b66c7adc90bd2b8c7e
2021-10-26 17:14:24 -07:00
Stefanos Markidis 456cf3db14 Fix ReactSwitch for non RippleDrawable backgrounds (#32468)
Summary:
ReactSwitch component is crashing on Android when it is initialised with both a backgroundColor and thumbColor, `style={{ backgroundColor: "anyColor" }} thumbColor="anyColor"`, due to IllegalCastException.

When setting a background color, BaseViewManagerDelegate is calling `setBackgroundColor` which replaces the background drawable with a ColorDrawale, hence [this line](72ea0e111f/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java (L68)) fails.

Instead, given the ripple effect needs to be preserved, one should initialise a RippleDrawable using the current background drawable and set it as the background of the switch.

Given the RippleDrawable should be preserved, overriding the `setBackgroundColor` seemed the sensible thing to do.

## Changelog

[Android] [Fixed] - Fix crash when a Switch is initialised with both backgroundColor and thumbColor.

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

Test Plan:
### Setup:
Initialise an empty React Native project. Add a switch component:
`<Switch
        style={{backgroundColor: 'red'}}
        thumbColor={'https://github.com/facebook/react-native/issues/356'}
      />`
Run the project `yarn android`

### Current state (RN 65+):
Red screen will show highlighting an IllegalCastException.

<img src="https://user-images.githubusercontent.com/4354327/138616661-3ba1370c-6a2b-48c2-ba70-b99415a4256f.png" width="200"/>

### With fix:
- The component is expected to have a red background.
- When pressed a ripple effect shows inside the backgrounds bounding box.
- Business as usual otherwise.

`backgroundColor` with `thumbColor`:
![backgroundColor + thumbColor](https://user-images.githubusercontent.com/4354327/138615603-141660d2-a5cd-49d7-aa5e-9c93ebc6d680.gif)

Just `thumbColor`:
![Screen Recording 2021-10-25 at 00 23 57](https://user-images.githubusercontent.com/4354327/138615658-baa380dd-2cbb-4d0f-a25e-a003ef67c977.gif)

Reviewed By: ShikaSD

Differential Revision: D31895690

Pulled By: cortinico

fbshipit-source-id: 60af16de7db61440ccfbf11d67a3d945dd90b562
2021-10-26 11:21:05 -07:00
Andrei Shikov f58c496e07 Use context from entry point for prerendering
Summary:
Some of the prerendered surfaces rely on Android context being present to have correct theming (e.g. for platform colors) and measurements of platform components. This change uses context provided to initialize the surface as themed context before view is attached.
This way it is possible to configure theming with `ContextThemeWrapper` the same way as Litho does it for prerendering. The assumption is that any kind of customization done through Android theme will be applied from prerendering entry point as well.

Changelog: [Internal] - Use context from surface for prerendering

Reviewed By: mdvacca

Differential Revision: D31906091

fbshipit-source-id: 344fc96eb2f85ba5b762bee64d1a29443b3fd1d3
2021-10-26 06:00:27 -07:00
Geraint White d2c10da5d5 Add bundleForVariant option (#32472)
Summary:
Ref https://github.com/facebook/react-native/pull/30606#issuecomment-948458552

## Changelog

[Android] [Added] - Add bundleForVariant option

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

Test Plan:
I added the following log into react.gradle and ran the Android build for my app:

```
println("bundleEnabled: ${targetName}, ${bundleForVariant(variant)}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
bundleEnabled: CveDebug, false
bundleEnabled: CveRelease, true
bundleEnabled: CveLive, true
bundleEnabled: WhceDebug, false
bundleEnabled: WhceRelease, true
bundleEnabled: WhceLive, true
```

Reviewed By: cortinico, ryancat

Differential Revision: D31910406

Pulled By: ShikaSD

fbshipit-source-id: baca5efaddedddad15d974cc7bb8f3c2a4c4f35b
2021-10-26 04:59:16 -07:00
Pieter De Baets d1439e8b85 Remove unused ensureComponentIsNative mock
Summary: Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31893181

fbshipit-source-id: 63204b818465f8ae06135f42c63e1340f6abb351
2021-10-26 03:24:01 -07:00
Sota Ogo 24d41845e8 Add fabric_enabled check in generate_temp_pod_spec_for_codegen
Summary:
I missed to push this change in the previous diff D31809012 (f7e4c07c84).

This diff adds a check so that only when fabric is enabled it include the React-graphic dependency.

Changelog: [internal]

Reviewed By: fkgozali

Differential Revision: D31919354

fbshipit-source-id: 0b4e7f489155f868cdf58bec3f61f309470ca0c6
2021-10-26 01:18:22 -07:00
Sota Ogo f7e4c07c84 Move codegen output out of node_modules
Summary:
In this diff, it moves the codegen output location out of node_modules and to build/generated/ios folder.

A temp pod spec will be created so that those files will be included in the Xcode project.

Changelog: [Internal]

Reviewed By: hramos, cortinico

Differential Revision: D31809012

fbshipit-source-id: ba1c884c8024306ba0fd2102837b7dbebc6e18ac
2021-10-25 20:48:24 -07:00
Saad Najmi 1b30dd074b Expose Pressability Hover config props in Pressable (#32405)
Summary:
Several desktop forks (`react-native-macos`, `react-native-windows`, `react-native-web`) support mouse events, and while the stock Pressable component has the ability to support mouse events, it seems we aren't forwarding some props properly from Pressable -> Pressability.

Pressability will calculate onMouseEnter / onMouseLeave event handlers based on the `onHoverIn/onHoverOut` callbacks passed into PressabilityConfig.
ad0d4534a7/Libraries/Pressability/Pressability.js (L552)
 However, Pressable does not pass take in onHoverIn/onHoverOut props to pass to PressabilityConfig, so we can't take advantage of this functionality. This change should simply address that by passing the props through.

## 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
-->

[General] [Fixed] - Pressabel not passing hover props and event handlers to PressabilityConfig

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

Test Plan: I fixed a similar issue in `react-native-macos` that I am now trying to contribute back upstream. https://github.com/microsoft/react-native-macos/pull/855

Reviewed By: yungsters

Differential Revision: D31667737

Pulled By: sota000

fbshipit-source-id: f0bbe48302703bb2c45280d2afeec8d7a4586b6a
2021-10-25 19:49:21 -07:00
Andrew Scherkus b2415c4866 Update XMLHttpRequest.getAllResponseHeaders() implementation (#32353) (#32363)
Summary:
As per the XMLHttpRequest specification [1], getAllResponseHeaders() should return a string of headers with lowercased names and sorted by their uppercase representation, with each header ending with '\r\n'.

[1] https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method

## Changelog

[General] [Changed] XMLHttpRequest.getAllResponseHeaders() now returns headers with names lowercased and sorted in ascending order, as per specification

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

Test Plan:
Test derived from Web Platform Test repository:
https://github.com/web-platform-tests/wpt/tree/master/xhr

Reviewed By: yungsters

Differential Revision: D31626217

Pulled By: sota000

fbshipit-source-id: 299d005facbe1c15b8cda5eed6750db75addca80
2021-10-25 19:45:51 -07:00
Sota Ogo 65af5eba9c Add a check for library_type
Summary:
Adding an error check to make debugging easier when codegen fails  when invalid library_type option is passed.

Changelog: [internal]

Reviewed By: hramos

Differential Revision: D31907880

fbshipit-source-id: c1ffa6bbd7b3e4faede88da2ee8d3378fa086780
2021-10-25 14:52:38 -07:00
Juan Tejada 016aef612c Update React DevTools v4.20.2
Summary:
Update `react-devtools-core` and `react-devtools` dependencies for RN, VSCode, Flipper, etc.

`js1 upgrade react-devtools -v 4.20.2`

# Changelog:

[General][Changed] - Upgraded react-devtools-core dependency to 4.20.2

Reviewed By: lunaruan

Differential Revision: D31809278

fbshipit-source-id: 0360fe173cfc7ce09595e6db4e8e41c6f64becd7
2021-10-25 14:00:48 -07:00
Sota Ogo 8b56522013 Accept "Library Type" in generate-specs-cli.js
Summary:
Currently, some filtering of generated files are done in multiple places (e.g. generate-specs-cli.js, react_native_pods.rb, etc). I am introducing this arguments so that only needed files are generated for components and modules.

Changelog: [internal]

Reviewed By: hramos, cortinico

Differential Revision: D31878098

fbshipit-source-id: d2dc8f51ea14a5d0ba1548bd481814220c9ae3a2
2021-10-25 11:39:53 -07:00
Luna Wei 03a0907868 Add back Xcode_12_5_M1_post_install_workaround
Summary: Changelog: [Internal] Add back Xcode_12_5_M1_post_install_workaround workaround

Reviewed By: sota000

Differential Revision: D31902449

fbshipit-source-id: 5c9d962d0d1a55a9f14186bd7d6d8fe087101f0d
2021-10-25 11:34:05 -07:00
Luna Wei 0454626415 Remove link to outdated release docs
Summary: Changelog: [Internal] - Remove link to outdated release docs

Reviewed By: cortinico

Differential Revision: D31837194

fbshipit-source-id: 9afad47e6d94d185d360af36776cd02a9b155650
2021-10-25 10:48:22 -07:00
Luna Wei 0a73a6fd31 Fix issue form description
Summary: Changelog: [Internal] - Fix github issue form description

Reviewed By: cortinico

Differential Revision: D31837196

fbshipit-source-id: 9ccdd0d1773add7f63b9ae8818b2a9364eb965d8
2021-10-25 10:48:22 -07:00
Luna Wei 2dda1cfc8e Remove action to close upgrade-related issues
Summary: Changelog: [Internal] Remove github action to close upgrade-related issues. We will be moving these issue to react-native repo and using this tag

Reviewed By: cortinico

Differential Revision: D31837195

fbshipit-source-id: 51fdd6efd88c0ebd5c504730406b217c8dbb3a88
2021-10-25 10:48:22 -07:00
Geraint White 055ea9c7b7 Fix devDisabledInStaging not working with multiple productFlavors (#30606)
Summary:
Fixes https://github.com/facebook/react-native/issues/27052

Since react-native 0.62, the `devDisabledIn${buildType}` syntax has stopped working for apps with multiple `productFlavors`. This PR adds the `disableDevForVariant` lambda to allow dev mode to be disabled for different variants.

## 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 devDisabledIn not working with multiple productFlavors

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

Test Plan:
I added the following log into `react.gradle` and ran the Android build for my app:

```
println("devEnabled: ${targetName}, ${devEnabled}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleInLive: true,
    disableDevForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
devEnabled: CveDebug, true
devEnabled: CveRelease, false
devEnabled: CveLive, false
devEnabled: WhceDebug, true
devEnabled: WhceRelease, false
devEnabled: WhceLive, false
```

Reviewed By: cortinico

Differential Revision: D31649977

Pulled By: ShikaSD

fbshipit-source-id: 520734314f4bca7608b8dca67c7c5ce0be6d31a5
2021-10-25 08:11:40 -07:00
CodemodService FBSourceClangFormatLinterBot 64711b0d98 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31891742

fbshipit-source-id: f6f6ad019e972de5acc8d04f0e8c8d9c9a2e3324
2021-10-25 04:08:21 -07:00
Andrew Rahn 72ea0e111f Hide the logbox window explicitly. New behavior in iOS SDK appears to… (#32435)
Summary:
Fixes  https://github.com/facebook/react-native/issues/32434: RCTLogBox window is orphaned, covering entire screen.

After this change, the logbox window once again is removed from the screen.

## Changelog

Some third-party SDKs may hold references to created UIWindow, UIViewController, or UIView objects. Doing so means that the current code's `hide` method that releases the reference to the UIWindow in LogBox will not cause the window to be dealloc'd, and thus instead it will remain on the screen. This change explicitly hides the LogBox window when the reference is released, so that even if some other SDK holds onto the window it will still be taken off the screen.

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

[iOS] [Fixed] - 32434

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

Test Plan:
1.     Use console.warn to generate a yellow warning message in log box.  Also install a third-party SDK that holds onto a reference to UIWindow -- for example the Facebook SDK, the Data Dog SDK, or any number of other SDKs that use `swizzling` to intercept calls like `viewDidAppear:`.
2.     click the log
3.     tap "dismiss"
4.     try to tap anywhere
5. Use Xcode view debugger to inspect the UI state

## Expected

The app still responds to the touch.
In Xcode, there is not an extra UIWindow covering the screen

Reviewed By: philIip

Differential Revision: D31794242

Pulled By: sshic

fbshipit-source-id: 28aa247b3ed3fd60b8e7c2ed7d0606cbf5c42408
2021-10-24 13:52:40 -07:00
Luna Wei ebe5417c7a Fix up dark mode for main lists
Summary: Changelog: [Internal] Fix up basic styling of dark mode for examples. Individual examples still may be broken and will be fixed up individually

Reviewed By: yungsters

Differential Revision: D31710790

fbshipit-source-id: 6ca4fb8a6238f38ff484ec91518057b243ba1d7b
2021-10-22 16:07:41 -07:00
Connor Tumbleson 4b25a0aaa0 feat: add missing Android dangerous permissions (#32445)
Summary:
This PR adds all missing `dangerous` permissions in Android. I recently updated these for Android 12 and found many more missing dating all the way back to API 26. After this PR, it will be in sync with ALL dangerous permissions as of the recently released Android 12.

https://developer.android.com/reference/android/Manifest.permission.html#ACCEPT_HANDOVER - 28
https://developer.android.com/reference/android/Manifest.permission.html#ACTIVITY_RECOGNITION - 29
https://developer.android.com/reference/android/Manifest.permission.html#ANSWER_PHONE_CALLS - 26
https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_NUMBERS - 26
https://developer.android.com/reference/android/Manifest.permission.html#UWB_RANGING - 31

## Changelog

[Android] [Changed] - Add ACCEPT_HANDOVER, ACTIVITY_RECOGNITION, ANSWER_PHONE_CALLS, READ_PHONE_NUMBERS & UWB_RANGING to PermissionsAndroid

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

Test Plan:
```
PermissionsAndroid.ACCEPT_HANDOVER === 'android.permission.ACCEPT_HANDOVER'
PermissionsAndroid.ACTIVITY_RECOGNITION === 'android.permission.ACTIVITY_RECOGNITION'
PermissionsAndroid.ANSWER_PHONE_CALLS === 'android.permission.ANSWER_PHONE_CALLS'
PermissionsAndroid.READ_PHONE_NUMBERS === 'android.permission.READ_PHONE_NUMBERS'
PermissionsAndroid.UWB_RANGING === 'android.permission.UWB_RANGING'
```

Reviewed By: yungsters

Differential Revision: D31793802

Pulled By: sshic

fbshipit-source-id: 4a2e5086e92ccd223e74db451c4ccd87485ffb63
2021-10-22 06:57:24 -07:00
Pieter De Baets b03e824c52 Mock composite animations when testing
Summary:
Single and composite animations were handled inconsistently in AnimatedMock. Also added a guard to prevent callbacks from triggering additional animations, since we had a test-scenario that did exactly that.

Changelog:
[General][Fixed] - Composite animations will now be ran immediately when the app is in testing mode

Reviewed By: yungsters

Differential Revision: D31826967

fbshipit-source-id: a6416b42e227fe79f5c3a55a9c51beb8451874f8
2021-10-22 06:38:17 -07:00
Nicola Corti e3a71b019f Bump react-native-codegen to 0.0.9
Summary:
Bumping the codegen to a new version to ship a change to the Android template.

Changelog:
[General] [Changed] - Bump react-native-codegen to 0.0.9

Reviewed By: hramos, mdvacca

Differential Revision: D31762139

fbshipit-source-id: 71a96210a3577c12ff3c9f9013c6e72adf4a0ecb
2021-10-22 03:09:24 -07:00
Tim Yung 3f629049ba RN: Deprecate Prop Types
Summary:
Deprecates `prop-types` from React Native.

Existing use cases will be presented with a warning to migrate to the newly published `deprecated-react-native-prop-types` module.

In a subsequent release, these will be removed from React Native.

Changelog:
[General][Changed] - Accessing `Image.propTypes`, `Text.propTypes`, `TextInput.propTypes`, `ColorPropType`, `EdgeInsetsPropType`, `PointPropType`, or `ViewPropTypes` now emits a deprecation warning.

Reviewed By: kacieb

Differential Revision: D29019309

fbshipit-source-id: 21e518e588fa05c498cc75ba81f69cfa8a9d0613
2021-10-21 17:45:47 -07:00
Gustavo Sverzut Barbieri 1e6add1a43 iOS Ruby Updates (#32456)
Summary:
Fix the `scripts/update-ruby.sh` so it always use the correct [bundle config](https://bundler.io/man/bundle-config.1.html#DESCRIPTION). In the current version it wasn't using the correct configuration inside the `template/` directory, resulting in incorrect platform for `template/Gemfile.lock`.

While at that, update the gems to their latest version:
- ethon 0.14.0 -> 0.15.0
- json 0.5.1 -> 0.6.0
- zeitwerk 2.4.2 -> 2.5.1
- bundler 2.2.28 -> 2.2.29

## Changelog

No changelog

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

Test Plan:
Run `bump-oss-version.js` and see `template/Gemfile.lock` lists `ruby` as the `PLATFORM` (no diff in that line).

## References
 - e18cf90d71 (r58230816)

Reviewed By: yungsters

Differential Revision: D31841524

Pulled By: charlesbdudley

fbshipit-source-id: 695c245fcb344c866afed45f747e04233e5c91e4
2021-10-21 15:58:18 -07:00
Héctor Ramos ad399f7a4f Utility script to discover codegen-enabled libraries
Summary:
Adds utility script which crawls through a React Native app's Node dependencies and, for each compatible library, generates the relevant native code artifacts.

This script is for development purposes, and is not hooked into the existing codegen integration by design.

Changelog: [Internal]

Reviewed By: sota000

Differential Revision: D28915433

fbshipit-source-id: de36d3e1dc0e11aad3ca55cea5e6731db09c5377
2021-10-21 15:24:30 -07:00
Tim Yung 70dcba9994 JS: Remove Unused Flow Suppressions
Summary:
Cleans up all unused Flow suppressions.

Changelog:
[Internal]

Reviewed By: kacieb

Differential Revision: D31754978

fbshipit-source-id: 951e28a245782b9bc9e93a6417d88b19ba0c8f1c
2021-10-21 14:26:00 -07:00
Xin Chen 7b77cc637e Change Vertical ScrollView to take Context instead of ReactContext
Summary:
The `ReactScrollView.java` constructor is using `ReactContext` instead of `Context`, which is inconsistent to the horizontal scroll view. This is the result from D3863966 (2cf2fdbc04) when an OSS issue needs to be addressed. That issue and all call sites to use the `ReactContext` are deprecated now.

Revert this back to use `Context` to be less restrictive.

Changelog:
[Android][Fixed] - Revert `ReactScrollView` to use `Context` instead of `ReactContext` in the constructor to be less restrictive.

Reviewed By: javache

Differential Revision: D31819799

fbshipit-source-id: 3f00d64850aebd2e20615033b2e1f1c721fed37e
2021-10-21 13:26:12 -07:00
Rubén Norte eccbf9b5cb Back out "Re-apply: [RN] Make runtime initialization from React renderers a no-op"
Summary:
Changelog: [internal]

This change had to be reverted because it caused some issues internally at Facebook. After we solved those we re-applied the changes but this also has issues in OSS apps. Specifically, the option in Metro to inject modules to execute before the EntryPoint (in this case `InitializeCore`) doesn't work if those modules aren't part of the bundle in the first place.

This reverts again so we can think about a long-term solution for this.

Original commit changeset: ba145a30ead5

Reviewed By: ShikaSD

Differential Revision: D31825736

fbshipit-source-id: 393b3d5d2a726951a9ac386dc2b1c19ef4a916a5
2021-10-21 04:29:07 -07:00
Pieter De Baets 8de8d475d4 Add surfaceId helper to Event baseclass
Summary:
Colocate the surface ID generate with the code that consumes it. This allows us to re-use this method in other event emitter locations.

Changelog: [Android][Changed] Add helper to get surfaceId for event dispatching

Reviewed By: philIip

Differential Revision: D31651881

fbshipit-source-id: 109e189f90261d3ba0077ffa519c3d12a9111439
2021-10-21 03:43:49 -07:00
Pieter De Baets 03e513de41 Add emitting view to onChildStartedNativeGesture callback
Summary:
Changelog:
[Android][Changed] RootView's onChildStartedNativeGesture now takes the child view as its first argument

Reviewed By: philIip

Differential Revision: D31399515

fbshipit-source-id: b9438f6118e604a04799ef67d0b46303a06d6434
2021-10-21 03:43:49 -07:00
CodemodService FBSourceGoogleJavaFormatLinterBot e007c8a9de Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D31824304

fbshipit-source-id: 146d9ca721773af1200ca01876387bcb44f95a40
2021-10-21 03:34:48 -07:00
Phillip Pan def7dd857d use new instead of alloc init
Summary:
i saw this a lot in the codebase, it's not optimal bc we're using two selectors when we only need one.

  fastmod --extensions m,mm '\[\[(.*) alloc] init]' '[${1} new]' --dir xplat/js/react-native-github/*

i manually updated the callsites that this codemod couldn't handle (e.g., where there were more than one of these instances in a single line)

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31776561

fbshipit-source-id: 1b16da240e8a79b54da67383d548921b82b05a9f
2021-10-20 22:18:38 -07:00
Tim Yung 9ac03361e6 RN: Add `glob` Flow Definition
Summary:
Adds the `glob` type definition via `flow-typed` so that the `combine-js-to-schema-cli.js` script does not need a Flow suppression.

Changelog:
[Internal]

Reviewed By: kacieb

Differential Revision: D31800809

fbshipit-source-id: 3e01a096d2153639a619a7152bd06332df57f06b
2021-10-20 19:25:45 -07:00
Tuomas Jaakola d839b24b06 Load jsc or hermes lib in static method (#30749)
Summary:
Many have reported about the misguiding error `Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so` even though they don't use Hermes (for example issues https://github.com/facebook/react-native/issues/26075 #25923).

**The current code does not handle errors correctly when loading JSC or Hermes in `ReactInstanceManagerBuilder`**.

**ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java:**
```java
try {
  return new HermesExecutorFactory();
} catch (UnsatisfiedLinkError hermesE) {
  // We never get here because "new HermesExecutorFactory()" does not throw an exception!
  hermesE.printStackTrace();
  throw jscE;
}
```

In Java, when an exception is thrown in static block, it will be RuntimeException and it can't be caught. For example the exception from `SoLoader.loadLibrary` can't be caught and it will crash the app.

**ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java:**
```java
static {
  // Exception from this code block will be RuntimeException and it can't be caught!
  SoLoader.loadLibrary("hermes");
  try {
    SoLoader.loadLibrary("hermes-executor-debug");
    mode_ = "Debug";
  } catch (UnsatisfiedLinkError e) {
    SoLoader.loadLibrary("hermes-executor-release");
    mode_ = "Release";
  }
}
```

This PR fixes the code so that the original exception from failed JSC loading is not swallowed. It does not fix the original issue why JSC loading is failing with some devices, but it can be really helpful to know what the real error is. For example Firebase Crashlytics shows wrong stack trace with current code.

I'm sure that this fix could have been written better. It feels wrong to import `JSCExecutor` and `HermesExecutor` in `ReactInstanceManagerBuilder.java`. However, the main point of this PR is to give the idea what is wrong with the current code.

## 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 error handling when loading JSC or Hermes

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

Test Plan:
* from this PR, modify  `ReactAndroid/src/main/java/com/facebook/react/jscexecutor/JSCExecutor.java` so that JSC loading will fail:
```java
// original
SoLoader.loadLibrary("jscexecutor");
// changed
SoLoader.loadLibrary("jscexecutor-does-not-exist");
```
* Run `rn-tester` app
* Check from Logcat that the app crashed with correct exception and stacktrace. It should **not** be `java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so`

Tested with Hermes

```
    SoLoader.loadLibrary("hermes-executor-test");
```
Got this one in logcat
```
09-24 20:12:39.552  6412  6455 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-test.so
```

Reviewed By: cortinico

Differential Revision: D30346032

Pulled By: sota000

fbshipit-source-id: 09b032a9e471af233b7ac90b571c311952ab6342
2021-10-20 17:53:26 -07:00
Phillip Pan 6acb18ca5d do not return BOOL for start and stop methods
Summary:
Changelog: [Internal]

these are returning bools for some reason even though no one is using the returned value. changing them to return void

Reviewed By: RSNara

Differential Revision: D31594241

fbshipit-source-id: 04c115b573b74996eaf2fef631eedb12c6734ea8
2021-10-20 15:42:22 -07:00
Phillip Pan f1aabc5164 remove unnecessary public methods on RCTFabricSurface
Summary:
Changelog: [Internal]

`start` and `stop` are already part of `RCTSurfaceProtocol` which is a public protocol conformance, we don't need to add these to this header, it's just extra work for the compiler

Reviewed By: RSNara

Differential Revision: D31776005

fbshipit-source-id: d89ad4dbe35e1b67cfa750c6414c40f9b4fc7f24
2021-10-20 15:42:22 -07:00