mirror of
https://github.com/ProtonMail/android-mail.git
synced 2026-05-15 09:50:40 +00:00
Add FCM diagnostics logs
- Log priority downgrade cases as warning - Override onMessagesDeleted and add a warning log - Log message type ET-5803
This commit is contained in:
+16
-5
@@ -50,11 +50,6 @@ internal class ProcessPushNotificationDataWorker @AssistedInject constructor(
|
||||
val sessionId = inputData.getString(KeyPushNotificationUid)
|
||||
val encryptedNotification = inputData.getString(KeyPushNotificationEncryptedMessage)
|
||||
|
||||
Timber.d(
|
||||
"Notification: Process push notification for userId=%s, sessionId=%s",
|
||||
userId,
|
||||
sessionId
|
||||
)
|
||||
return if (userId.isNullOrEmpty() || sessionId.isNullOrEmpty() || encryptedNotification.isNullOrEmpty()) {
|
||||
Result.failure(workDataOf(KeyProcessPushNotificationDataError to "Input data is missing"))
|
||||
} else {
|
||||
@@ -74,6 +69,13 @@ internal class ProcessPushNotificationDataWorker @AssistedInject constructor(
|
||||
return Result.failure(workDataOf(KeyProcessPushNotificationDataError to it.message))
|
||||
}
|
||||
|
||||
Timber.d(
|
||||
"Notification: Process push notification of type=%s for userId=%s, sessionId=%s",
|
||||
decryptedNotification.typeName(),
|
||||
userId,
|
||||
sessionId
|
||||
)
|
||||
|
||||
return when (decryptedNotification) {
|
||||
is LocalPushNotification.Message.NewMessage -> processNewMessagePushNotification(decryptedNotification)
|
||||
is LocalPushNotification.Message.MessageRead -> processMessageReadPushNotification(decryptedNotification)
|
||||
@@ -106,3 +108,12 @@ internal class ProcessPushNotificationDataWorker @AssistedInject constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun LocalPushNotification.typeName(): String = when (this) {
|
||||
is LocalPushNotification.Message.MessageRead -> "MessageRead"
|
||||
is LocalPushNotification.Message.NewMessage -> "NewMessage"
|
||||
is LocalPushNotification.Message.UnsupportedMessageAction ->
|
||||
"UnsupportedMessageAction"
|
||||
|
||||
is LocalPushNotification.Login -> "Login"
|
||||
}
|
||||
|
||||
+34
@@ -66,6 +66,8 @@ internal class PMFirebaseMessagingService : FirebaseMessagingService() {
|
||||
val uid = remoteMessage.data["UID"]
|
||||
val encryptedMessage = remoteMessage.data["encryptedMessage"]
|
||||
|
||||
logPriorityDiagnostics(remoteMessage, uid)
|
||||
|
||||
if (uid != null && encryptedMessage != null) {
|
||||
Timber.d("Notification: Push message received for session id=%s", uid)
|
||||
appScope.launch { processPushNotificationMessage(SessionId(uid), encryptedMessage) }
|
||||
@@ -77,4 +79,36 @@ internal class PMFirebaseMessagingService : FirebaseMessagingService() {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDeletedMessages() {
|
||||
super.onDeletedMessages()
|
||||
Timber.w("Notification: FCM deleted some pending messages!")
|
||||
}
|
||||
|
||||
private fun logPriorityDiagnostics(remoteMessage: RemoteMessage, uid: String?) {
|
||||
val messageId = remoteMessage.messageId
|
||||
val priority = remoteMessage.priority
|
||||
val originalPriority = remoteMessage.originalPriority
|
||||
|
||||
val isPriorityDowngraded =
|
||||
originalPriority == RemoteMessage.PRIORITY_HIGH &&
|
||||
priority != RemoteMessage.PRIORITY_HIGH
|
||||
|
||||
if (isPriorityDowngraded) {
|
||||
Timber.w(
|
||||
"Notification: priority downgraded HIGH to %s messageId=%s uid=%s",
|
||||
priorityToString(priority),
|
||||
messageId,
|
||||
uid
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun priorityToString(priority: Int): String {
|
||||
return when (priority) {
|
||||
RemoteMessage.PRIORITY_HIGH -> "HIGH"
|
||||
RemoteMessage.PRIORITY_NORMAL -> "NORMAL"
|
||||
else -> "UNKNOWN"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user