Page MenuHomePhabricator

Make CommSecureStore initialization idempotent on Android
ClosedPublic

Authored by marcin on Jun 8 2022, 6:37 AM.
Tags
None
Referenced Files
F3393656: D4240.id13432.diff
Sat, Nov 30, 3:27 PM
F3393642: D4240.id13455.diff
Sat, Nov 30, 3:17 PM
F3393632: D4240.id13600.diff
Sat, Nov 30, 3:14 PM
F3393446: D4240.diff
Sat, Nov 30, 2:00 PM
Unknown Object (File)
Wed, Nov 27, 8:36 PM
Unknown Object (File)
Wed, Nov 27, 8:35 PM
Unknown Object (File)
Sun, Nov 24, 9:50 PM
Unknown Object (File)
Sun, Nov 24, 9:50 PM

Details

Summary

This diff makes succesive calls to CommSecureStore.getInstance().initialize(...) idempotent. We need it since MainApplication and CommNotificationsHAndler may initialize CommSecureStore independently of each other.

Test Plan

Temporarily place logging into initialize() method. Check that logs appear only once between succesive foregrounding/backgrounding of the app. Also make sure that logs do not appear after the app is backgrounded and notification is received (CommNotificationsNahdler gets called).

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.Jun 8 2022, 6:38 AM
Harbormaster failed remote builds in B9691: Diff 13432!

Rebase to master after CI change

marcin requested review of this revision.Jun 8 2022, 7:17 AM

If CommSecureStore has to be threadsafe, I wonder if we should add a comment somewhere so people understand that if they're modifying it

native/android/app/src/main/java/app/comm/android/fbjni/CommSecureStore.java
8 ↗(On Diff #13438)

Can we put the newline back between import and the class declaration?

This revision is now accepted and ready to land.Jun 8 2022, 8:08 AM

Use double-check idiom to correctly privide idempotent initialization of CommSecureStore

This is great, but can be improved by using a Supplier - we will create a new instance of SecureStoreModule only when it's needed

native/android/app/src/main/java/app/comm/android/fbjni/CommSecureStore.java
22–30 ↗(On Diff #13455)

Use supplier pattern for CommSecureStore initialization. Use context for SecureStoreModule instantiation in CommCoreJSIModule