mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 03:46:00 +01:00
Debug: delete notification channels
This commit is contained in:
@@ -36,6 +36,10 @@ import androidx.annotation.RequiresApi;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class NotificationHelper {
|
||||
static final int NOTIFICATION_SYNCHRONIZE = 100;
|
||||
static final int NOTIFICATION_SEND = 200;
|
||||
@@ -43,6 +47,17 @@ class NotificationHelper {
|
||||
static final int NOTIFICATION_UPDATE = 400;
|
||||
static final int NOTIFICATION_TAGGED = 500;
|
||||
|
||||
private static final List<String> PERSISTENT_IDS = Collections.unmodifiableList(Arrays.asList(
|
||||
"service",
|
||||
"send",
|
||||
"notification",
|
||||
"progress",
|
||||
"update",
|
||||
"warning",
|
||||
"error",
|
||||
"alerts"
|
||||
));
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static void createNotificationChannels(Context context) {
|
||||
// https://issuetracker.google.com/issues/65108694
|
||||
@@ -134,6 +149,18 @@ class NotificationHelper {
|
||||
nm.createNotificationChannelGroup(group);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static void clear(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
for (NotificationChannel channel : nm.getNotificationChannels()) {
|
||||
String id = channel.getId();
|
||||
if (!PERSISTENT_IDS.contains(id)) {
|
||||
EntityLog.log(context, "Deleting channel=" + id);
|
||||
nm.deleteNotificationChannel(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static JSONObject channelToJSON(NotificationChannel channel) throws JSONException {
|
||||
JSONObject jchannel = new JSONObject();
|
||||
|
||||
Reference in New Issue
Block a user