Refactoring

pull/209/head
M66B 2 years ago
parent c3f380f0b5
commit 28b479c478

@ -30,6 +30,7 @@ import android.app.Activity;
import android.app.ActivityManager;
import android.app.ApplicationExitInfo;
import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.app.UiModeManager;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStatsManager;
@ -732,6 +733,23 @@ public class Helper {
}
}
static String getInterruptionFilter(int filter) {
switch (filter) {
case NotificationManager.INTERRUPTION_FILTER_UNKNOWN:
return "Unknown";
case NotificationManager.INTERRUPTION_FILTER_ALL:
return "All";
case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
return "Priority";
case NotificationManager.INTERRUPTION_FILTER_NONE:
return "None";
case NotificationManager.INTERRUPTION_FILTER_ALARMS:
return "Alarms";
default:
return Integer.toString(filter);
}
}
static <T extends Object> T getSystemService(Context context, Class<T> type) {
return ContextCompat.getSystemService(context.getApplicationContext(), type);
}

@ -2674,37 +2674,17 @@ public class Log {
paused, (paused ? "!!!" : "")));
}
String name;
int filter = nm.getCurrentInterruptionFilter();
switch (filter) {
case NotificationManager.INTERRUPTION_FILTER_UNKNOWN:
name = "Unknown";
break;
case NotificationManager.INTERRUPTION_FILTER_ALL:
name = "All";
break;
case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
name = "Priority";
break;
case NotificationManager.INTERRUPTION_FILTER_NONE:
name = "None";
break;
case NotificationManager.INTERRUPTION_FILTER_ALARMS:
name = "Alarms";
break;
default:
name = Integer.toString(filter);
}
size += write(os, String.format("Interruption filter allow=%s %s\r\n\r\n",
name, (filter == NotificationManager.INTERRUPTION_FILTER_ALL ? "" : "!!!")));
Helper.getInterruptionFilter(filter),
(filter == NotificationManager.INTERRUPTION_FILTER_ALL ? "" : "!!!")));
for (NotificationChannel channel : nm.getNotificationChannels())
try {
JSONObject jchannel = NotificationHelper.channelToJSON(channel);
size += write(os, jchannel.toString(2) + "\r\n\r\n");
} catch (JSONException ex) {
size += write(os, ex.toString() + "\r\n");
size += write(os, ex + "\r\n");
}
size += write(os,

Loading…
Cancel
Save