| b6b9bd6b | 19-Mar-2020 |
Stanisław Chmiela <[email protected]> |
[expo-network] Fix getMacAddressAsync as per docs (#7394)
# Why
While QAing SDK37 with `test-suite` I noticed persistent failures on `getMacAddressAsync` method. Decided to investigate them and f
[expo-network] Fix getMacAddressAsync as per docs (#7394)
# Why
While QAing SDK37 with `test-suite` I noticed persistent failures on `getMacAddressAsync` method. Decided to investigate them and fix before release.
# How
- `mac` sometimes is `null`, looping over `null` threw an NPE — fixed by `if (mac != null)`
- logic of this function is somewhat convoluted and I may have not grasped it all, but my gut tells me that this `break;` should happen alongside `promise.resolve`, otherwise for an empty `interfaceName` we only ever try to get MAC address of one interface
- `getMacAddressAsync`'s documentation states that on Android
> If undefined interface name passed in, the method would reject the promise with corresponding message.
which it didn't. Added a simple `if (interfaceName === undefined)` check, which if true, throws a `CodedError`.
- also updated the test case in `test-suite` to reflect the documentation behavior
- while editing Android Studio also reformatted the `NetworkModule` so I just reformatted all the files in the module
- then I backported those changes to versioned SDK37
# Test Plan
The tests pass.
show more ...
|