package com.radiola.service

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import androidx.core.content.ContextCompat

/**
 * BroadcastReceiver-триггер будильника.
 * Не Hilt-инжектируемый — намеренно простой: только передаёт id в PlayerService.
 */
class AlarmReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        val alarmId = intent.getIntExtra("alarm_id", -1)
        if (alarmId < 0) return

        val serviceIntent = Intent(context, PlayerService::class.java).apply {
            action = PlayerService.ACTION_ALARM
            putExtra("alarm_id", alarmId)
        }
        ContextCompat.startForegroundService(context, serviceIntent)
    }
}
