1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

Some logging for the weird blacklist issue #696

This commit is contained in:
cpfeiffer 2017-05-21 21:02:23 +02:00
parent c79eda5507
commit e279cd736f

View File

@ -338,26 +338,34 @@ public class GBApplication extends Application {
private static HashSet<String> blacklist = null;
public static boolean isBlacklisted(String packageName) {
if (blacklist == null) {
GB.log("isBlacklisted: blacklisti is null!", GB.INFO, null);
}
return blacklist != null && blacklist.contains(packageName);
}
public static void setBlackList(Set<String> packageNames) {
if (packageNames == null) {
GB.log("Set null blacklist", GB.INFO, null);
blacklist = new HashSet<>();
} else {
blacklist = new HashSet<>(packageNames);
}
GB.log("New blacklist has " + blacklist.size() + " entries", GB.INFO, null);
saveBlackList();
}
private static void loadBlackList() {
GB.log("Loading blacklist", GB.INFO, null);
blacklist = (HashSet<String>) sharedPrefs.getStringSet(GBPrefs.PACKAGE_BLACKLIST, null);
if (blacklist == null) {
blacklist = new HashSet<>();
}
GB.log("Loaded blacklist has " + blacklist.size() + " entries", GB.INFO, null);
}
private static void saveBlackList() {
GB.log("Saving blacklist with " + blacklist.size() + " entries", GB.INFO, null);
SharedPreferences.Editor editor = sharedPrefs.edit();
if (blacklist.isEmpty()) {
editor.putStringSet(GBPrefs.PACKAGE_BLACKLIST, null);
@ -374,6 +382,7 @@ public class GBApplication extends Application {
}
public static synchronized void removeFromBlacklist(String packageName) {
GB.log("Removing from blacklist: " + packageName, GB.INFO, null);
blacklist.remove(packageName);
saveBlackList();
}