From 5c1a1b2efc5cff309edfc437c3b50e73d7438537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kosmaty?= Date: Fri, 22 May 2020 13:23:02 +0200 Subject: [PATCH] [expo-notifications] Fix test suite (#8413) --- apps/test-suite/tests/NewNotifications.js | 2 +- .../channels/NotificationChannelSerializer.java | 6 +++++- .../service/ExpoNotificationSchedulerService.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/test-suite/tests/NewNotifications.js b/apps/test-suite/tests/NewNotifications.js index 566283a6b3cd1..18ad817e9eb2a 100644 --- a/apps/test-suite/tests/NewNotifications.js +++ b/apps/test-suite/tests/NewNotifications.js @@ -358,7 +358,7 @@ export async function test(t) { lightColor: '#FF231F7C', lockscreenVisibility: Notifications.AndroidNotificationVisibility.SECRET, showBadge: false, - soundUri: null, + sound: null, audioAttributes: { usage: Notifications.AndroidAudioUsage.NOTIFICATION_COMMUNICATION_INSTANT, contentType: Notifications.AndroidAudioContentType.SONIFICATION, diff --git a/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationChannelSerializer.java b/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationChannelSerializer.java index a3e41ffe48ed4..5e98fad8d77e7 100644 --- a/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationChannelSerializer.java +++ b/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationChannelSerializer.java @@ -76,7 +76,11 @@ public static String toString(@Nullable Uri uri) { return "custom"; } - public static Bundle toBundle(AudioAttributes attributes) { + public static Bundle toBundle(@Nullable AudioAttributes attributes) { + if (attributes == null) { + return null; + } + Bundle result = new Bundle(); result.putInt(AUDIO_ATTRIBUTES_USAGE_KEY, AudioUsage.fromNativeValue(attributes.getUsage()).getEnumValue()); result.putInt(AUDIO_ATTRIBUTES_CONTENT_TYPE_KEY, AudioContentType.fromNativeValue(attributes.getContentType()).getEnumValue()); diff --git a/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/service/ExpoNotificationSchedulerService.java b/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/service/ExpoNotificationSchedulerService.java index 5efe02df69089..1411f403606ec 100644 --- a/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/service/ExpoNotificationSchedulerService.java +++ b/packages/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/service/ExpoNotificationSchedulerService.java @@ -264,7 +264,7 @@ protected Collection fetchNotifications() { protected NotificationRequest fetchNotification(String identifier) { try { return mStore.getNotificationRequest(identifier); - } catch (IOException | ClassNotFoundException e) { + } catch (IOException | ClassNotFoundException | NullPointerException e) { return null; } }