mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Ignore notifications from suspended apps (#6082)
This commit is contained in:
@@ -84,6 +84,7 @@
|
|||||||
* Huawei: Fix crash on sync for some devices
|
* Huawei: Fix crash on sync for some devices
|
||||||
* Huawei: Fix watchface installation on some devices
|
* Huawei: Fix watchface installation on some devices
|
||||||
* Huawei: Improve workout sync error handling
|
* Huawei: Improve workout sync error handling
|
||||||
|
* Ignore notifications from suspended apps
|
||||||
* Improve battery notifications
|
* Improve battery notifications
|
||||||
* Include awake-sleep duration in sleep sessions
|
* Include awake-sleep duration in sleep sessions
|
||||||
* Intent API: Add Intent to change global settings
|
* Intent API: Add Intent to change global settings
|
||||||
|
|||||||
+17
-2
@@ -65,7 +65,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -383,6 +382,21 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
if (rankingMap.getRanking(sbn.getKey(), ranking)) {
|
if (rankingMap.getRanking(sbn.getKey(), ranking)) {
|
||||||
if (!ranking.matchesInterruptionFilter()) dndSuppressed = 1;
|
if (!ranking.matchesInterruptionFilter()) dndSuppressed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
// Digital Wellbeing app pause and similar restrictions can suppress notifications
|
||||||
|
// changing the interruption filter, but the app will be marked as suspended
|
||||||
|
if (ranking.isSuspended()) {
|
||||||
|
LOG.debug("Ignoring notification - app is suspended");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If importance is none, it should also not even show up
|
||||||
|
if (ranking.getImportance() == NotificationManager.IMPORTANCE_NONE) {
|
||||||
|
LOG.debug("Ignoring notification - importance is NONE");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.getBoolean("notification_filter", false) && dndSuppressed == 1) {
|
if (prefs.getBoolean("notification_filter", false) && dndSuppressed == 1) {
|
||||||
@@ -482,7 +496,7 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
LOG.info(
|
LOG.info(
|
||||||
"Processing notification {}, age: {}, source: {}, flags: {}",
|
"Processing notification {}, age: {}, source: {}, flags: {}",
|
||||||
notificationSpec.getId(),
|
notificationSpec.getId(),
|
||||||
(System.currentTimeMillis() - notification.when) ,
|
(System.currentTimeMillis() - notification.when),
|
||||||
source,
|
source,
|
||||||
notification.flags
|
notification.flags
|
||||||
);
|
);
|
||||||
@@ -1112,6 +1126,7 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
this.notificationPictureCacheDirectory = new File(cacheDir, "notification-pictures");
|
this.notificationPictureCacheDirectory = new File(cacheDir, "notification-pictures");
|
||||||
this.notificationPictureCacheDirectory.mkdir();
|
this.notificationPictureCacheDirectory.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logNotification(StatusBarNotification sbn, boolean posted) {
|
private void logNotification(StatusBarNotification sbn, boolean posted) {
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Notification {} {}: packageName={}, when={}, priority={}, category={}",
|
"Notification {} {}: packageName={}, when={}, priority={}, category={}",
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
<change>Huawei: Fix crash on sync for some devices</change>
|
<change>Huawei: Fix crash on sync for some devices</change>
|
||||||
<change>Huawei: Fix watchface installation on some devices</change>
|
<change>Huawei: Fix watchface installation on some devices</change>
|
||||||
<change>Huawei: Improve workout sync error handling</change>
|
<change>Huawei: Improve workout sync error handling</change>
|
||||||
|
<change>Ignore notifications from suspended apps</change>
|
||||||
<change>Improve battery notifications</change>
|
<change>Improve battery notifications</change>
|
||||||
<change>Include awake-sleep duration in sleep sessions</change>
|
<change>Include awake-sleep duration in sleep sessions</change>
|
||||||
<change>Intent API: Add Intent to change global settings</change>
|
<change>Intent API: Add Intent to change global settings</change>
|
||||||
|
|||||||
Reference in New Issue
Block a user