1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-09 07:01:33 +02:00

Allow WeChat notifications

It seems WeChat always mark its notifications as LocalOnly. The reason
may be to avoid double notifications when using Android Wear watches,
since WeChat has a standalone Android Wear app.

Do not ignore WeChat notifications even if they're marked as LocalOnly.
This commit is contained in:
Zhong Jianxin 2017-08-16 09:58:00 +08:00 committed by Andreas Shimokawa
parent 7b3e929cd4
commit 2f443ad419

View File

@ -394,7 +394,7 @@ public class NotificationListener extends NotificationListenerService {
}
return shouldIgnoreSource(sbn.getPackageName()) || shouldIgnoreNotification(
sbn.getNotification());
sbn.getNotification(), sbn.getPackageName());
}
@ -432,15 +432,18 @@ public class NotificationListener extends NotificationListenerService {
return false;
}
private boolean shouldIgnoreNotification(Notification notification) {
private boolean shouldIgnoreNotification(Notification notification, String source) {
MediaSessionCompat.Token mediaSession = NotificationCompat.getMediaSession(notification);
//try to handle media session notifications
if (mediaSession != null && handleMediaSessionNotification(mediaSession))
return true;
NotificationType type = AppNotificationType.getInstance().get(source);
//ignore notifications marked as LocalOnly https://developer.android.com/reference/android/app/Notification.html#FLAG_LOCAL_ONLY
if (NotificationCompat.getLocalOnly(notification))
if (NotificationCompat.getLocalOnly(notification) &&
//WeChat always marks its notifications as LocalOnly, do not ignore them
type != NotificationType.WECHAT)
return true;
Prefs prefs = GBApplication.getPrefs();