Skip to content

Commit

Permalink
Fix bug foreground service exception Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin committed Dec 6, 2024
1 parent 6a3abd8 commit b0672b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.pm.ServiceInfo
import android.graphics.drawable.Icon
import androidx.core.app.NotificationCompat
import androidx.hilt.work.HiltWorker
Expand Down Expand Up @@ -112,7 +113,11 @@ constructor(

val notification: Notification =
buildNotification(progress = 0, isSyncUpload = false, isInitial = true)

Check warning on line 115 in android/engine/src/main/java/org/smartregister/fhircore/engine/sync/AppSyncWorker.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/sync/AppSyncWorker.kt#L114-L115

Added lines #L114 - L115 were not covered by tests
return ForegroundInfo(NotificationConstants.NotificationId.DATA_SYNC, notification)
return ForegroundInfo(
NotificationConstants.NotificationId.DATA_SYNC,
notification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
}

private fun getSyncProgress(completed: Int, total: Int) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class AppMainActivityTest : ActivityRobolectricTest() {
appMainActivity.onSync(stateSucceded)

Assert.assertEquals(
viewModel.formatLastSyncTimestamp(timestamp = stateSucceded.timestamp),
viewModel.formatLastSyncTimestamp(timestamp = stateSucceded.timestamp) + " (0s)",
viewModel.getSyncTime(),
)
}
Expand Down

0 comments on commit b0672b7

Please sign in to comment.