fix(todo): reminders at the minute on Android 13 on, through USE_EXACT_ALARM (ADR 0033, D31)

SCHEDULE_EXACT_ALARM is off from Android 14 on until the person allows it
in Alarms & reminders, so every reminder was scheduled inexact and could
come minutes late. USE_EXACT_ALARM is granted with the install to an app
reminding of what a person planned, and AlarmManager.canScheduleExactAlarms
(which flutter_local_notifications' canScheduleExactNotifications asks) is
true with it, so reminders are exactAllowWhileIdle. SCHEDULE_EXACT_ALARM
stays for Android 12 and 12L, which don't know the other, up to API 32.

Whats-New: Reminders arrive on the minute.
Whats-New-De: Erinnerungen kommen auf die Minute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-04 22:35:05 +01:00
commit d49331b210
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -0,0 +1,38 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
/// Reminders come at the minute on Android (ADR 0033, D31): from Android 13
/// on through `USE_EXACT_ALARM`, granted with the install to an app that
/// reminds of what a person planned; on 12 and 12L, which don't know it,
/// through `SCHEDULE_EXACT_ALARM`, declared up to API 32 alone, so that from
/// 13 on the app holds no permission the person would have to grant in
/// Alarms & reminders.
void main() {
final manifest = File(
'android/app/src/main/AndroidManifest.xml',
).readAsStringSync();
/// The attributes of each `<uses-permission>` naming [permission].
List<String> declared(String permission) => [
for (final match in RegExp(
'<uses-permission([^>]*android:name="android.permission.$permission"'
'[^>]*)/>',
).allMatches(manifest))
match[1]!,
];
test('USE_EXACT_ALARM is declared, for every version', () {
expect(declared('USE_EXACT_ALARM'), [isNot(contains('maxSdkVersion'))]);
});
test('SCHEDULE_EXACT_ALARM is declared up to Android 12L alone', () {
expect(declared('SCHEDULE_EXACT_ALARM'), [
contains('android:maxSdkVersion="32"'),
]);
});
test('reminders are scheduled again after a restart', () {
expect(declared('RECEIVE_BOOT_COMPLETED'), hasLength(1));
});
}