Disable notification service on Android O
This commit is contained in:
parent
342ab8c41a
commit
926712a704
4 changed files with 26 additions and 7 deletions
|
@ -93,6 +93,7 @@
|
||||||
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
|
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
|
||||||
<bool name="enable_call_notification">true</bool>
|
<bool name="enable_call_notification">true</bool>
|
||||||
<bool name="kill_service_with_task_manager">true</bool>
|
<bool name="kill_service_with_task_manager">true</bool>
|
||||||
|
<string name="notification_service_channel_id">linphone_notification_service_id</string>
|
||||||
<string name="notification_channel_id">linphone_notification_id</string>
|
<string name="notification_channel_id">linphone_notification_id</string>
|
||||||
<integer name="notification_ms_on">1000</integer>
|
<integer name="notification_ms_on">1000</integer>
|
||||||
<integer name="notification_ms_off">7000</integer>
|
<integer name="notification_ms_off">7000</integer>
|
||||||
|
|
|
@ -485,5 +485,6 @@
|
||||||
<string name="content_description_call_options">Call options</string>
|
<string name="content_description_call_options">Call options</string>
|
||||||
<string name="content_description_audio_route">Audio route</string>
|
<string name="content_description_audio_route">Audio route</string>
|
||||||
<string name="content_description_exit_conference">Exit conference</string>
|
<string name="content_description_exit_conference">Exit conference</string>
|
||||||
|
<string name="content_title_notification_service">Linphone Service</string>
|
||||||
<string name="content_title_notification">Linphone Notification</string>
|
<string name="content_title_notification">Linphone Notification</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -307,6 +307,12 @@ public final class LinphoneService extends Service {
|
||||||
dumpDeviceInformation();
|
dumpDeviceInformation();
|
||||||
dumpInstalledLinphoneInformation();
|
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 = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
mNM.cancel(INCALL_NOTIF_ID); // in case of crash the icon is not removed
|
mNM.cancel(INCALL_NOTIF_ID); // in case of crash the icon is not removed
|
||||||
Compatibility.CreateChannel(this);
|
Compatibility.CreateChannel(this);
|
||||||
|
@ -393,7 +399,7 @@ public final class LinphoneService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message) {
|
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);
|
sendNotification(IC_LEVEL_ORANGE, R.string.notification_started);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.media.AudioAttributes;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
@ -37,12 +38,22 @@ public class ApiTwentySixPlus {
|
||||||
public static void CreateChannel(Context context) {
|
public static void CreateChannel(Context context) {
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
String id = context.getString(R.string.notification_channel_id);
|
// Create service notification channel
|
||||||
CharSequence name = context.getString(R.string.content_title_notification);
|
String id = context.getString(R.string.notification_service_channel_id);
|
||||||
String description = context.getString(R.string.content_title_notification);
|
CharSequence name = context.getString(R.string.content_title_notification_service);
|
||||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
String description = context.getString(R.string.content_title_notification_service);
|
||||||
|
int importance = NotificationManager.IMPORTANCE_NONE;
|
||||||
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
|
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
|
||||||
mChannel.setDescription(description);
|
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.enableLights(true);
|
||||||
mChannel.setLightColor(context.getColor(R.color.notification_color_led));
|
mChannel.setLightColor(context.getColor(R.color.notification_color_led));
|
||||||
mChannel.enableLights(true);
|
mChannel.enableLights(true);
|
||||||
|
@ -103,7 +114,7 @@ public class ApiTwentySixPlus {
|
||||||
Notification notif;
|
Notification notif;
|
||||||
|
|
||||||
if (largeIcon != null) {
|
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)
|
.setContentTitle(title)
|
||||||
.setContentText(message)
|
.setContentText(message)
|
||||||
.setSmallIcon(icon, level)
|
.setSmallIcon(icon, level)
|
||||||
|
@ -114,7 +125,7 @@ public class ApiTwentySixPlus {
|
||||||
.setPriority(priority)
|
.setPriority(priority)
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} 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)
|
.setContentTitle(title)
|
||||||
.setContentText(message)
|
.setContentText(message)
|
||||||
.setSmallIcon(icon, level)
|
.setSmallIcon(icon, level)
|
||||||
|
|
Loading…
Reference in a new issue