CA-8 | Crashlytics | TimerNotificationService.playTimer (#12310)

This commit is contained in:
Shivam Goyal
2024-09-02 22:43:01 +05:30
committed by GitHub
parent 0c8d805250
commit 22360d62bb
2 changed files with 21 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
<!--
~
~ * Copyright © 2019-2022 by Navi Technologies Limited
~ * Copyright © 2019-2024 by Navi Technologies Limited
~ * All rights reserved. Strictly confidential
~
-->
@@ -11,7 +11,9 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="androidx.security.ktx" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
<queries>
<intent>
@@ -54,8 +56,9 @@
android:name=".pushnotification.NotificationCancelBroadcastReceiver"
android:exported="false" />
<service android:name=".pushnotification.TimerNotificationService"
android:foregroundServiceType="specialUse" />
<service
android:name=".pushnotification.TimerNotificationService"
android:foregroundServiceType="remoteMessaging" />
</application>
</manifest>

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2023 by Navi Technologies Limited
* * Copyright © 2023-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -11,6 +11,8 @@ import android.app.NotificationManager
import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo
import android.os.Build
import android.os.Bundle
import android.os.CountDownTimer
import android.os.IBinder
@@ -77,10 +79,18 @@ class TimerNotificationService : Service() {
this.setTime = setTime
secondsRemaining = setTime
bundle.putLong(TIME_LEFT, setTime)
startForeground(
foreGroundNotificationId,
TimerNotificationRenderer.createNotification(this, bundle)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(
foreGroundNotificationId,
TimerNotificationRenderer.createNotification(this, bundle),
ServiceInfo.FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING
)
} else {
startForeground(
foreGroundNotificationId,
TimerNotificationRenderer.createNotification(this, bundle)
)
}
TimerNotificationRenderer.updateTimeLeft(this, bundle)
timer =