Будильник (Settings → Будильник): несколько будильников, время, станция, дни недели, fade-in пробуждения. AlarmManager.setAlarmClock (вне doze) + фолбэк, BootReceiver перепланирует после перезагрузки, AlarmReceiver→PlayerService (foreground) → PlayerController.startAlarmPlayback (нарастание громкости). Room: AlarmEntity/Dao, БД v7. Выбор битрейта по умолчанию в Settings (Авто/Эконом/Стандарт/Высокое) → preferredBitrate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1020 B
Kotlin
37 lines
1020 B
Kotlin
package com.radiola.service
|
|
|
|
import android.content.BroadcastReceiver
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import com.radiola.data.local.dao.AlarmDao
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
import kotlinx.coroutines.CoroutineScope
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.launch
|
|
import javax.inject.Inject
|
|
|
|
/**
|
|
* Перепланирует будильники после перезагрузки устройства.
|
|
*/
|
|
@AndroidEntryPoint
|
|
class BootReceiver : BroadcastReceiver() {
|
|
|
|
@Inject
|
|
lateinit var alarmDao: AlarmDao
|
|
|
|
@Inject
|
|
lateinit var alarmScheduler: AlarmScheduler
|
|
|
|
override fun onReceive(context: Context, intent: Intent) {
|
|
if (intent.action != Intent.ACTION_BOOT_COMPLETED) return
|
|
val pending = goAsync()
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
try {
|
|
alarmScheduler.rescheduleAll(alarmDao)
|
|
} finally {
|
|
pending.finish()
|
|
}
|
|
}
|
|
}
|
|
}
|