MuntashirAkon/AppManager · error · UnsupportedOperationException
Flags must be returned by the corresponding subclasses. key
Error message
Flags must be returned by the corresponding subclasses. key: ${key} What it means
FilterOption.getFlags(key) is an intentionally unimplemented base-class method: only subclasses that define flag keys override it. The base implementation throws UnsupportedOperationException to signal that flag lookup must be handled by the concrete option subclass.
Solutions
- Override getFlags(String key) in the concrete FilterOption subclass and return the flag map for its flag keys.
- Only call getFlags for keys whose keyType is TYPE_INT_FLAGS.
- Route flag lookup through flagsToString()/getFlags on the concrete subclass type rather than the abstract base.
Example fix
// before
@Override
public Map<Integer, CharSequence> getFlags(String key) { /* not overridden -> base throws */ }
// after
@Override
public Map<Integer, CharSequence> getFlags(@NonNull String key) {
if (key.equals("with_flags") || key.equals("without_flags")) return mFlags;
return super.getFlags(key);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (option.getKeyType() == FilterOption.TYPE_INT_FLAGS) {
Map<Integer, CharSequence> flags = option.getFlags(key);
} Type guard
static boolean supportsFlags(FilterOption o, String key) {
return o.getKeyType() == FilterOption.TYPE_INT_FLAGS && !(o instanceof FilterOption) == false && o.getClass() != FilterOption.class;
} Try / catch
try {
flags = option.getFlags(key);
} catch (UnsupportedOperationException e) {
flags = Collections.emptyMap();
} Prevention
- Only request flags for keys whose keyType is TYPE_INT_FLAGS.
- Always override getFlags() in subclasses that define flag keys.
- Call via the concrete subclass type when possible.
When it happens
Trigger: Calling getFlags(key) on a FilterOption reference whose concrete class does not override getFlags for that key; calling flagsToString(key, flags) (which calls getFlags) on a non-flag key or on a base-typed option that lacks the override.
Common situations: Generic UI code iterating all filter options and asking for flags of every key; adding a new TYPE_INT_FLAGS key to a subclass but forgetting to override getFlags; calling getFlags on a key whose keyType is not TYPE_INT_FLAGS.
Related errors
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/2d1a31ce578462f2.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/filters/options/FilterOption.java:145
case TYPE_LONG:
case TYPE_TIME_MILLIS:
case TYPE_DURATION_MILLIS:
case TYPE_SIZE_BYTES:
this.longValue = Long.parseLong(value);
break;
case TYPE_REGEX:
this.regexValue = Pattern.compile(Pattern.quote(value));
case TYPE_STR_MULTIPLE:
this.stringValues = value.split("\\n");
}
}
}
@NonNull
public abstract Map<String, Integer> getKeysWithType();
public Map<Integer, CharSequence> getFlags(String key) {
throw new UnsupportedOperationException("Flags must be returned by the corresponding subclasses. key: " + key);
}
@NonNull
public abstract TestResult test(@NonNull IFilterableAppInfo info, @NonNull TestResult result);
@NonNull
@Override
public String toString() {
return "FilterOption{" +
"type='" + type + '\'' +
", id=" + id +
", key='" + key + '\'' +
", keyType=" + keyType +
", value='" + value + '\'' +
'}';
}
@OverrideView on GitHub (pinned to 0152f468fc)