Commit Graph

479 Commits

Author SHA1 Message Date
David Vacca f535c8b4bb Inject ImagePipeline into FrescoModule
Summary:
This diff refactors the FrescoModule in order to receive an ImagePipeline as a parameter. This is necessary to ensure the same ImagePipeline is used by every RN module

changelog: [Internal][Android]

Reviewed By: JoshuaGross

Differential Revision: D21428346

fbshipit-source-id: 70a6cc57c8585fe74b6d0b0d1fd86c539974ec23
2020-05-08 16:37:41 -07:00
Kevin Gozali 164d47f30a label react-native-github targets
Summary:
For internal code attribution.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D21468924

fbshipit-source-id: 59cd2a52e0ae46bedbf54816820a5f40b684da8b
2020-05-08 00:36:17 -07:00
David Vacca 03385ac1d6 Fix Fb4aReactPackageTest.testGetNativeModulesByName test
Summary:
This diff refactors the ImageLoaderModule class in order to prevent early execution of Fresco.getImagePipeline method when prefetching MC is disabled (see stack D21362266)

changelog: [Internal][Android]

Reviewed By: shergin

Differential Revision: D21368516

fbshipit-source-id: 53f99cd3c3f4848364182cb954a8d34821cb6d9e
2020-05-02 11:06:47 -07:00
David Vacca eb6001998b Extend logging of image prefetching to include react_native contextChain
Summary:
This diff extends the logging of image prefetching to include react_native ID in the ContextChain of the Fresco logger.

This is necesary to properly assign pre-fetching of RN Android images to the react_native ID

changelog: [Internal][Android]

Reviewed By: fkgozali

Differential Revision: D21362266

fbshipit-source-id: ff64f0ebd12f61b713996558eb2d962f96ad8d94
2020-05-01 17:19:29 -07:00
David Vacca 3da8103679 Inject Fresco.ImagePipeline into ImageLoaderModule
Summary:
This diff injects Fresco.ImagePipeline into ImageLoaderModule in order to ensure prefetching uses the same ImagePipeline than ReactImageView

changelog: [internal][Android]

Reviewed By: fkgozali

Differential Revision: D21362267

fbshipit-source-id: d6f55cffb6be6a012c2afb4ad5db2072bc7100ec
2020-05-01 17:19:29 -07:00
generatedunixname89002005287564 673cbb3110 Daily arc lint --take GOOGLEJAVAFORMAT
Reviewed By: zertosh

Differential Revision: D21325542

