Allow notification filtering per listener.

Test: atest
Bug: 173052211
Change-Id: I54c740e9755f18339c59aad4f1f5aecd8c734892
This commit is contained in:
Julia Reynolds
2021-01-05 16:54:54 -05:00
parent 0fd2a2008a
commit eb2b36a5e2
7 changed files with 355 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.notification.ConversationChannelWrapper;
import android.service.notification.NotificationListenerFilter;
import android.text.format.DateUtils;
import android.util.IconDrawableFactory;
import android.util.Log;
@@ -593,6 +594,32 @@ public class NotificationBackend {
}
}
public NotificationListenerFilter getListenerFilter(ComponentName cn, int userId) {
try {
return sINM.getListenerFilter(cn, userId);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
}
return new NotificationListenerFilter();
}
public void setListenerFilter(ComponentName cn, int userId, NotificationListenerFilter nlf) {
try {
sINM.setListenerFilter(cn, userId, nlf);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
}
}
public boolean isNotificationListenerAccessGranted(ComponentName cn) {
try {
return sINM.isNotificationListenerAccessGranted(cn);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
}
return false;
}
/**
* NotificationsSentState contains how often an app sends notifications and how recently it sent
* one.