Restored behavior where baresip foregound service notification is always visible
This commit is contained in:
@@ -1468,11 +1468,13 @@ class BaresipService: Service() {
|
|||||||
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
||||||
.setCustomContentView(notificationLayout)
|
.setCustomContentView(notificationLayout)
|
||||||
if (VERSION.SDK_INT >= 31)
|
if (VERSION.SDK_INT >= 31)
|
||||||
snb.foregroundServiceBehavior = Notification.FOREGROUND_SERVICE_DEFAULT
|
snb.foregroundServiceBehavior = Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
|
val notification = snb.build()
|
||||||
|
notification.flags = notification.flags or Notification.FLAG_NO_CLEAR
|
||||||
try {
|
try {
|
||||||
if (VERSION.SDK_INT >= 29)
|
if (VERSION.SDK_INT >= 29)
|
||||||
startForeground(
|
startForeground(
|
||||||
STATUS_NOTIFICATION_ID, snb.build(),
|
STATUS_NOTIFICATION_ID, notification,
|
||||||
if (VERSION.SDK_INT >= 30) {
|
if (VERSION.SDK_INT >= 30) {
|
||||||
if (ContextCompat.checkSelfPermission(this, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED)
|
if (ContextCompat.checkSelfPermission(this, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED)
|
||||||
FOREGROUND_SERVICE_TYPE_PHONE_CALL or FOREGROUND_SERVICE_TYPE_MICROPHONE
|
FOREGROUND_SERVICE_TYPE_PHONE_CALL or FOREGROUND_SERVICE_TYPE_MICROPHONE
|
||||||
@@ -1483,7 +1485,7 @@ class BaresipService: Service() {
|
|||||||
FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
startForeground(STATUS_NOTIFICATION_ID, snb.build())
|
startForeground(STATUS_NOTIFICATION_ID, notification)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Failed to start foreground service: ${e.message}")
|
Log.e(TAG, "Failed to start foreground service: ${e.message}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user