Prevent crash if exact alarm permission is revoked

hotfix/2.1.3
Alinson S. Xavier 2 years ago
parent 9ca1aa911a
commit d4f4f8b4a9
Signed by: isoron
GPG Key ID: 0DA8E4B9E1109DCA

@ -25,6 +25,7 @@ import android.app.AlarmManager.RTC_WAKEUP
import android.app.PendingIntent
import android.content.Context
import android.content.Context.ALARM_SERVICE
import android.os.Build
import android.util.Log
import org.isoron.uhabits.core.AppScope
import org.isoron.uhabits.core.models.Habit
@ -56,6 +57,10 @@ class IntentScheduler
)
return SchedulerResult.IGNORED
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !manager.canScheduleExactAlarms()) {
Log.e("IntentScheduler", "No permission to schedule exact alarms")
return SchedulerResult.IGNORED
}
manager.setExactAndAllowWhileIdle(alarmType, timestamp, intent)
return SchedulerResult.OK
}

Loading…
Cancel
Save