Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/mumla.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/lublin/mumla/service/MumlaConnectionNotification.java')
-rw-r--r--app/src/main/java/se/lublin/mumla/service/MumlaConnectionNotification.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/src/main/java/se/lublin/mumla/service/MumlaConnectionNotification.java b/app/src/main/java/se/lublin/mumla/service/MumlaConnectionNotification.java
index 46834ec..64f180f 100644
--- a/app/src/main/java/se/lublin/mumla/service/MumlaConnectionNotification.java
+++ b/app/src/main/java/se/lublin/mumla/service/MumlaConnectionNotification.java
@@ -19,6 +19,8 @@ package se.lublin.mumla.service;
import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
+import static android.content.Context.RECEIVER_NOT_EXPORTED;
+import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -29,6 +31,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ServiceInfo;
import android.os.Build;
import androidx.core.app.NotificationCompat;
@@ -109,7 +112,11 @@ public class MumlaConnectionNotification {
filter.addAction(BROADCAST_MUTE);
filter.addAction(BROADCAST_OVERLAY);
try {
- mService.registerReceiver(mNotificationReceiver, filter);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ mService.registerReceiver(mNotificationReceiver, filter, RECEIVER_NOT_EXPORTED);
+ } else {
+ mService.registerReceiver(mNotificationReceiver, filter);
+ }
} catch (IllegalArgumentException e) {
// Thrown if receiver is already registered.
e.printStackTrace();
@@ -181,7 +188,11 @@ public class MumlaConnectionNotification {
builder.setContentIntent(pendingIntent);
Notification notification = builder.build();
- mService.startForeground(NOTIFICATION_ID, notification);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ mService.startForeground(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_MICROPHONE);
+ } else {
+ mService.startForeground(NOTIFICATION_ID, notification);
+ }
return notification;
}