Support mixed-case notification packages
This commit is contained in:
@@ -80,6 +80,10 @@ public final class NotificationKeyReflection {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String normalized = key.trim();
|
String normalized = key.trim();
|
||||||
|
String pipePackage = packageFromPipeNotificationKey(normalized);
|
||||||
|
if (pipePackage != null) {
|
||||||
|
return pipePackage;
|
||||||
|
}
|
||||||
int suffix = normalized.indexOf('@');
|
int suffix = normalized.indexOf('@');
|
||||||
if (suffix >= 0) {
|
if (suffix >= 0) {
|
||||||
normalized = normalized.substring(0, suffix);
|
normalized = normalized.substring(0, suffix);
|
||||||
@@ -91,6 +95,19 @@ public final class NotificationKeyReflection {
|
|||||||
return AppIconRules.isValidPackageName(normalized) ? normalized : null;
|
return AppIconRules.isValidPackageName(normalized) ? normalized : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String packageFromPipeNotificationKey(String key) {
|
||||||
|
int firstPipe = key.indexOf('|');
|
||||||
|
if (firstPipe < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int secondPipe = key.indexOf('|', firstPipe + 1);
|
||||||
|
if (secondPipe <= firstPipe + 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String packageName = key.substring(firstPipe + 1, secondPipe);
|
||||||
|
return AppIconRules.isValidPackageName(packageName) ? packageName : null;
|
||||||
|
}
|
||||||
|
|
||||||
private static String nonEmptyStringFromMethod(Object target, String methodName) {
|
private static String nonEmptyStringFromMethod(Object target, String methodName) {
|
||||||
Object value = ReflectionSupport.invokeMethod(target, methodName);
|
Object value = ReflectionSupport.invokeMethod(target, methodName);
|
||||||
return value instanceof String string && !string.isEmpty() ? string : null;
|
return value instanceof String string && !string.isEmpty() ? string : null;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public final class AppIconRules {
|
public final class AppIconRules {
|
||||||
private static final Pattern PACKAGE_NAME_PATTERN =
|
private static final Pattern PACKAGE_NAME_PATTERN =
|
||||||
Pattern.compile("^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$");
|
Pattern.compile("^[A-Za-z][A-Za-z0-9_]*(\\.[A-Za-z][A-Za-z0-9_]*)+$");
|
||||||
|
|
||||||
public static final String PREF_KEY_BLOCKED_MODES = "app_icon_blocked_modes";
|
public static final String PREF_KEY_BLOCKED_MODES = "app_icon_blocked_modes";
|
||||||
public static final String PREF_KEY_EXCEPTION_RULES = "app_icon_exception_rules";
|
public static final String PREF_KEY_EXCEPTION_RULES = "app_icon_exception_rules";
|
||||||
|
|||||||
Reference in New Issue
Block a user