Skip to content

feat(ifw): Add full AOSP Intent Firewall parameter support#1497

Merged
lihenggui merged 1 commit intomainfrom
feat/ifw-full-parameter-support
Mar 15, 2026
Merged

feat(ifw): Add full AOSP Intent Firewall parameter support#1497
lihenggui merged 1 commit intomainfrom
feat/ifw-full-parameter-support

Conversation

@lihenggui
Copy link
Copy Markdown
Owner

Summary

  • Redesign core:ifw-api module with type-safe sealed class domain model supporting all 18 AOSP IntentFirewall filter types
  • Add separate XML serialization/deserialization layer using XmlPullParser (decoupled from domain model)
  • Extend IIntentFirewall interface with getRules/saveRules for the new domain model while preserving full backward compatibility

New Domain Model (com.merxury.core.ifw.model)

Category Filter Types
Composite And, Or, Not
String-based (10 types, each with 6 matching modes) Action, Component, ComponentName, ComponentPackage, Data, Host, MimeType, Scheme, SchemeSpecificPart, Path
String matching modes Equals, StartsWith, Contains, Pattern, Regex, IsNull
Special Category, Port (exact/range), Sender (signature/system/userId), SenderPackage, SenderPermission
Legacy ComponentFilter (backward compat)
Configurability block/log attributes now configurable per rule

Architecture

IfwFilter (domain model, type-safe sealed hierarchy)
    ↕  IfwXmlSerializer / IfwXmlDeserializer
XML String (AOSP-compatible)

Test plan

  • Unit tests for all domain model types (StringMatcher, IfwFilter, IfwRules)
  • Deserializer tests: all filter types, string matchers, composites, legacy format, error handling
  • Serializer tests: all filter types, string matchers, composites, block/log attributes
  • Round-trip tests: serialize → deserialize equality for every filter type
  • Integration tests: IntentFirewall getRules/saveRules with file system
  • Backward compatibility: legacy XML format parses correctly
  • All existing tests continue to pass
  • Spotless formatting applied

lihenggui added a commit that referenced this pull request Mar 14, 2026
Changes based on PR #1497 review feedback:

1. log default → true (IfwRule, IfwXmlDeserializer)
2. Remove fully qualified names in IfwXmlSerializer (use import alias)
3. DI for IfwXmlSerializer/IfwXmlDeserializer via constructor injection
4. Unified interface: rename add/remove → addComponentFilter/removeComponentFilter
5. Remove dual rules - single IfwRules cache, delete old IfwEntity.kt
6. Rename "legacy" → "component-filter only" in test naming
7. Remove xmlutil/kotlinx-serialization dependencies from ifw-api
8. Migrate ImportIfwRulesWorker to use IfwXmlDeserializer
@lihenggui lihenggui force-pushed the feat/ifw-full-parameter-support branch 3 times, most recently from 57ee2f2 to 793ffc9 Compare March 15, 2026 01:54
Redesign core:ifw-api to support all 18 AOSP IntentFirewall filter types
using a type-safe sealed class domain model with a separate XML
serialization layer.

Domain model (com.merxury.core.ifw.model):
- IfwFilter: sealed interface with all filter types
  - Composite: And, Or, Not
  - String-based (10 types × 6 matching modes): Action, Component,
    ComponentName, ComponentPackage, Data, Host, MimeType, Scheme,
    SchemeSpecificPart, Path
  - StringMatcher: Equals, StartsWith, Contains, Pattern, Regex, IsNull
  - Special: Category, Port, Sender, SenderPackage, SenderPermission
  - Legacy: ComponentFilter
- IfwRule/IfwRules with configurable block/log attributes

XML serialization layer (com.merxury.core.ifw.xml):
- IfwXmlSerializer/IfwXmlDeserializer (XmlPullParser-based)
- IfwXmlConstants for all AOSP XML tag/attribute names
- Full backward compatibility with existing component-filter XML

Interface redesign:
- Unified IIntentFirewall: getRules/saveRules as core API,
  addComponentFilter/removeComponentFilter as convenience methods
- Single IfwRules cache (removed old dual-model approach)
- DI for serializer/deserializer via constructor injection
- Removed xmlutil/kotlinx-serialization dependencies
- Deleted old IfwEntity.kt
- Migrated ImportIfwRulesWorker to new deserializer
@lihenggui lihenggui force-pushed the feat/ifw-full-parameter-support branch from 793ffc9 to 2bceaaa Compare March 15, 2026 02:00
@lihenggui lihenggui merged commit f5bfede into main Mar 15, 2026
4 checks passed
@lihenggui lihenggui deleted the feat/ifw-full-parameter-support branch March 15, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant