Skip to content
Snippets Groups Projects
Commit 8e72429b authored by cyberta's avatar cyberta
Browse files

try to fix potential RemoteServiceException: Bad notification for startForeground

parent 55ae2eba
No related branches found
No related tags found
No related merge requests found
...@@ -203,7 +203,7 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat ...@@ -203,7 +203,7 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
blockingMessage, blockingMessage,
blockingMessage, blockingMessage,
eipStatus.getLevel(), eipStatus.getLevel(),
this null
); );
} else { } else {
stopForeground(true); stopForeground(true);
......
...@@ -128,7 +128,7 @@ public class VpnNotificationManager { ...@@ -128,7 +128,7 @@ public class VpnNotificationManager {
public void buildOpenVpnNotification(String profileName, boolean isObfuscated, String msg, public void buildOpenVpnNotification(String profileName, boolean isObfuscated, String msg,
String tickerText, ConnectionStatus status, long when, String tickerText, ConnectionStatus status, long when,
String notificationChannelNewstatusId, VpnServiceCallback vpnServiceCallback) { String channelId, VpnServiceCallback vpnServiceCallback) {
String cancelString; String cancelString;
CharSequence bigmessage = null; CharSequence bigmessage = null;
String bridgeIcon = new String(Character.toChars(0x1f309)); String bridgeIcon = new String(Character.toChars(0x1f309));
...@@ -183,7 +183,7 @@ public class VpnNotificationManager { ...@@ -183,7 +183,7 @@ public class VpnNotificationManager {
bigmessage, bigmessage,
tickerText, tickerText,
status, status,
notificationChannelNewstatusId, channelId,
PRIORITY_DEFAULT, PRIORITY_DEFAULT,
when, when,
contentIntent, contentIntent,
...@@ -245,9 +245,9 @@ public class VpnNotificationManager { ...@@ -245,9 +245,9 @@ public class VpnNotificationManager {
} }
private void buildVpnNotification(String title, String message, CharSequence bigMessage, String tickerText, private void buildVpnNotification(String title, String message, CharSequence bigMessage, String tickerText,
ConnectionStatus status, String notificationChannelNewstatusId, int priority, ConnectionStatus status, String channelId, int priority,
long when, PendingIntent contentIntent, NotificationCompat.Action notificationAction, VpnServiceCallback vpnServiceCallback) { long when, PendingIntent contentIntent, NotificationCompat.Action notificationAction, VpnServiceCallback vpnServiceCallback) {
NotificationCompat.Builder nCompatBuilder = new NotificationCompat.Builder(context, notificationChannelNewstatusId); NotificationCompat.Builder nCompatBuilder = new NotificationCompat.Builder(context, channelId);
int icon = getIconByConnectionStatus(status); int icon = getIconByConnectionStatus(status);
nCompatBuilder.setStyle(new NotificationCompat.BigTextStyle(). nCompatBuilder.setStyle(new NotificationCompat.BigTextStyle().
...@@ -271,11 +271,13 @@ public class VpnNotificationManager { ...@@ -271,11 +271,13 @@ public class VpnNotificationManager {
} }
Notification notification = nCompatBuilder.build(); Notification notification = nCompatBuilder.build();
int notificationId = notificationChannelNewstatusId.hashCode(); int notificationId = channelId.hashCode();
compatNotificationManager.notify(notificationId, notification);
if (vpnServiceCallback != null) { if (vpnServiceCallback != null) {
vpnServiceCallback.onNotificationBuild(notificationId, notification); vpnServiceCallback.onNotificationBuild(notificationId, notification);
} else {
compatNotificationManager.notify(notificationId, notification);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment