Android Room, Job Queue, and Cache Invalidation
This is documentation for the prototype that includes Room integration, Job Queue integration, and Cache Invalidation patterns.
Source documentation:
- https://proandroiddev.com/offline-apps-its-easier-than-you-think-9ff97701a73f
- Room Persistance library: https://developer.android.com/topic/libraries/architecture/room
- Android Priority Job Queue: https://github.com/yigit/android-priority-jobqueue
- https://stackoverflow.com/questions/35022074/how-do-i-inject-an-object-into-android-priority-job-queue-with-dagger-2
Git Repo w/ prototype:
- Pre-req changes in JavaSDK https://github.com/Sage-Bionetworks/BridgeJavaSDK/pull/501
- Primary BridgeAndroidSDK changes https://github.com/DwayneJengSage/BridgeAndroidSDK/commit/b4a6426c9d5244d451e51806130b4bc3cc458c52
- Missed a one-liner to kick off async update https://github.com/DwayneJengSage/BridgeAndroidSDK/commit/b520d7fb6570b69c3ffa4700b35269f0bdb73a74
State of Prototype
Prototype compiles and accurately reflects what I believe is the design pattern and API integration that accomplishes our goals. Unfortunately, I was unable to generify the components. App Config and Activities have very different API, call patterns, and query requirements. However, the pattern is simple enough that we should be able to replicate is across different use cases. If we need something generic and complete, we might want to consider codegen.
Code Organization
jobqueue package: Contains code to integrate with Android Priority Job Queue. BridgeJob is base class and handles retry logic and sets the Require Network flag. We also inject our managers here, so that Jobs can persist across app execution. We can either have the base class contain all the managers, or we can have different parent jobs for each manager and inject each parent class individually.
ActivityManagerV2: New version of ActivityManager using the new components. The old ActivityManager uses ScheduledActivityListV4 as its interface, which is hard to work with w.r.t Room persistence, so I created a brand new one.
persistence package: Contains code to integrate with Room and utils to marshal and unmarshal between Room type and Bridge Server type.