Skip to content

Commit ee596ac

Browse files
committed
Show call notification only on Android APIs prior to 31
Call notifications are not needed for 31+ APIs because of built in Android privacy indicators. As a result, there is no need to start NotificationRemovalService on 31+ APIs. So the following crash should not happen: "Not allowed to start service Intent ... NotificationRemovalService ... app is in background" anymore. MOB-3358
1 parent 53b926b commit ee596ac

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

widgetssdk/src/main/java/com/glia/widgets/core/notification/device/NotificationManager.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ internal class NotificationManager(private val applicationContext: Application)
5858
}
5959

6060
override fun showAudioCallNotification() {
61+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
62+
// Android APIs 31+ have built in privacy indicators for microphone and camera
63+
// See https://source.android.com/docs/core/permissions/privacy-indicators
64+
return
65+
}
6166
if (areNotificationsEnabledForChannel(NotificationFactory.NOTIFICATION_CALL_CHANNEL_ID)) {
6267
notificationManager.notify(
6368
NotificationFactory.CALL_NOTIFICATION_ID,
@@ -67,6 +72,11 @@ internal class NotificationManager(private val applicationContext: Application)
6772
}
6873

6974
override fun showVideoCallNotification(isTwoWayVideo: Boolean, hasAudio: Boolean) {
75+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
76+
// Android APIs 31+ have built in privacy indicators for microphone and camera
77+
// See https://source.android.com/docs/core/permissions/privacy-indicators
78+
return
79+
}
7080
if (areNotificationsEnabledForChannel(NotificationFactory.NOTIFICATION_CALL_CHANNEL_ID)) {
7181
notificationManager.notify(
7282
NotificationFactory.CALL_NOTIFICATION_ID,

widgetssdk/src/main/java/com/glia/widgets/di/Dependencies.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import androidx.core.content.ContextCompat;
1010
import androidx.lifecycle.Lifecycle;
1111

12+
import com.glia.androidsdk.Glia;
1213
import com.glia.widgets.GliaWidgetsConfig;
1314
import com.glia.widgets.StringProvider;
1415
import com.glia.widgets.StringProviderImpl;
@@ -251,7 +252,9 @@ private static void initApplicationLifecycleObserver(
251252
lifecycleManager.addObserver((source, event) -> {
252253
if (event == Lifecycle.Event.ON_STOP) {
253254
chatBubbleController.onApplicationStop();
254-
notificationManager.startNotificationRemovalService();
255+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S && Glia.isInitialized()) {
256+
notificationManager.startNotificationRemovalService();
257+
}
255258
} else if (event == Lifecycle.Event.ON_DESTROY) {
256259
chatBubbleController.onDestroy();
257260
}

0 commit comments

Comments
 (0)