package com.doctate.watch.sync

import android.content.Context
import android.os.Build

/**
 * [SyncTrigger] that routes kicks into [SyncService]. Wired in
 * [com.doctate.watch.DoctateApp.onCreate]; replaces [NoopSyncTrigger]
 * once the service is registered in the manifest.
 */
object SyncServiceLauncher : SyncTrigger {
    override fun kick(context: Context, kick: SyncKick) {
        val intent = SyncService.startIntent(context, kick)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            context.startForegroundService(intent)
        } else {
            context.startService(intent)
        }
    }
}