fbshipit-source-id: d4c70da59c67c1f7dfcd36f06bbfe0eec5d4e824
2020-04-30 08:20:05 -07:00
James Ide d20ac69fc8 Replace duplicate code in AndroidInfoModule with call to AndroidInfoHelpers (#28756)
Summary:
The AndroidInfoModule class defines a `getServerHost()` method that duplicates the logic in `AndroidInfoHelpers.getServerHost(context)`. This commit makes AndroidInfoModule call into AndroidInfoHelpers so that potential future changes to `AndroidInfoHelpers.getServerHost` don't need to be duplicated in `AndroidInfoModule.getServerHost`.

## Changelog

[Android] [Changed] - Internal change to make `PlatformConstants` use the same method to determine `ServerHost` as other code paths
Pull Request resolved: https://github.com/facebook/react-native/pull/28756

Test Plan: Tested by running the RNTester app and editing the root component to print out `NativeModules.PlatformConstants.getConstants()` and verified one of the properties was: `"ServerHost": "10.0.2.2:8081"`.

Differential Revision: D21252158

Pulled By: shergin

fbshipit-source-id: b460197e5f1d972a5b91991c32a929294e358d9f
2020-04-29 22:32:28 -07:00
David Vacca e9f29a3291 Reject promise when if an error occurs while processing prefetching result
Summary:
This diff rejects the promise when if an error occurs while processing prefetching result, it applies the same concept as other methods in this class (e.g. see getSizeWithHeaders)

changelog: [internal][Android] Internal change in RN Image prefetching

Reviewed By: JoshuaGross

Differential Revision: D21295612

fbshipit-source-id: c3675e5f2d9c8e38094a538b388ff63a6ea18360
2020-04-28 21:47:01 -07:00
Ramanpreet Nara 9263eb5d38 Part 2: Make CatalystInstanceImpl.getNativeModule Nullable
Summary:
This is the codemod portion of the parent diff.

I modified all call-sites to `ReactContext.getNativeModule` to do a null check on the returned NativeModule.

Changelog:
[Android][Fixed] - Check if NativeModules returned from CatalystInstanceImpl.getNativeModule are null before using them.

Reviewed By: JoshuaGross

Differential Revision: D21272028

fbshipit-source-id: 6bd16c6bf30605f2dfdf4c481352063712965342
2020-04-28 12:18:17 -07:00
Rick Hanlon 7cedccdb8d Add "Open Debugger" and "Open React DevTools" to Android dev menu
Summary:
This diff introduces a new "Open Debugger" menu item for VMs that support on device debugging and for opening the React DevTools in Flipper.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20784279

fbshipit-source-id: caecdace00007224692d994a75c106842c8b2acb
2020-04-16 08:41:20 -07:00
Bruno Barbieri 3904228704 Make Vibration.vibrate compatible with TurboModules (#27951)
Summary:
This PR fixes a compatibility issue with the Vibration module and TurboModules.
The TurboModules spec doesn't allow nullable arguments of type Number, causing the following problem:

![IMG_3758](https://user-images.githubusercontent.com/1247834/73803879-10be6f80-4790-11ea-92d4-a008f0007681.PNG)

## Changelog

[iOS] [Fixed] - Make Vibration library compatible with TurboModules.
Pull Request resolved: https://github.com/facebook/react-native/pull/27951

Test Plan:
Just submitted a PR to my own app to fix the issue [here](https://github.com/rainbow-me/rainbow/pull/340)

The problem should be reproducible on RNTester due to this line: https://github.com/facebook/react-native/blob/91f139b94118fe8db29728ea8ad855fc4a13f743/RNTester/js/examples/Vibration/VibrationExample.js#L66  and should be working on this branch.

Reviewed By: TheSavior

Differential Revision: D19761064

Pulled By: hramos

fbshipit-source-id: 84f6b62a2734cc09d450e906b5866d4e9ce61124
2020-04-07 18:27:03 -07:00
Joshua Gross c4806fada6 Fail silently in AppStateModule.sendEvent if CatalystInstance is not available
Summary: According to our logs, 80% of these warnings are coming from AppStateModule. It's not particularly interesting or surprising that the CatalystInstance would be torn down when there's some app event, so let's stop taking up DB space with a useless message.

Reviewed By: ejanzer, mdvacca

Differential Revision: D20879426

fbshipit-source-id: b1182461aed4a66d82cb34bbd4b12782af6ed7b3
2020-04-06 17:52:33 -07:00
Emily Janzer 9d56c07bea Add API for getting sourceURL directly from ReactContext
Summary:
In bridgeless mode, the CatalystInstance doesn't exist, but we still need to be able to access the sourceURL in SourceCodeModule (which is needed to render the images in LogBox warnings and errors). This diff adds a new API for getting the sourceURL directly from ReactContext, instead of having to call context.getCatalystInstance().getSourceURL(), and updates SourceCodeModule to use it.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D20848700

fbshipit-source-id: 3ecda81a17121178b76bbb3e9b0f27f103c1961a
2020-04-06 11:37:14 -07:00
Jack Wang 05e2ec601b Changing Order Of mOverrideColorScheme In Constructor
Summary:
Changelog: [Android] [Updated]

mOverrideColorScheme should be assigned before the first colorSchemeForCurrentConfiguration call, so the initial setting of mColorScheme will reflect the override

Reviewed By: zackargyle

Differential Revision: D20630173

fbshipit-source-id: a2a2d174d3fc40c14f27dce6a7fa8e67203480c9
2020-03-24 15:33:40 -07:00
Jack Wang 45d7df6cf7 Adding interface callback for dynamic color scheme
Summary:
Changelog: [Android] [Added]

Adding:
- OverrideColorScheme interface to AppearanceModule
- setOverrideColorScheme method to AppearanceModule

This allows RN surfaces's color scheme to be overriden by custom theme from the app.
When set, AppearanceModule will use the value from OverrideColorScheme instead of system theme (light/dark)

Reviewed By: JoshuaGross

Differential Revision: D20405810

fbshipit-source-id: 8e562148a75231781649b615fdaf3368beeb477d
2020-03-13 22:06:04 -07:00
generatedunixname89002005287564 2e2b331db5 Daily arc lint --take GOOGLEJAVAFORMAT
Reviewed By: zertosh

Differential Revision: D20092187

fbshipit-source-id: 636d70cf85ae4e7c1be941cf04580dd91e68c8bf
2020-02-25 06:09:22 -08:00
Nikita Kraev 79efa43428 Update ImageEditingManager to use internal storage before falling back to external for cache
Summary:
Changelog: [Android] [Changed] - Internal storage now will be preferred for caching images from ImageEditor.

Now we try to write to internal cache directory first.
If that fails (due to no memory error or other IOException), we attempt to write to external storage (if that is allowed).

I introduced additional configuration flag, `allowExternalStorage` which is true by default.
And i updated documentation for new behaviour - see
 `ImageEditor.cropImage(..)` comment.

Reviewed By: makovkastar

Differential Revision: D19878158

fbshipit-source-id: 7e338ce68f535f74c62b5eecd5a94af7e7396f8b
2020-02-25 05:46:59 -08:00
Ramanpreet Nara 8bb78553a2 Make DeviceInfoModule extend code-generated Java spec
Summary:
I think this NativeModule was converted before we checked in the Java codegen output for TurboModules. I'm making `DeviceInfoModule` extend `NativeDeviceInfoSpec` to properly make it a TurboModule.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D19911145

fbshipit-source-id: fcec8c5b991bd9fd991e690dfa51f1bd36117e5f
2020-02-24 13:54:29 -08:00
Emily Janzer c32ec1f2ab Add @DoNotStrip annotation to JavaTimerManager.deleteTimer()
Summary:
This method is being stripped in release builds because it's used directly from C++ and not referenced in Java. Adding `DoNotStrip` to prevent this.

Changelog: [Internal]

Reviewed By: PeteTheHeat, mdvacca

Differential Revision: D19708826

fbshipit-source-id: a572f0295ab3b49e5884d0a6c723d65e4bbc9226
2020-02-05 15:26:11 -08:00
Emily Janzer bf32023e50 The life-changing magic of clang-tidying up
Summary:
Adding a `.clang-tidy` to a bunch of dirs under `react-native-github/ReactAndroid` and `react-native-github/ReactCommon`.

I don't want to add a single `.clang-tidy` at the root because we'll need more fine-grained control over what checks are enabled in different parts of the codebase; for example, fabric will and TM will probably have more checks enabled than older parts of the codebase that we're not actively modernizing, and the Hermes team probably wants its own config to be consistent with the rest of their codebase.

Starting off each `.clang-tidy` by only enabling clang-diagnostic; this is just to test that it's working. In the future, we'll work with the community to gradually enable more checks.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19705749

fbshipit-source-id: 979cea053b645ac4a9790340033bfcfb49ca0f97
2020-02-04 11:09:30 -08:00
Emily Janzer d3b2ac3a84 Add @DoNotStrip to method called from cpp in bridgeless mode
Summary:
I hit a crash when testing bridgeless mode in a release build:

Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/facebook/react/modules/core/JavaTimerManager;.createTimer(IJZ)V"

It turns out that `JavaTimerManager.createTimer()` is getting stripped from release builds because it's not referenced in Java at all. Adding `DoNotStrip` annotation to keep it around. The other methods in JavaTimerManager don't need this because they're referenced by TimingModule - this is the only method that's only used directly from C++ by bridgeless mode.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19655519

fbshipit-source-id: 8b9862475986bb84b12d81f73f677cc2e4860c67
2020-01-31 14:04:31 -08:00
Emily Janzer 8f5779cd70 Add in the optimization to check the first/least timer in the queue before iterating (#27841)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/27841

Follow up from https://github.com/facebook/react-native/pull/27539 - adding back in the optimization that Detox has in TimersIdlingResource to avoid iterating over the entire timers queue if the next timer is already within the specified range.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19522346

fbshipit-source-id: 32609f434d1ca575a5a49ad630e288c43fa90864
2020-01-29 11:45:26 -08:00
Bruno Barbieri aeaf286c77 - Origin header check shouldn't be case sensitive (#27827)
Summary:
Based on [this](https://stackoverflow.com/a/5259004), header names are not case sensitive.
That means that it's valid to pass a header `Origin` or `origin`.

With the current implementation. on Android only, if you pass `Origin`, it will get overwritten by the default origin.

This made me waste a lot of time debugging a problem while trying to connect to a websockets server that required an `origin` header and my implementation was working fine in iOS but not on Android, so I'm suggest changing the logic a little bit to take that into account.

## Changelog

[Android] [Fixed] - Support for case insensitive "Origin" headers for Websockets
Pull Request resolved: https://github.com/facebook/react-native/pull/27827

Test Plan:
Here's a screenshot of that shows the issue before the fix (`Origin` header set, but getting overridden)

![Screen Shot 2020-01-21 at 11 41 33 AM](https://user-images.githubusercontent.com/1247834/72824606-86302900-3c43-11ea-92c2-3d39881495f0.png)

The fix is not that easy to test since it requires a public websocket server that checks for a custom Origin header, but I think the code changes are very small and clear.

Differential Revision: D19578860

Pulled By: cpojer

fbshipit-source-id: d854e887d1b9e8e54da662b2da2ebe08ce65fdbc
2020-01-27 07:39:31 -08:00
Janic Duplessis d72e078df4 Add missing NativeEventListener methods to NativeDevSettings (#27838)
Summary:
Since migrating to Turbomodules (8fe04cf) the addMenuItem method crashes because the NativeEventListener methods are missing from the codegen flow type. Added the same methods based on what we do in AppState which is another native module that extends NativeEventListener.

## Changelog

[Internal] [Fixed] - Add missing NativeEventListener methods to NativeDevSettings
Pull Request resolved: https://github.com/facebook/react-native/pull/27838

Test Plan:
|Before|After|
|{F226978596}|{F226978628}

Differential Revision: D19518474

Pulled By: PeteTheHeat

fbshipit-source-id: acddba9f18dd558df1d6df78b539689fdfd0062f
2020-01-23 13:20:53 -08:00
Emily Janzer 383934a06e Don't emit dimensions update event on initial load
Summary: On iOS we don't emit the didUpdateDimensions event in JS when the first React Native screen is rendered, so let's keep the behavior the same on Android.

Reviewed By: mdvacca

Differential Revision: D19506829

fbshipit-source-id: d0122d18be79177318c3f059ed396f990eeabcb7
2020-01-22 10:16:33 -08:00
Pascal Hartig 9ad5e72b77 Migrate to FBJNI (#27729)
Summary:
This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time.

**A non-exhaustive list of tasks:**

* [X] Gradle builds the SDK and RNTester for Android.
* [X] Buck build for rntester works in OSS.
* [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution.
* [ ] Import this and fix potential internal build issues.
* [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences.

## Changelog

[Android] [Changed] - Migrated from libfb to libfbjni for JNI calls
Pull Request resolved: https://github.com/facebook/react-native/pull/27729

Test Plan:
- CI is already passing again for Gradle and Buck in OSS.
- After applying the following patch, RNTester builds and works with the latest Flipper SDK:

```
 diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle
index b8a6437d7..eac942104 100644
 --- a/RNTester/android/app/build.gradle
+++ b/RNTester/android/app/build.gradle
@@ -170,10 +170,19 @@ dependencies {
     debugImplementation files(hermesPath + "hermes-debug.aar")
     releaseImplementation files(hermesPath + "hermes-release.aar")

-    debugImplementation("com.facebook.flipper:flipper:0.23.4") {
+    debugImplementation("com.facebook.flipper🐬+") {
         exclude group:'com.facebook.yoga'
-        exclude group:'com.facebook.flipper', module: 'fbjni'
-        exclude group:'com.facebook.litho', module: 'litho-annotations'
+        exclude group:'com.facebook.fbjni'
+    }
+
+    debugImplementation("com.facebook.flipper:flipper-network-plugin:+") {
+        exclude group:'com.facebook.yoga'
+        exclude group:'com.facebook.fbjni'
+    }
+
+    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") {
+        exclude group:'com.facebook.yoga'
+        exclude group:'com.facebook.fbjni'
     }

     if (useIntlJsc) {
```

Reviewed By: mdvacca

Differential Revision: D19345270

Pulled By: passy

fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 02:32:50 -08:00
Emily Janzer bef845ffd5 Save a copy of DisplayMetrics native map in DeviceInfoModule
Summary:
After some more testing, I discovered a problem in D19395326 because the native map that DeviceInfoModule was storing in `mPreviousDisplayMetrics` had been consumed when the event was emitted to JS. This caused the comparison to fail, so it would emit the event again when the dimensions hadn't changed.

In this diff, I'm storing a Java-only copy of the native map before emitting the event to JS so this shouldn't happen.

Changelog: [Android][Fixed] Fix bug in updating dimensions in JS

Reviewed By: mdvacca

Differential Revision: D19462861

fbshipit-source-id: 2e47479df93377b85fe87f255972dd31e874e3a8
2020-01-18 12:00:07 -08:00
Emily Janzer cc3e27d484 Don't update dimensions for a new ReactRootView if they haven't changed
Summary:
ReactRootView currently caches the last seen DisplayMetrics so we can compare them against the current values in DisplayMetricsHolder to determine if the screen dimensions have changed. (If they have changed, we emit an event to notify JS of the new dimensions).

However, ReactRootView initializes these member variables with empty DisplayMetrics, which means that the first time we check against them in onGlobalLayout, we will *always* emit an event to JS.

This seems reasonable if you only have one ReactRootView, but if you create a new RRV for each RN screen in your app, then you're going to get updated dimensions on each navigation event, even though the screen dimensions have probably not changed.

In this diff, I'm no longer storing the DisplayMetrics in ReactRootView at all, but instead am using temporary variables to check the new DisplayMetrics values against the old.

Changelog: [Android][Fixed] Only update dimensions in ReactRootView if they've changed

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D19395326

fbshipit-source-id: c01aee73064764503c9b49208032c790b83a1d29
2020-01-17 21:13:22 -08:00
Pascal Hartig d5ba113bb2 clang-format cpp
Summary:
Ran `arc f` against some CPP files to be modified with the next diff
to reduce the churn on it.

## Changelog

[Android] [Changed] - Formatted cpp/h code with clang-format

Reviewed By: javache

Differential Revision: D19371785

fbshipit-source-id: b7f7b92c4cb9ec7f8da728bb577db29cf11fbb39
2020-01-14 01:04:16 -08:00
Peter Argany 1fbc6a7c17 Fix animations in OSS debug builds by modifying Platform.isTesting() behaviour
Summary:
In D14244606 I "fixed" `Platform.isTesting()` in JS. By fixed, I made it return true when running SSTs.

People in OSS complained about this in discord and [github](https://github.com/facebook/react-native/issues/27010). The problem is that this call returns true whenever an RN project references Detox in the build.gradle file. In practice, this has been really annoying, because it has disabled animations in debug builds, due to D13811035.

The fix is to be more specific, and look for the exact screenshot test activity. I haven't explicitly verified this doesn't trigger from Detox, but it shouldn't. I'll coordinate on the github issue to verify.

Changelog: [Android][Fixed] Fix animations in OSS debug builds by modifying `Platform.isTesting()` behaviour

Reviewed By: TheSavior

Differential Revision: D19384098

fbshipit-source-id: 22c885219f2c00f5dcc3b930b068bfd2ad7e4b8e
2020-01-13 23:22:09 -08:00
Emily Janzer 22764e6cdc Add an API for Detox to check if there are any timers expiring in a certain range (#27539)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/27539

Detox currently relies on reflection to inspect the private timers queue in the Timing module to check if React Native is idle or not. This broke when I renamed TimingModule and moved the queue to JavaTimerManager in D17260848 and D17282187. A better solution to this problem is for us to expose a public API for checking the timers queue from TimingModule, so that Detox doesn't need to access private fields.

Using similar logic to Detox's TimersIdlingResource: https://github.com/wix/Detox/blob/4f81a77baee4e4542a693922bcbde621d9d8c1a5/detox/android/detox/src/main/java/com/wix/detox/reactnative/idlingresources/TimersIdlingResource.kt#L95

Changelog: [Android] [Added] Added an API for checking if there are busy timers to TimingModule

Reviewed By: makovkastar

Differential Revision: D19128786

fbshipit-source-id: 835ae214eba58879c8343255bba680a81801ce03
2020-01-07 15:38:57 -08:00
Ramanpreet Nara 796dcf441c Make Java only NativeModules TurboModule-compatible"
Summary:
See D18787789.

Changelog:
[Android][Added] - Make Java only NativeModules TurboModule-compatible

Reviewed By: ejanzer

Differential Revision: D19216355

fbshipit-source-id: c59a6f976e32064cb0f331c00a53fb5e423cda5b
2020-01-06 16:30:18 -08:00
Jason Safaiyeh cc845ccfb4 Make addCookies method public. (#27512)
Summary:
react-native-cookie-store wants the ability to set custom cookies on Android. We use ForwardingCookieHandler to mange the cookies. Exposing the `addCookies` method will allow the module to provide the same functionality on Android.

https://github.com/safaiyeh/react-native-cookie-store/issues/1

## Changelog

[Android] [Changed] - Expose addCookies method
Pull Request resolved: https://github.com/facebook/react-native/pull/27512

Test Plan: N/A

Differential Revision: D19236309

Pulled By: cpojer

fbshipit-source-id: bf1a0730165456c34c5bf432ac370176a881cbcf
2019-12-27 01:55:40 -08:00
Ramanpreet Nara d43059d0b8 Correct ReactModuleSpecProcessor TurboModule detection logic
Summary:
## Problem
For efficiency reasons, we'd only check whether the current class or its superclass implemented the `TurboModule` interface. However, it's possible for NativeModules to exist that use inheritance, and have their base class extend a code-generated spec. In this case, the superclass of the superclass of the NativeModule will implement `TurboModule`.

## Solution
To fix this problem, I'm relying on the `Types.isAssignable` API and checking whether the NativeModule can be assigned to the `TurboModule` interface. This is a more reliable way of knowing whether a NativeModule is a TurboModule or not.

**Note:** Had to adjust the buck dependencies of FrescoModule to make the `mTypes.isAssignable` check work.

Changelog:
[Android][Fixed] - Correct TurboModule detection logic in ReactModuleSpecProcessor

Reviewed By: fkgozali

Differential Revision: D19183671

fbshipit-source-id: ad21881453fe7027d9432048108f6ba344fd7e63
2019-12-20 08:49:05 -08:00
Ramanpreet Nara 96a6ffb3e8 Make NativeModules TurboModule-compatible
Summary:
All these NativeModules are now: (1) type-safe, (2) TurboModule-compatible.

**Note:** We still need to update `{Catalyst,Work,Fb4a}TurboModuleManagerDelegate` to understand these TurboModules. I'll most likely write up that diff and stack this one on top of it.

Changelog:
[Android][Added] - Make NativeModules TurboModule-compatible

Reviewed By: mdvacca

Differential Revision: D18888735

fbshipit-source-id: 34df64dc70e3f3a0a0303c049861205f9d3fd2ed
2019-12-15 16:56:53 -08:00
David T. Nguyen 80bc51195e Revert D18787789: Make Java only NativeModules TurboModule-compatible
Differential Revision:
D18787789

Original commit changeset: d513006ffd73

fbshipit-source-id: 5757f8fe789840c10e358aa510e321fb8b326b7c
2019-12-13 22:26:48 -08:00
Ramanpreet Nara 1d3a95d96c Make Java only NativeModules TurboModule-compatible
Summary:
For NativeModules that don't need to be accessed from JS, we can just have them implement the TurboModule interface. This is enough to make them be instantiated via the TurboModule system.

Changelog:
[Android][Added] - Make Java only NativeModules TurboModule-compatible

Reviewed By: ejanzer

Differential Revision: D18787789

fbshipit-source-id: d513006ffd736621adbd41146ed6280a60a7437e
2019-12-13 18:23:14 -08:00
Ramanpreet Nara a8fbc5b893 Fix BlobModule getConstants()
Summary:
It's possible for us to return no constants from the BlobModule. Therefore, I'm correcting the flow-type.

Changelog:
[Internal]

Reviewed By: fkgozali

Differential Revision: D18932328

fbshipit-source-id: 2b415d12effd16eda313d5591825c711a20f9ae3
2019-12-11 11:31:51 -08:00
Ramanpreet Nara 37df2b28ad Delete getConstants from ImageEditingManager
Summary:
`NativeImageEditor` doesn't export any constants. Therefore, `ImageEditingManager` doesn't need a `getConstants()` method. In a subsequent diff (D18888735), I rename all `ReactMethod getConstants()` methods to `Override getTypedExportedConstants()`. This raises an error because the spec for `ImageEditingManager` doesn't contain a `getTypedExportedConstants()` method.

Changelog:
[Internal] - Delete getConstants() from ImageEditingManager

Reviewed By: fkgozali

Differential Revision: D18909419

fbshipit-source-id: 7e4f84f102068aa44bb3d267c66a60c0d0d27404
2019-12-10 12:35:17 -08:00
Anandraj Govindan 7cfabf42b8 Avoid throwing exceptions when the host activity is not FragmentActivity (#27425)
Summary:
There are some code in native modules which currently throws exception when the host activity is not a FragmentActivity, even if the native module is not used. This change avoids the throw and fail the promise instead.

## Changelog

There are some code in native modules which currently throws exception when the host activity is not a FragmentActivity, even if the native module is not used. This change avoids the throw and fail the promise instead.

[CATEGORY] [TYPE] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/27425

Test Plan: We've tested the change on MS Office applications, which currently don't use FragmentActivity.

Differential Revision: D18873012

Pulled By: mdvacca

fbshipit-source-id: 1b7c9efba5a59b2051487510da9ef7e1232877a5
2019-12-06 20:39:34 -08:00
Ramanpreet Nara 5c6451247d Make DeviceInfo extend ReactContextBaseJavaModule
Summary:
Changelog:
[Android][Changed] - Make DeviceInfo extend ReactContextBaseJavaModule

Reviewed By: PeteTheHeat

Differential Revision: D18784629

fbshipit-source-id: 782b922aa14232738dc7969594b0e0f07d9241f9
2019-12-06 10:05:10 -08:00
Emily Janzer 476a336e36 Convert NetworkingModule to TurboModule
Summary: Making the open source NetworkingModule TM-compatible.

Reviewed By: mdvacca

Differential Revision: D18770987

fbshipit-source-id: 64966f91308e31bdcf9bfa959381d4e40ccb2753
2019-12-04 11:26:39 -08:00
Ramanpreet Nara a6a34ba1d1 Add codegen specs as dependencies of NativeModules
Summary:
## Step 1
I'm going to make every Java NativeModule type-safe and TurboModule-compatible. The first step is to make sure that every type-unsafe NativeModule has a dependency on its spec's codegen target.

## Input
Module -> owner(Module): P123320255
Module -> name(Module): P123320256
Module -> owner(spec(name(Module))): P123320257

### Excluded NativeModules
NativeModules without Specs: P123320644
Java only NativeModules: P123320645

Changelog:
[Internal] - Add buck dependencies for NativeModule specs

Reviewed By: mdvacca

Differential Revision: D18781629

fbshipit-source-id: 89f39017b8224355d9d7b43bf6c162b0957760ee
2019-12-03 15:37:30 -08:00
Ramanpreet Nara 4d9e5f8481 Delete com.facebook.react.modules.debug.NativeSourceCodeSpec
Summary:
When SourceCode was converted to a TurboModule in D17586276, we had to check in `NativeSourceCodeSpec` into the codebase. Since all the OSS NativeModule base classes are now checked into `react-native-github`, it's no longer necessary to keep `NativeSourceCodeSpec`. So, I'm deleting it.

Changelog:
[Android][Removed] - Delete com.facebook.react.modules.debug.NativeSourceCodeSpec

Reviewed By: PeteTheHeat, mdvacca

Differential Revision: D18732997

fbshipit-source-id: 6026b4bcb9ebb9c4d7ba556bc644698eb550a9de
2019-12-03 06:29:58 -08:00
Ramanpreet Nara 7ce8babfef Make ExceptionsManagers extend ReactContextBaseJavaModule
Summary:
Eventually, we want these to extend the abstract base class code-generated from the NativeModule spec. That base class extends `ReactContextBaseJavaModule`. So, this is a step in the right direction.

Changelog:
[Internal] Make ExceptionsManagerModule extend ReactContextBaseJavaModule

Reviewed By: PeteTheHeat, mdvacca

Differential Revision: D18718061

fbshipit-source-id: 70ba5c45b3ef1dd7602e1186763c8bc7ab5d4f42
2019-11-27 16:27:36 -08:00
Emily Janzer 641e9657dd Make ImageLoaderModule TurboModule-compatible
Summary:
Modifying ImageLoaderModule to be TM-compatible by extending the generated abstract class and fixing the conflicting method signatures (int -> double).

Changelog: [Android] [Changed] Changing method signatures for ImageLoaderModule to accept double for requestId

Reviewed By: mdvacca

Differential Revision: D18435628

fbshipit-source-id: bc2a82bda49e339d1feebfe917b0862a1af15a1f
2019-11-18 12:40:31 -08:00
Vincent Cheung 1df8bd4932 Fix multiple set-cookie not aggregated correctly in response headers (#27066)
Summary:
Multiple `set-cookie` headers should be aggregated as one `set-cookie` with values in a comma separated list. It is working as expected on iOS but not on Android. On Android, only the last one is preserved

The problem arises because `NetworkingModule.translateHeaders()` uses `WritableNativeMap` as the translated headers but uses both native and non-native methods. The mixup causes out of sync data that both sets of methods do no agree. A simple fix is to use `Bundle` as the storage and only convert it to `WritableMap` at the end in one go

Related issues: https://github.com/facebook/react-native/issues/26280, https://github.com/facebook/react-native/issues/21795, https://github.com/facebook/react-native/issues/23185

## Changelog

[Android] [Fixed] - Fix multiple headers of the same name (e.g. `set-cookie`) not aggregated correctly
Pull Request resolved: https://github.com/facebook/react-native/pull/27066

Test Plan:
A mock api, https://demo6524373.mockable.io/, will return 2 `set-cookie` as follows:
```
set-cookie: cookie1=value1
set-cookie: cookie2=value2
```

Verify the following will print the `set-cookie` with a value `cookie1=value1, cookie2=value2`
```javascript
  fetch('https://demo6524373.mockable.io/')
    .then(response => {
      console.log(response.headers);
    });
```
On iOS, `set-cookie` will have `cookie1=value1, cookie2=value2` while on Android it will have `cookie2=value2` (preserving only the last one)

Differential Revision: D18298933

Pulled By: cpojer

fbshipit-source-id: ce53cd41d7c6de0469700617900f30a7d0914c26
2019-11-05 03:30:02 -08:00
Rick Hanlon 93f4bb23e2 LogBox - Don't show native redbox for JS errors on Android
Summary:
Will not show native redboxes when LogBox handles them

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D18236608

fbshipit-source-id: 1c60c69419b1a823594caf650d67693d4ad2076b
2019-10-31 16:26:44 -07:00
Elisa Lou 27d7d3fed5 update android AppearanceModule to support dark mode in all OS versions
Summary:
We no longer need to gate by OS version since we want to allow in-app theming. This diff ensures that we are passing in the updated system context to retrieve the correct app theme.

Changelog:
[Android] Enable AppearanceModule for all OS versions

Reviewed By: mdvacca

Differential Revision: D18224915

fbshipit-source-id: 42d5db8497d8bead32c49e3e2a25d4ba779e2b33
2019-10-31 10:05:38 -07:00
Joshua Gross 9446277fc1 Simplify API of getReactApplicationContextIfActiveOrWarn
Summary:
Simplify the API of `getReactApplicationContextIfActiveOrWarn`. We don't need to pass so much information into this method to collect good SoftExceptions.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18134400

fbshipit-source-id: 0a250ab0252a44121f3339a31506a0a6c4c7cd35
2019-10-25 16:16:00 -07:00