Page MenuHomePhabricator

Make CommSecureStore initialization idempotent on Android
ClosedPublic

Authored by marcin on Jun 8 2022, 6:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 9:50 PM
Unknown Object (File)
Sun, Nov 24, 9:50 PM
Unknown Object (File)
Sun, Nov 24, 9:50 PM
Unknown Object (File)
Sun, Nov 24, 9:49 PM
Unknown Object (File)
Sun, Nov 24, 9:49 PM
Unknown Object (File)
Sun, Nov 24, 9:49 PM
Unknown Object (File)
Sun, Nov 24, 9:49 PM
Unknown Object (File)
Fri, Nov 8, 1:27 AM

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
No Lint Coverage
Unit
No Test Coverage

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

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