fix(alarm): declare pendingMissedIntent nullable to stop STOP_NATIVE NPE
Build & Deploy PluriWave / Análisis de código (push) Successful in 31s
Build & Deploy PluriWave / Build APK + AAB release (push) Successful in 2m27s

cancelAutoSilence calls pendingMissedIntent with FLAG_NO_CREATE, the
one Android flag whose entire purpose is to make getBroadcast() return
null on no match. The Kotlin signature declared a non-null return type,
so the compiler-inserted assertion threw NPE inside onStartCommand,
crashing the process before the Dart-side postpone flow could reach
its actual +N-minute reschedule call.
This commit is contained in:
Javier Bautista Fernández
2026-07-24 11:16:36 +02:00
parent f950da789a
commit 87acfae069
2 changed files with 5 additions and 2 deletions
@@ -741,7 +741,10 @@ class AlarmScheduler(private val context: Context) {
appContext,
id,
PendingIntent.FLAG_UPDATE_CURRENT
)
) ?: run {
Log.w(tag, "alarm.autoSilence arm failed: pendingMissedIntent returned null id=$id")
return
}
try {
alarmManager.setExactAndAllowWhileIdle(
AlarmManager.RTC_WAKEUP,
@@ -286,7 +286,7 @@ class PluriWaveAlarmReceiver : BroadcastReceiver() {
private fun requestCode(id: String, slot: Int): Int = 47 * id.hashCode() + slot
/** Shared PendingIntent factory for the MISSED transition alarm (Decision 3). */
fun pendingMissedIntent(context: Context, alarmId: String, flags: Int): PendingIntent =
fun pendingMissedIntent(context: Context, alarmId: String, flags: Int): PendingIntent? =
PendingIntent.getBroadcast(
context,
requestCode(alarmId, 4),