diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml index 891c6eb1e..1879eedbe 100644 --- a/res/values/non_localizable_custom.xml +++ b/res/values/non_localizable_custom.xml @@ -93,6 +93,7 @@ linphone-android@belledonne-communications.com true true + linphone_notification_service_id linphone_notification_id 1000 7000 diff --git a/res/values/strings.xml b/res/values/strings.xml index 37123420a..6ba093432 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -485,5 +485,6 @@ Call options Audio route Exit conference + Linphone Service Linphone Notification diff --git a/src/android/org/linphone/LinphoneService.java b/src/android/org/linphone/LinphoneService.java index 3ffadd427..3217c0b07 100644 --- a/src/android/org/linphone/LinphoneService.java +++ b/src/android/org/linphone/LinphoneService.java @@ -307,6 +307,12 @@ public final class LinphoneService extends Service { dumpDeviceInformation(); dumpInstalledLinphoneInformation(); + //Disable service notification for Android O + if ((Version.sdkAboveOrEqual(Version.API26_O_80))) { + LinphonePreferences.instance().setServiceNotificationVisibility(false); + mDisableRegistrationStatus = true; + } + mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNM.cancel(INCALL_NOTIF_ID); // in case of crash the icon is not removed Compatibility.CreateChannel(this); @@ -393,7 +399,7 @@ public final class LinphoneService extends Service { @Override public void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message) { - if (state == GlobalState.GlobalOn && displayServiceNotification()) { + if (!mDisableRegistrationStatus && state == GlobalState.GlobalOn && displayServiceNotification()) { sendNotification(IC_LEVEL_ORANGE, R.string.notification_started); } } diff --git a/src/android/org/linphone/compatibility/ApiTwentySixPlus.java b/src/android/org/linphone/compatibility/ApiTwentySixPlus.java index b1111c6d6..2360bd0c6 100644 --- a/src/android/org/linphone/compatibility/ApiTwentySixPlus.java +++ b/src/android/org/linphone/compatibility/ApiTwentySixPlus.java @@ -8,6 +8,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.graphics.Bitmap; +import android.media.AudioAttributes; import android.view.ViewTreeObserver; import org.linphone.R; @@ -37,12 +38,22 @@ public class ApiTwentySixPlus { public static void CreateChannel(Context context) { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - String id = context.getString(R.string.notification_channel_id); - CharSequence name = context.getString(R.string.content_title_notification); - String description = context.getString(R.string.content_title_notification); - int importance = NotificationManager.IMPORTANCE_DEFAULT; + // Create service notification channel + String id = context.getString(R.string.notification_service_channel_id); + CharSequence name = context.getString(R.string.content_title_notification_service); + String description = context.getString(R.string.content_title_notification_service); + int importance = NotificationManager.IMPORTANCE_NONE; NotificationChannel mChannel = new NotificationChannel(id, name, importance); mChannel.setDescription(description); + mChannel.enableVibration(false); + notificationManager.createNotificationChannel(mChannel); + // Create message/call notification channel + id = context.getString(R.string.notification_channel_id); + name = context.getString(R.string.content_title_notification); + description = context.getString(R.string.content_title_notification); + importance = NotificationManager.IMPORTANCE_HIGH; + mChannel = new NotificationChannel(id, name, importance); + mChannel.setDescription(description); mChannel.enableLights(true); mChannel.setLightColor(context.getColor(R.color.notification_color_led)); mChannel.enableLights(true); @@ -103,7 +114,7 @@ public class ApiTwentySixPlus { Notification notif; if (largeIcon != null) { - notif = new Notification.Builder(context, context.getString(R.string.notification_channel_id)) + notif = new Notification.Builder(context, context.getString(R.string.notification_service_channel_id)) .setContentTitle(title) .setContentText(message) .setSmallIcon(icon, level) @@ -114,7 +125,7 @@ public class ApiTwentySixPlus { .setPriority(priority) .build(); } else { - notif = new Notification.Builder(context, context.getString(R.string.notification_channel_id)) + notif = new Notification.Builder(context, context.getString(R.string.notification_service_channel_id)) .setContentTitle(title) .setContentText(message) .setSmallIcon(icon, level)