Skip to content

feat: add IFW rule editor UI for per-component intent filtering#1498

Merged
lihenggui merged 30 commits intomainfrom
feat/ifw-rule-editor
Mar 18, 2026
Merged

feat: add IFW rule editor UI for per-component intent filtering#1498
lihenggui merged 30 commits intomainfrom
feat/ifw-rule-editor

Conversation

@lihenggui
Copy link
Owner

Summary

  • New feature:ifwrule module (api + impl) with per-component IFW rule editor screen
  • Scenario-driven UI with user-friendly language — no IFW/XML technical terms exposed to users
  • Supports all IFW filter types via intuitive condition cards: action, sender, sender-package, sender-permission, category, host, path, scheme, port, mime-type, data, component pattern
  • Bidirectional mapper (IfwRuleUiMapper) converts between UI state and IfwRules domain model
  • Progressive disclosure: simple "block all" toggle for basic use, expandable conditions for advanced users
  • Dedicated IfwRule per component for independent block/log settings
  • Entry point: component long-press context menu → "自定义拦截规则" (hidden for Provider type)
  • Advanced options: log toggle, monitor-only mode (block=false)
  • Handles unrecognizable legacy rules gracefully with read-only banner

Depends on #1497 (IFW full parameter support)

Test plan

  • Unit tests for IfwRuleUiMapper (15 tests covering all mapping directions, edge cases, merge strategy)
  • Unit tests for IfwRuleEditorViewModel (5 tests covering load/save/state transitions)
  • Manual test: long press component → "自定义拦截规则" opens editor
  • Manual test: save "block all" → verify component-filter written to IFW file
  • Manual test: save conditional rule → verify and/or/not structure in IFW file
  • Manual test: edit existing rule → verify round-trip preservation
  • Manual test: Provider components should not show the menu item

lihenggui and others added 18 commits March 15, 2026 19:32
…rule flow

Adds a new top-level navigation tab for viewing and managing all IFW
rules on the device. Includes rule list grouped by package, delete with
confirmation, and an add-rule screen with condition editor.
…ponent names, add transition animation, translate Block to 阻止
Change-Id: I95b5c309cb4a2adf48cc047962e738619fb7133e
Change-Id: I3f8fe5c2326d0bca14798fef751c8a5a4b23de03
Change-Id: I70740d09ae9fb52d8226e51fce9f637c112e78b3
lihenggui and others added 4 commits March 16, 2026 13:48
Change-Id: I871aa52fddb35740dfae2fe0e4fda6ab54a072f3
Change-Id: Icb245523621a5384e71bdd33ad6095c74b18ed46
Change-Id: I7e5d46a4473784ad5c9d8555307c7d787b167f25
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android Lint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

- Fix toTopLevelFilters() to always wrap root group as single filter,
  preventing ALL-mode conditions from being incorrectly OR'd by IFW
- Simplify per-component toIfwFilter() to use toIfwFilterOrNull() directly
- Replace FQN references in AddRuleScreen SwitchRow with proper imports
- Update test expectation for nested And structure
… toolbar

- Split IfwRuleTreeEditor.kt (732 lines) into 5 focused files in
  ifwruleeditor sub-package
- Fix critical IFW semantic bug: top-level filters in a rule are OR'd
  (not AND'd). toEditorRootGroup() now defaults to ANY mode, matching
  IFW behavior. Per-component editor correctly uses ALL for filters
  extracted from And wrappers
- Move save button from bottom to toolbar (check icon) in both
  IfwRuleEditorScreen and AddRuleScreen
- Add unsaved changes confirmation dialog on back navigation
- Add app icon to Firewall page package headers
- Fix FQN reference in IfwRuleEditorScreen
Change-Id: I9cae42be44b33d9d7ad3785a86b380d76af89d89
Change-Id: I741ce05436b36e6cfeef925f0c6c894e3f3cf083
@juliewww
Copy link
Collaborator

Find an issue: Every time I open the Firewall screen, it will reload even though it's empty

Change-Id: I4d6d3f21f2ea9d7dcfcdc33453baad3f819e8109
Change-Id: Iabf8b1d96c223cd67fe5db5f1401d6ebaf5d24b5
Change-Id: I5fcd8482b820b48acab46ac35c72d8dfcf4281e8
Change-Id: I70360b3f28d4e287f98dc3f653a3cc2d5341ae30
@lihenggui lihenggui merged commit 31abec5 into main Mar 18, 2026
4 checks passed
@lihenggui lihenggui deleted the feat/ifw-rule-editor branch March 18, 2026 22:05
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.

2 participants