fix(alarm): declare pendingMissedIntent nullable to stop STOP_NATIVE NPE
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:
@@ -741,7 +741,10 @@ class AlarmScheduler(private val context: Context) {
|
|||||||
appContext,
|
appContext,
|
||||||
id,
|
id,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
)
|
) ?: run {
|
||||||
|
Log.w(tag, "alarm.autoSilence arm failed: pendingMissedIntent returned null id=$id")
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
alarmManager.setExactAndAllowWhileIdle(
|
alarmManager.setExactAndAllowWhileIdle(
|
||||||
AlarmManager.RTC_WAKEUP,
|
AlarmManager.RTC_WAKEUP,
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ class PluriWaveAlarmReceiver : BroadcastReceiver() {
|
|||||||
private fun requestCode(id: String, slot: Int): Int = 47 * id.hashCode() + slot
|
private fun requestCode(id: String, slot: Int): Int = 47 * id.hashCode() + slot
|
||||||
|
|
||||||
/** Shared PendingIntent factory for the MISSED transition alarm (Decision 3). */
|
/** 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(
|
PendingIntent.getBroadcast(
|
||||||
context,
|
context,
|
||||||
requestCode(alarmId, 4),
|
requestCode(alarmId, 4),
|
||||||
|
|||||||
Reference in New Issue
Block a user