Page MenuHomePhabricator

[native] [31/40] RN 0.70: First commit for new AndroidLifecycle Expo module
ClosedPublic

Authored by ashoat on Dec 19 2022, 7:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 5:54 PM
Unknown Object (File)
Fri, Nov 8, 11:28 PM
Unknown Object (File)
Fri, Nov 8, 10:54 AM
Unknown Object (File)
Thu, Nov 7, 8:35 PM
Unknown Object (File)
Thu, Nov 7, 5:53 AM
Unknown Object (File)
Wed, Nov 6, 6:26 AM
Unknown Object (File)
Wed, Nov 6, 6:26 AM
Unknown Object (File)
Wed, Nov 6, 6:26 AM
Subscribers

Details

Summary

We have an existing custom AndroidLifecycle React Native module, but it started having issues after the update: ENG-2484. I decided to migrate the module to an Expo module, which are newly supported as of Expo 47.

This diff contains basically an end-to-end "Hello World", mostly pulled from running npx create-expo-module expo-settings and filtering out just the pieces I wanted to keep.

Depends on D5925

Test Plan

I patched the following into native/root.react.js:

import * as AndroidLifecycleModule from './lifecycle/lifecycle-module';

if (Platform.OS === 'android') {
  console.log(`androidLifecycle.PI: ${AndroidLifecycleModule.PI ?? 'null or undefined'}`);
  console.log(`androidLifecycle.hello(): ${AndroidLifecycleModule.hello() ?? 'null or undefined'}`);
  (async () => {
    AndroidLifecycleModule.addChangeListener(({ value }) => { console.log(`onChange ${value}`) });
    await AndroidLifecycleModule.setValueAsync('testing!!');
    console.log('done testing');
  })();
}

It resulted in the following output:

LOG  androidLifecycle.PI: 3.141592653589793
LOG  androidLifecycle.hello(): Hello world! ๐Ÿ‘‹
LOG  onChange testing!!
LOG  done testing

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Dec 19 2022, 7:01 AM
Harbormaster failed remote builds in B14316: Diff 19558!
Harbormaster returned this revision to the author for changes because remote builds failed.Dec 19 2022, 9:10 AM
Harbormaster failed remote builds in B14388: Diff 19637!

Please ignore CI until the end of the stack

native/expo-modules/android-lifecycle/android/src/main/java/app/comm/android/lifecycle/AndroidLifecycleModule.kt
1โ€“38 โ†—(On Diff #19637)

I shorten the line lengths to 80 chars in the next diff. This is just boilerplate

package.json
12 โ†—(On Diff #19637)

Oops, this was a rebase mistake

13 โ†—(On Diff #19637)

I need to copy this over in keyserver/Dockerfile. That's what's causing the CI failure there

Copy new package.json in keyserver Dockerfile, remove reference to deprecated opaque-ke-node package

Modify .dockerignore to make sure Docker can access new package.json

This revision is now accepted and ready to land.Dec 19 2022, 10:49 AM
tomek added inline comments.
package.json
44โ€“46 โ†—(On Diff #19768)

What is changed in these lines? (Phabricator isn't too helpful here)

package.json
44โ€“46 โ†—(On Diff #19768)

I think I accidentally copy-pasted tab characters in D5901. I can move this change there before landing.

ashoat@ashoatmbp2021 [~/src/comm]$ git diff HEAD^ package.json
diff --git a/package.json b/package.json
index 93e34aba0..f87fd501a 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,8 @@
     "keyserver",
     "landing",
     "desktop",
-    "keyserver/addons/opaque-ke-napi"
+    "keyserver/addons/opaque-ke-napi",
+    "native/expo-modules/android-lifecycle"
   ],
   "scripts": {
     "clean": "yarn workspace lib clean && yarn workspace web clean && yarn workspace native clean && yarn workspace keyserver clean && yarn workspace landing clean && yarn workspace desktop clean && yarn workspace opaque-ke-napi clean && rm -rf node_modules/",
@@ -41,6 +42,6 @@
     "prettier": "^2.1.2"
   },
   "resolutions": {
-               "react-native-flipper": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.0.2.tgz"
-       }
+    "react-native-flipper": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.0.2.tgz"
+  }
 }
package.json
44โ€“46 โ†—(On Diff #19768)

Tab-to-spaces change has been moved to D5901 where it belongs