Skip to content

Commit

Permalink
deps: Upgrade react-native-device-info to 6.0.2, the latest.
Browse files Browse the repository at this point in the history
This is such a big leap between versions that my approach is to just
tear down the package and set it up again, all in the same commit.

This actually went very smoothly, for a few reasons:

- We use a very small part of its API, especially after 18c37ce.

- At least in the part we use, the library's own Flow types seem to
  be up-to-date. (We could have switched entirely to `expo-device`,
  and we could still do that, except that Expo has abandoned Flow
  completely, in favor of TypeScript. React Native Community has
  much better Flow support, generally.)

- Since the addition of this package, we started using CocoaPods
  (33f4b41) and autolinking (a9a9ac7), which make it much easier
  to manage dependencies that use native code.

In this commit:

- Look over past commits and the installation instructions for
  v0.21.5 of this package [1] to see what we need to tear down:

  - Remove workaround code from 44a7e07; the problem was solved in
    react-native-device-info/react-native-device-info@95887635, released
    in v2.1.2.

  - Keep mock of this library from 8300c9f; experimentally, it's
    still necessary.

  - (Nothing else stands out.)

- Upgrade version range of react-native-device-info from ^0.21.5 to
  ^6.0.2.

- Skip some manual setup instructions labeled "AndroidX Support" [2]
  that say to add things in the `ext` block in
  `android/build.gradle`.

  - One chunk of these instructions says it's meant for supporting
    `deviceId` (it probably means `getDeviceId`), with a menu of
    different choices for that based on what modern new features we
    want to use. Probably best to make that choice if and when we
    actually decide to use `getDeviceId`.

  - Another chunk is labeled "include as needed". It suggests
    `compileSdkVersion` and `targetSdkVersion` be at least 28, in
    order to use AndroidX; ours are already. There are a few things
    there I don't quite understand, but we've been doing fine with
    AndroidX since we started using it in e433197, and presumably
    "as needed" implies we would know (or soon find out) if we
    needed that stuff.

- Adjust our runtime code, if necessary (it's not necessary):

  - The two methods we do use, `getSystemName` and
    `getSystemVersion`, are still documented [3] [4] with the same
    usage as before. The changelog [5] doesn't suggest anything
    about these two methods, except for a blip with `getSystemName`
    where it had been returning "unknown" near-universally for one
    or two release candidates of v3, before that was promptly fixed.

Manual testing on one physical Android device and one physical iOS
device suggests that the same strings are given by those methods
before and after the upgrade. (Also, notably, no build failures or
runtime errors were observed.) In that experiment, the exported
constant in src/utils/userAgent.js was:

Before:

- "ZulipMobile/27.154 (iOS 13.7)"
- "ZulipMobile/27.154 (Android 9)"

After:

- "ZulipMobile/27.154 (iOS 13.7)"
- "ZulipMobile/27.154 (Android 9)"

If, one day, we're surprised by some unexpected string being used,
we can dig into the implementation difference between v0.21.5 and
v6.0.2 of this library and see what changed.

[1] https://github.com/react-native-community/react-native-device-info/tree/v0.21.5#installation
[2] https://github.com/react-native-community/react-native-device-info/tree/v6.0.2#androidx-support
[3] https://github.com/react-native-community/react-native-device-info/tree/v6.0.2#getsystemname
[4] https://github.com/react-native-community/react-native-device-info/tree/v6.0.2#getsystemversion
[5] https://github.com/react-native-community/react-native-device-info/blob/v6.0.2/CHANGELOG.md

Fixes: zulip#4240
  • Loading branch information
chrisbobbe committed Sep 21, 2020
1 parent 9cd4ceb commit ff253df
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ allprojects {
}
}

project(":react-native-device-info").beforeEvaluate {
ext.googlePlayServicesVersion = "16.1.0"
}

subprojects {
afterEvaluate {
if (project.hasProperty("android")) {
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ PODS:
- React
- RNCMaskedView (0.1.10):
- React
- RNDeviceInfo (0.21.5):
- RNDeviceInfo (6.0.2):
- React
- RNGestureHandler (1.8.0):
- React
Expand Down Expand Up @@ -695,7 +695,7 @@ SPEC CHECKSUMS:
rn-fetch-blob: f525a73a78df9ed5d35e67ea65e79d53c15255bc
RNCAsyncStorage: 3c304d1adfaea02ec732ac218801cb13897aa8c0
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNDeviceInfo: e7c5fcde13d40e161d8a27f6c5dc69c638936002
RNDeviceInfo: bdd61e8b070d13a1dd9d022091981075ed4cde16
RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39
RNReanimated: 89f5e0a04d1dd52fbf27e7e7030d8f80a646a3fc
RNSentry: ae1e005e4f2655775475445a9c49c1d343e8e3a7
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"react": "16.11.0",
"react-intl": "^2.4.0",
"react-native": "0.62.2",
"react-native-device-info": "^0.21.5",
"react-native-device-info": "^6.0.2",
"react-native-document-picker": "^3.2.4",
"react-native-gesture-handler": "^1.0.12",
"react-native-image-picker": "^2.3.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9792,10 +9792,10 @@ react-native-cli@^2.0.1:
prompt "^0.2.14"
semver "^5.0.3"

react-native-device-info@^0.21.5:
version "0.21.5"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-0.21.5.tgz#99478a2d68182e012297f2d63f2bd1b788106dee"
integrity sha512-Bvl7TyVMDbBH3wzvZx0xj3deMhWVRDHdOdjP1MjGVxVVH+bSlCi6oYDScaX2yz5rfi2OvevWWCg8jUqFKeepjA==
react-native-device-info@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-6.0.2.tgz#03317893bd6336b9ed2fe7a78d424737a441553f"
integrity sha512-Kx6ozWKkiPPvRhZDIL5jQ8zEZLlRT8hTovTaV+NgDc0tM+slBEnuEIgn0FXArHudO0qq2r+VDs4pUwMf6csGPg==

react-native-document-picker@^3.2.4:
version "3.2.4"
Expand Down

0 comments on commit ff253df

Please sign in to comment.