浏览代码

revert calculation of delayed delivery time

this didn't make sense because time between firebase and devices is not synchronized, so the results were useless.

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 2 年之前
父节点
当前提交
ca145d170c

+ 0 - 1
app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt

@@ -65,7 +65,6 @@ class NCFirebaseMessagingService : FirebaseMessagingService() {
             val messageData = Data.Builder()
             val messageData = Data.Builder()
                 .putString(BundleKeys.KEY_NOTIFICATION_SUBJECT, subject)
                 .putString(BundleKeys.KEY_NOTIFICATION_SUBJECT, subject)
                 .putString(BundleKeys.KEY_NOTIFICATION_SIGNATURE, signature)
                 .putString(BundleKeys.KEY_NOTIFICATION_SIGNATURE, signature)
-                .putLong(BundleKeys.KEY_NOTIFICATION_SENT_TIME, remoteMessage.sentTime)
                 .build()
                 .build()
             val notificationWork =
             val notificationWork =
                 OneTimeWorkRequest.Builder(NotificationWorker::class.java).setInputData(messageData)
                 OneTimeWorkRequest.Builder(NotificationWorker::class.java).setInputData(messageData)

+ 5 - 31
app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt

@@ -53,7 +53,6 @@ import androidx.work.Worker
 import androidx.work.WorkerParameters
 import androidx.work.WorkerParameters
 import autodagger.AutoInjector
 import autodagger.AutoInjector
 import com.bluelinelabs.logansquare.LoganSquare
 import com.bluelinelabs.logansquare.LoganSquare
-import com.nextcloud.talk.BuildConfig
 import com.nextcloud.talk.R
 import com.nextcloud.talk.R
 import com.nextcloud.talk.activities.CallNotificationActivity
 import com.nextcloud.talk.activities.CallNotificationActivity
 import com.nextcloud.talk.activities.MainActivity
 import com.nextcloud.talk.activities.MainActivity
@@ -136,14 +135,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
     private var conversationType: String? = "one2one"
     private var conversationType: String? = "one2one"
     private var muteCall = false
     private var muteCall = false
     private var importantConversation = false
     private var importantConversation = false
-    private var deliveryDelayTime: Long = 0
     private lateinit var notificationManager: NotificationManagerCompat
     private lateinit var notificationManager: NotificationManagerCompat
 
 
     override fun doWork(): Result {
     override fun doWork(): Result {
         sharedApplication!!.componentApplication.inject(this)
         sharedApplication!!.componentApplication.inject(this)
         context = applicationContext
         context = applicationContext
 
 
-        calculateDeliveryDelayTime(inputData)
         initDecryptedData(inputData)
         initDecryptedData(inputData)
         initNcApiAndCredentials()
         initNcApiAndCredentials()
 
 
@@ -247,9 +244,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
                 .setSubText(baseUrl)
                 .setSubText(baseUrl)
                 .setShowWhen(true)
                 .setShowWhen(true)
                 .setWhen(pushMessage.timestamp)
                 .setWhen(pushMessage.timestamp)
-                .setContentTitle(
-                    EmojiCompat.get().process(pushMessage.subject + getDeliveryDelayTimeForDebug())
-                )
+                .setContentTitle(EmojiCompat.get().process(pushMessage.subject))
                 .setAutoCancel(true)
                 .setAutoCancel(true)
                 .setOngoing(true)
                 .setOngoing(true)
                 .setContentIntent(fullScreenPendingIntent)
                 .setContentIntent(fullScreenPendingIntent)
@@ -263,20 +258,6 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
         checkIfCallIsActive(signatureVerification, pushMessage)
         checkIfCallIsActive(signatureVerification, pushMessage)
     }
     }
 
 
-    /**
-     * Calculates the time between the sent time (from firebase) and the received time on the device.
-     * 'deliveryDelayTime' is displayed in debug mode right after the notification message.
-     * A huge delay means that there might be something wrong on device side.
-     */
-    private fun calculateDeliveryDelayTime(inputData: Data) {
-        val messageSentTime = inputData.getLong(BundleKeys.KEY_NOTIFICATION_SENT_TIME, 0)
-        deliveryDelayTime = if (messageSentTime == 0L) {
-            0
-        } else {
-            System.currentTimeMillis() - messageSentTime
-        }
-    }
-
     private fun initNcApiAndCredentials() {
     private fun initNcApiAndCredentials() {
         credentials = ApiUtils.getCredentials(
         credentials = ApiUtils.getCredentials(
             signatureVerification.user!!.username,
             signatureVerification.user!!.username,
@@ -456,12 +437,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
             .setAutoCancel(true)
             .setAutoCancel(true)
         if (!TextUtils.isEmpty(pushMessage.subject)) {
         if (!TextUtils.isEmpty(pushMessage.subject)) {
             notificationBuilder.setContentTitle(
             notificationBuilder.setContentTitle(
-                EmojiCompat.get().process(pushMessage.subject + getDeliveryDelayTimeForDebug())
+                EmojiCompat.get().process(pushMessage.subject)
             )
             )
         }
         }
         if (!TextUtils.isEmpty(pushMessage.text)) {
         if (!TextUtils.isEmpty(pushMessage.text)) {
             notificationBuilder.setContentText(
             notificationBuilder.setContentText(
-                EmojiCompat.get().process(pushMessage.text!! + getDeliveryDelayTimeForDebug())
+                EmojiCompat.get().process(pushMessage.text!!)
             )
             )
         }
         }
         if (Build.VERSION.SDK_INT >= 23) {
         if (Build.VERSION.SDK_INT >= 23) {
@@ -625,17 +606,10 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
                 )
                 )
             }
             }
         )
         )
-        newStyle.addMessage(pushMessage.text + getDeliveryDelayTimeForDebug(), pushMessage.timestamp, person)
+        newStyle.addMessage(pushMessage.text, pushMessage.timestamp, person)
         return newStyle
         return newStyle
     }
     }
 
 
