Skip to content

Commit

Permalink
Fix incorrect notification sound when channel is set to silent.
Browse files Browse the repository at this point in the history
Fixes #12317
  • Loading branch information
cody-signal authored and alex-signal committed Jul 11, 2022
1 parent e80df64 commit 748dbc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Expand Up @@ -25,7 +25,8 @@ class CustomNotificationsSettingsRepository(context: Context) {
val recipient = Recipient.resolved(recipientId)
val database = SignalDatabase.recipients
if (recipient.notificationChannel != null) {
database.setMessageRingtone(recipient.id, NotificationChannels.getMessageRingtone(context, recipient))
val ringtoneUri: Uri? = NotificationChannels.getMessageRingtone(context, recipient)
database.setMessageRingtone(recipient.id, if (ringtoneUri == Uri.EMPTY) null else ringtoneUri)
database.setMessageVibrate(recipient.id, RecipientDatabase.VibrateState.fromBoolean(NotificationChannels.getMessageVibrate(context, recipient)))
}
}
Expand Down
Expand Up @@ -296,7 +296,8 @@ public static synchronized void updateMessagesLedColor(@NonNull Context context,
return null;
}

return channel.getSound();
Uri channelSound = channel.getSound();
return channelSound != null ? channelSound : Uri.EMPTY;
}

/**
Expand Down
Expand Up @@ -274,7 +274,7 @@ object NotificationFactory {
recipient.messageRingtone ?: SignalStore.settings().messageNotificationSound
}

if (uri.toString().isEmpty()) {
if (uri == Uri.EMPTY || uri.toString().isEmpty()) {
Log.d(TAG, "ringtone uri is empty")
return
}
Expand Down

0 comments on commit 748dbc2

Please sign in to comment.