Skip to content

Commit

Permalink
added permission check when using alarmClock as schedule mode (#2250)
Browse files Browse the repository at this point in the history
* added permission check when using alarmClock as schedule mode

* bumped device_info_plus dependency

* remove steps to build using Flutter 3.0.0

* addressed unnecessary_set_literal warnings
  • Loading branch information
MaikuB authored Mar 5, 2024
1 parent 2783939 commit 1acce02
Show file tree
Hide file tree
Showing 8 changed files with 660 additions and 490 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ jobs:
run: ./.github/workflows/scripts/install-tools.sh
- name: Build
run: melos run build:example_android
build_example_android_300:
name: Build Android example app (3.0.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.0.0
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
run: ./.github/workflows/scripts/install-tools.sh
- name: Build
run: melos run build:example_android
build_example_ios_stable:
name: Build iOS example app (stable channel)
runs-on: macos-latest
Expand Down Expand Up @@ -103,25 +88,6 @@ jobs:
- run: flutter config --enable-linux-desktop
- name: Build
run: melos run build:example_linux
build_example_linux_300:
name: Build Linux example app (3.0.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.0.0
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
run: ./.github/workflows/scripts/install-tools.sh
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev
- run: flutter config --enable-linux-desktop
- name: Build
run: melos run build:example_linux
unit_tests_dart:
name: Run all unit tests (Dart)
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# [16.3.3]

* [Android] added missing check on if `SCHEDULE_EXACT_ALARM` permission was granted when using the `alarmClock` as the `AndroidScheduleMode`
* Bumped `device_info_plus` dependency for example app, which means example app requires Flutter SDK version 3.3.0 or higher to run

# [16.3.2]

* [Android] fixed how native stack traces were obtained. Relates to issue [2088](https://github.com/MaikuB/flutter_local_notifications/issues/2088). Thanks to the PR from [Jonas Uekötter](https://github.com/ueman)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ private static void setupAlarm(
AlarmManagerCompat.setExact(
alarmManager, AlarmManager.RTC_WAKEUP, epochMilli, pendingIntent);
} else if (notificationDetails.scheduleMode.useAlarmClock()) {
checkCanScheduleExactAlarms(alarmManager);
AlarmManagerCompat.setAlarmClock(alarmManager, epochMilli, pendingIntent, pendingIntent);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, epochMilli, pendingIntent);
Expand All @@ -734,6 +735,7 @@ private static void setupAllowWhileIdleAlarm(
AlarmManagerCompat.setExactAndAllowWhileIdle(
alarmManager, AlarmManager.RTC_WAKEUP, epochMilli, pendingIntent);
} else if (notificationDetails.scheduleMode.useAlarmClock()) {
checkCanScheduleExactAlarms(alarmManager);
AlarmManagerCompat.setAlarmClock(alarmManager, epochMilli, pendingIntent, pendingIntent);
} else {
AlarmManagerCompat.setAndAllowWhileIdle(
Expand Down
1,085 changes: 641 additions & 444 deletions flutter_local_notifications/example/lib/main.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion flutter_local_notifications/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: none

dependencies:
cupertino_icons: ^1.0.2
device_info_plus: ^8.0.0
device_info_plus: ^9.1.2
flutter:
sdk: flutter
flutter_local_notifications:
Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_local_notifications
description: A cross platform plugin for displaying and scheduling local
notifications for Flutter applications with the ability to customise for each
platform.
version: 16.3.2
version: 16.3.3
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ void main() {
).thenAnswer((_) async => platformInfo);
when(
mockStorage.forceReloadCache(),
).thenAnswer((_) async => <void>{});
).thenAnswer((_) async {});
when(
mockDbus.build(
destination: 'org.freedesktop.Notifications',
path: '/org/freedesktop/Notifications',
),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});
when(
mockDbus.subscribeSignal('ActionInvoked'),
).thenAnswer((_) => mockActionInvokedSignal);
Expand Down
16 changes: 8 additions & 8 deletions flutter_local_notifications_linux/test/storage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(false);
when(
mockStorageFile.createSync(recursive: true),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});
when(mockStorageFile.readAsStringSync()).thenReturn('');

expect(await storage.insert(notifications[0]), isTrue);
Expand Down Expand Up @@ -111,7 +111,7 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(true);
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});
when(mockStorageFile.readAsStringSync()).thenReturn('');

await storage.insert(notifications[0]);
Expand Down Expand Up @@ -153,7 +153,7 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(true);
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});

when(mockStorageFile.readAsStringSync()).thenReturn('');
expect(await storage.getAll(), <LinuxNotificationInfo>[]);
Expand Down Expand Up @@ -185,7 +185,7 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(true);
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});

when(mockStorageFile.readAsStringSync()).thenReturn('');
expect(await storage.getAll(), <LinuxNotificationInfo>[]);
Expand Down Expand Up @@ -213,7 +213,7 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(true);
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});

when(
mockStorageFile.readAsStringSync(),
Expand Down Expand Up @@ -241,7 +241,7 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(true);
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});
when(mockStorageFile.readAsStringSync()).thenReturn('');

await storage.insert(notifications[0]);
Expand Down Expand Up @@ -271,7 +271,7 @@ void main() {
when(mockStorageFile.existsSync()).thenReturn(true);
when(
mockStorageFile.writeAsStringSync(any),
).thenAnswer((_) => <void>{});
).thenAnswer((_) {});
when(mockStorageFile.readAsStringSync()).thenReturn('');

await storage.insert(notification);
Expand Down

0 comments on commit 1acce02

Please sign in to comment.