google-research / CVD-paper-mobile-camera-example

Apache License 2.0
6 stars 4 forks source link

SyncUploadState #52

Closed MJ1998 closed 6 months ago

MJ1998 commented 6 months ago

Fixes #47

SensingEngine.syncUpload is moved to SensingSynchronizer.synchornize API

in synchronize we

  1. Fetch all upload requests
  2. invoke upload on them
  3. Collect individual UploadResults and creatSyncUploadStates We start off with emitting SyncUploadState.Started. Then the states are SyncUploadState.InProgress for all individual UploadResults statuses except for Failed state. Here we emit SyncUploadState.Failed and the worker cancels the upload job. Finally we emit SyncUploadState.Completed

We also added SyncUploadState.NoOp for the case when a new worker attempts to sync when there is already one worker which is running.

These SyncUploadStatees are collected by worker and persisted as WorkManager's progress data using setProgress API. This progress can be fetched as a flow using

WorkManager.getInstance(context)
      .getWorkInfosForUniqueWorkLiveData(uniqueWorkerName)
      .asFlow()

TESTED with code in demo app: Sensory. Look at the following progress bar.

Screenshot 2023-12-09 at 14 48 55