// determinate Source App Name ("Label")
@Override
    public void onNotificationPosted(StatusBarNotification sbn) {
        Prefs prefs = GBApplication.getPrefs();
        if (GBApplication.isRunningLollipopOrLater()) {
            if ("call".equals(sbn.getNotification().category) && prefs.getBoolean("notification_support_voip_calls", false)) {
                handleCallNotification(sbn);
                return;
            }
        }
        if (shouldIgnore(sbn)) {
            LOG.info("Ignore notification");
            return;
        }
        switch (GBApplication.getGrantedInterruptionFilter()) {
            case NotificationManager.INTERRUPTION_FILTER_ALL:
                break;
            case NotificationManager.INTERRUPTION_FILTER_ALARMS:
            case NotificationManager.INTERRUPTION_FILTER_NONE:
                return;
            case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
                // FIXME: Handle Reminders and Events if they are enabled in Do Not Disturb
                return;
        }
        String source = sbn.getPackageName().toLowerCase();
        Notification notification = sbn.getNotification();
        if (notificationOldRepeatPrevention.containsKey(source)) {
            if (notification.when <= notificationOldRepeatPrevention.get(source)) {
                LOG.info("NOT processing notification, already sent newer notifications from this source.");
                return;
            }
        }
        // Ignore too frequent notifications, according to user preference
        long min_timeout = (long)prefs.getInt("notifications_timeout", 0) * 1000L;
        long cur_time = System.currentTimeMillis();
        if (notificationBurstPrevention.containsKey(source)) {
            long last_time = notificationBurstPrevention.get(source);
            if (cur_time - last_time < min_timeout) {
                LOG.info("Ignoring frequent notification, last one was " + (cur_time - last_time) + "ms ago");
                return;
            }
        }
        NotificationSpec notificationSpec = new NotificationSpec();
        // determinate Source App Name ("Label")
        String name = getAppName(source);
        if (name != null) {
            notificationSpec.sourceName = name;
        }
        boolean preferBigText = false;
        // Get the app ID that generated this notification. For now only used by pebble color, but may be more useful later.
        notificationSpec.sourceAppId = source;
        notificationSpec.type = AppNotificationType.getInstance().get(source);
        //FIXME: some quirks lookup table would be the minor evil here
        if (source.startsWith("com.fsck.k9")) {
            if (NotificationCompat.isGroupSummary(notification)) {
                LOG.info("ignore K9 group summary");
                return;
            }
            preferBigText = true;
        }
        if (notificationSpec.type == null) {
            notificationSpec.type = NotificationType.UNKNOWN;
        }
        // Get color
        notificationSpec.pebbleColor = getPebbleColorForNotification(notificationSpec);
        LOG.info("Processing notification " + notificationSpec.getId() + " age: " + (System.currentTimeMillis() - notification.when) + " from source " + source + " with flags: " + notification.flags);
        dissectNotificationTo(notification, notificationSpec, preferBigText);
        if (!checkNotificationContentForWhiteAndBlackList(sbn.getPackageName().toLowerCase(), notificationSpec.body)) {
            return;
        }
        // ignore Gadgetbridge's very own notifications, except for those from the debug screen
        if (getApplicationContext().getPackageName().equals(source)) {
            if (!getApplicationContext().getString(R.string.test_notification).equals(notificationSpec.title)) {
                return;
            }
        }
        NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(notification);
        List<NotificationCompat.Action> actions = wearableExtender.getActions();
        if (actions.size() == 0 && NotificationCompat.isGroupSummary(notification)) { //this could cause #395 to come back
            LOG.info("Not forwarding notification, FLAG_GROUP_SUMMARY is set and no wearable action present. Notification flags: " + notification.flags);
            return;
        }
        notificationSpec.attachedActions = new ArrayList<>();
        // DISMISS action
        NotificationSpec.Action dismissAction = new NotificationSpec.Action();
        dismissAction.title = "Dismiss";
        dismissAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_DISMISS;
        notificationSpec.attachedActions.add(dismissAction);
        for (NotificationCompat.Action act : actions) {
            if (act != null) {
                NotificationSpec.Action wearableAction = new NotificationSpec.Action();
                wearableAction.title = act.getTitle().toString();
                if(act.getRemoteInputs()!=null) {
                    wearableAction.type = NotificationSpec.Action.TYPE_WEARABLE_REPLY;
                } else {
                    wearableAction.type = NotificationSpec.Action.TYPE_WEARABLE_SIMPLE;
                }
                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());
            }
        }
        // OPEN action
        NotificationSpec.Action openAction = new NotificationSpec.Action();
        openAction.title = getString(R.string._pebble_watch_open_on_phone);
        openAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_OPEN;
        notificationSpec.attachedActions.add(openAction);
        // MUTE action
        NotificationSpec.Action muteAction = new NotificationSpec.Action();
        muteAction.title = getString(R.string._pebble_watch_mute);
        muteAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_MUTE;
        notificationSpec.attachedActions.add(muteAction);
        mNotificationHandleLookup.add(notificationSpec.getId(), sbn.getPostTime()); // for both DISMISS and OPEN
        mPackageLookup.add(notificationSpec.getId(), sbn.getPackageName()); // for MUTE
        notificationBurstPrevention.put(source, cur_time);
        if(0 != notification.when) {
            notificationOldRepeatPrevention.put(source, notification.when);
        }else {
            LOG.info("This app might show old/duplicate notifications. notification.when is 0 for " + source);
        }
        GBApplication.deviceService().onNotification(notificationSpec);
    }
}
NotificationSpec notificationSpec = new NotificationSpec();
// determinate Source App Name ("Label")
String name = getAppName(source);
if (name != null) {
long min_timeout = (long)prefs.getInt("notifications_timeout", 0) * 1000L;
long cur_time = System.currentTimeMillis();
if (notificationBurstPrevention.containsKey(source)) {
long last_time = notificationBurstPrevention.get(source);
if (cur_time - last_time < min_timeout) {
LOG.info("Ignoring frequent notification, last one was " + (cur_time - last_time) + "ms ago");
return;
}
}
NotificationSpec notificationSpec = new NotificationSpec();
// determinate Source App Name ("Label")
String name = getAppName(source);
if (name != null) {
notificationSpec.sourceName = name;
}
boolean preferBigText = false;
// Get the app ID that generated this notification. For now only used by pebble color, but may be more useful later.
notificationSpec.sourceAppId = source;
notificationSpec.type = AppNotificationType.getInstance().get(source);
//FIXME: some quirks lookup table would be the minor evil here
if (source.startsWith("com.fsck.k9")) {
}
String source = sbn.getPackageName().toLowerCase();
Notification notification = sbn.getNotification();
if (notificationOldRepeatPrevention.containsKey(source)) {
if (notification.when <= notificationOldRepeatPrevention.get(source)) {
LOG.info("NOT processing notification, already sent newer notifications from this source.");
return;
}
}
// Ignore too frequent notifications, according to user preference
long min_timeout = (long)prefs.getInt("notifications_timeout", 0) * 1000L;
long cur_time = System.currentTimeMillis();
if (notificationBurstPrevention.containsKey(source)) {
long last_time = notificationBurstPrevention.get(source);
if (cur_time - last_time < min_timeout) {
LOG.info("Ignoring frequent notification, last one was " + (cur_time - last_time) + "ms ago");
return;
}
}
NotificationSpec notificationSpec = new NotificationSpec();
// determinate Source App Name ("Label")
String name = getAppName(source);
if (name != null) {
notificationSpec.sourceName = name;
}
boolean preferBigText = false;
// Get the app ID that generated this notification. For now only used by pebble color, but may be more useful later.
notificationSpec.sourceAppId = source;
notificationSpec.type = AppNotificationType.getInstance().get(source);
//FIXME: some quirks lookup table would be the minor evil here
if (source.startsWith("com.fsck.k9")) {
if (NotificationCompat.isGroupSummary(notification)) {
LOG.info("ignore K9 group summary");
return;
}
preferBigText = true;
}
if (notificationSpec.type == null) {
notificationSpec.type = NotificationType.UNKNOWN;
}
// Get color