diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java
index 93df781fc..5f294855f 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java
@@ -35,6 +35,8 @@ import android.media.session.MediaSession;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
+import android.os.Process;
+import android.os.UserHandle;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
@@ -280,6 +282,13 @@ public class NotificationListener extends NotificationListenerService {
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
final Prefs prefs = GBApplication.getPrefs();
+
+ final boolean ignoreWorkProfile = prefs.getBoolean("notifications_ignore_work_profile", false);
+ if (ignoreWorkProfile && isWorkProfile(sbn)) {
+ LOG.debug("Ignoring notification from work profile");
+ return;
+ }
+
final boolean mediaIgnoresAppList = prefs.getBoolean("notification_media_ignores_application_list", false);
// If media notifications ignore app list, check them before
@@ -717,6 +726,13 @@ public class NotificationListener extends NotificationListenerService {
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
final Prefs prefs = GBApplication.getPrefs();
+
+ final boolean ignoreWorkProfile = prefs.getBoolean("notifications_ignore_work_profile", false);
+ if (ignoreWorkProfile && isWorkProfile(sbn)) {
+ LOG.debug("Ignoring notification removal from work profile");
+ return;
+ }
+
final boolean mediaIgnoresAppList = prefs.getBoolean("notification_media_ignores_application_list", false);
// If media notifications ignore app list, check them before
@@ -885,6 +901,11 @@ public class NotificationListener extends NotificationListenerService {
return false;
}
+ private boolean isWorkProfile(StatusBarNotification sbn) {
+ final UserHandle currentUser = Process.myUserHandle();
+ return !sbn.getUser().equals(currentUser);
+ }
+
private boolean shouldIgnoreNotification(StatusBarNotification sbn, boolean remove) {
Notification notification = sbn.getNotification();
String source = sbn.getPackageName();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 51bdab235..897cf8140 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -253,6 +253,8 @@
…also when screen is on
Ignore low priority notifications
Do not send low and minimum priority notifications to the watch
+ Ignore work profile notifications
+ Do not send notifications from apps in the work profile to the watch
Prefer long notification text
If available, send the long notification text to the device
Cache while out of range
diff --git a/app/src/main/res/xml/notifications_preferences.xml b/app/src/main/res/xml/notifications_preferences.xml
index 396f2e40d..b775f9a19 100644
--- a/app/src/main/res/xml/notifications_preferences.xml
+++ b/app/src/main/res/xml/notifications_preferences.xml
@@ -30,6 +30,14 @@
android:title="@string/pref_title_notifications_ignore_low_priority"
app:iconSpaceReserved="false" />
+
+