mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 14:32:54 +01:00
Improve notification logging
- Reduce duplicated and redundant messages - Log notification priority - Add log entry for notification ignored by dnd
This commit is contained in:
parent
eb7366c7e3
commit
0c52f3d3da
@ -56,6 +56,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -262,7 +263,6 @@ public class NotificationListener extends NotificationListenerService {
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
|
||||
logNotification(sbn, true);
|
||||
LOG.debug("notificationAppListIsBlackList: " + GBApplication.getPrefs().getString("notification_list_is_blacklist","true"));
|
||||
|
||||
notificationStack.remove(sbn.getPackageName());
|
||||
notificationStack.add(sbn.getPackageName());
|
||||
@ -275,10 +275,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
// If media notifications ignore app list, check them before
|
||||
if (mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
|
||||
|
||||
if (shouldIgnoreSource(sbn)) {
|
||||
LOG.debug("Ignoring notification source");
|
||||
return;
|
||||
}
|
||||
if (shouldIgnoreSource(sbn)) return;
|
||||
|
||||
// If media notifications do NOT ignore app list, check them after
|
||||
if (!mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
|
||||
@ -293,8 +290,10 @@ public class NotificationListener extends NotificationListenerService {
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("notification_filter", false) && dndSuppressed == 1) {
|
||||
LOG.debug("Ignoring notification because of do not disturb");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category)
|
||||
&& prefs.getBoolean("notification_support_voip_calls", false)
|
||||
&& sbn.isOngoing()) {
|
||||
@ -304,7 +303,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
|
||||
if (shouldIgnoreNotification(sbn, false)) {
|
||||
if (!"com.sec.android.app.clockpackage".equals(sbn.getPackageName())) { // workaround to allow phone alarm notification
|
||||
LOG.info("Ignore notification: " + sbn.getPackageName()); // need to fix
|
||||
LOG.info("Ignoring notification: {}", sbn.getPackageName()); // need to fix
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -316,8 +315,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
if (notificationOldRepeatPreventionValue != null
|
||||
&& notification.when <= notificationOldRepeatPreventionValue
|
||||
&& !shouldIgnoreRepeatPrevention(sbn)
|
||||
)
|
||||
{
|
||||
) {
|
||||
LOG.info("NOT processing notification, already sent newer notifications from this source.");
|
||||
return;
|
||||
}
|
||||
@ -328,8 +326,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
if (notificationBurstPreventionValue != null) {
|
||||
long diff = curTime - notificationBurstPreventionValue;
|
||||
if (diff < TimeUnit.SECONDS.toNanos(prefs.getInt("notifications_timeout", 0))) {
|
||||
LOG.info("Ignoring frequent notification, last one was "
|
||||
+ TimeUnit.NANOSECONDS.toMillis(diff) + "ms ago");
|
||||
LOG.info("Ignoring frequent notification, last one was {} ms ago", TimeUnit.NANOSECONDS.toMillis(diff));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -365,7 +362,13 @@ public class NotificationListener extends NotificationListenerService {
|
||||
// Get color
|
||||
notificationSpec.pebbleColor = getPebbleColorForNotification(notificationSpec);
|
||||
|
||||
LOG.info("Processing notification " + notificationSpec.getId() + " age: " + (System.currentTimeMillis() - notification.when) + " from source " + source + " with flags: " + notification.flags);
|
||||
LOG.info(
|
||||
"Processing notification {}, age: {}, source: {}, flags: {}",
|
||||
notificationSpec.getId(),
|
||||
(System.currentTimeMillis() - notification.when) ,
|
||||
source,
|
||||
notification.flags
|
||||
);
|
||||
|
||||
boolean preferBigText = prefs.getBoolean("notification_prefer_long_text", true);
|
||||
|
||||
@ -416,7 +419,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
|
||||
notificationSpec.attachedActions.add(wearableAction);
|
||||
mActionLookup.add((notificationSpec.getId() << 4) + notificationSpec.attachedActions.size(), act);
|
||||
LOG.info("found wearable action: " + notificationSpec.attachedActions.size() + " - "+ act.getTitle() + " " + sbn.getTag());
|
||||
LOG.info("Found wearable action: {} - {} {}", notificationSpec.attachedActions.size(), act.getTitle(), sbn.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
@ -786,16 +789,14 @@ public class NotificationListener extends NotificationListenerService {
|
||||
}
|
||||
|
||||
private void logNotification(StatusBarNotification sbn, boolean posted) {
|
||||
String infoMsg = String.format(
|
||||
"Notification %d %s: %s",
|
||||
LOG.debug(
|
||||
"Notification {} {}: packageName={}, priority={}, category={}",
|
||||
sbn.getId(),
|
||||
posted ? "posted" : "removed",
|
||||
sbn.getPackageName()
|
||||
sbn.getPackageName(),
|
||||
sbn.getNotification().priority,
|
||||
sbn.getNotification().category
|
||||
);
|
||||
|
||||
infoMsg += ": " + sbn.getNotification().category;
|
||||
|
||||
LOG.debug(infoMsg);
|
||||
}
|
||||
|
||||
private void dumpExtras(Bundle bundle) {
|
||||
@ -808,7 +809,6 @@ public class NotificationListener extends NotificationListenerService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isServiceNotRunningAndShouldIgnoreNotifications() {
|
||||
/*
|
||||
* return early if DeviceCommunicationService is not running,
|
||||
@ -849,6 +849,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
source.equals("com.android.messaging") ||
|
||||
source.equals("org.smssecure.smssecure")) {
|
||||
if (!"never".equals(prefs.getString("notification_mode_sms", "when_screen_off"))) {
|
||||
LOG.info("Ignoring notification, it's an sms notification");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -911,7 +912,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
type != NotificationType.WECHAT &&
|
||||
type != NotificationType.OUTLOOK &&
|
||||
type != NotificationType.SKYPE) { //see https://github.com/Freeyourgadget/Gadgetbridge/issues/1109
|
||||
LOG.info("local only");
|
||||
LOG.info("Ignoring notification, local only");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user