-    private fun getDeliveryDelayTimeForDebug(): String {
-        if (BuildConfig.DEBUG) {
-            return " ($deliveryDelayTime ms delay)"
-        }
-        return ""
-    }
-
     @Throws(NumberFormatException::class)
     @Throws(NumberFormatException::class)
     private fun parseMessageId(objectId: String): Int {
     private fun parseMessageId(objectId: String): Int {
         val objectIdParts = objectId.split("/".toRegex()).toTypedArray()
         val objectIdParts = objectId.split("/".toRegex()).toTypedArray()
@@ -801,7 +775,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
                             String.format(
                             String.format(
                                 context!!.resources.getString(R.string.nc_missed_call),
                                 context!!.resources.getString(R.string.nc_missed_call),
                                 currentConversation!!.displayName
                                 currentConversation!!.displayName
-                            ) + getDeliveryDelayTimeForDebug()
+                            )
                         )
                         )
                         .setSmallIcon(R.drawable.ic_baseline_phone_missed_24)
                         .setSmallIcon(R.drawable.ic_baseline_phone_missed_24)
                         .setOngoing(false)
                         .setOngoing(false)

+ 0 - 1
app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt

@@ -48,7 +48,6 @@ object BundleKeys {
     const val KEY_MODIFIED_BASE_URL = "KEY_MODIFIED_BASE_URL"
     const val KEY_MODIFIED_BASE_URL = "KEY_MODIFIED_BASE_URL"
     const val KEY_NOTIFICATION_SUBJECT = "KEY_NOTIFICATION_SUBJECT"
     const val KEY_NOTIFICATION_SUBJECT = "KEY_NOTIFICATION_SUBJECT"
     const val KEY_NOTIFICATION_SIGNATURE = "KEY_NOTIFICATION_SIGNATURE"
     const val KEY_NOTIFICATION_SIGNATURE = "KEY_NOTIFICATION_SIGNATURE"
-    const val KEY_NOTIFICATION_SENT_TIME = "KEY_NOTIFICATION_SENT_TIME"
     const val KEY_INTERNAL_USER_ID = "KEY_INTERNAL_USER_ID"
     const val KEY_INTERNAL_USER_ID = "KEY_INTERNAL_USER_ID"
     const val KEY_CONVERSATION_TYPE = "KEY_CONVERSATION_TYPE"
     const val KEY_CONVERSATION_TYPE = "KEY_CONVERSATION_TYPE"
     const val KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS"
     const val KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS"