Summary
_parsePossibleChannels — which parses a TR-181 PossibleChannels string into a sorted list of channel numbers — is duplicated verbatim in two service files. Any future fix (e.g. sentinel filtering, range-parsing hardening) must be applied in both places; missing one causes silent divergence between the two services.
Locations
lib/page/wifi_settings/services/usp_wifi_data_service.dart (_parsePossibleChannels, ~line 424)
lib/page/wifi_settings/services/usp_wifi_settings_service.dart (identical top-level function, ~line 622)
Impact
Suggested fix
Extract to a single shared utility (e.g. lib/core/utils/wifi_channel_utils.dart, parsePossibleChannels(String raw) -> List<int>) and import from both services. Move the associated unit tests to cover the shared function once.
★ The shared utility MUST carry the hardened logic (sentinel "0" filtering, bounds.length != 2 guard, range-notation coverage), taking the usp_wifi_data_service copy as the correct baseline — NOT the un-hardened usp_wifi_settings_service copy. Extracting from the wrong baseline would spread the gap rather than close it. This subsumes the "C-1" finding raised in PR #1027 review (Round 3), which was downgraded there and folded into this issue.
Notes
Related functional fixes (band normalization for DFS annotation, "0" sentinel filtering, range-notation test coverage) were handled directly in #1023 / PR #1027 for the usp_wifi_data_service path. This issue tracks the deduplication tech-debt AND re-convergence of the two now-diverged copies (hardening the settings-service path in the process), deferred from #1027 to avoid scope-creep.
Summary
_parsePossibleChannels— which parses a TR-181PossibleChannelsstring into a sorted list of channel numbers — is duplicated verbatim in two service files. Any future fix (e.g. sentinel filtering, range-parsing hardening) must be applied in both places; missing one causes silent divergence between the two services.Locations
lib/page/wifi_settings/services/usp_wifi_data_service.dart(_parsePossibleChannels, ~line 424)lib/page/wifi_settings/services/usp_wifi_settings_service.dart(identical top-level function, ~line 622)Impact
Not a functional bug today — behaviour is identicalUPDATE (2026-07-02): the two copies have now DIVERGED. Theusp_wifi_data_servicecopy was hardened (sentinel"0"filtering + range-notation guard) while theusp_wifi_settings_servicecopy was not. They are no longer identical — which is precisely the drift hazard this issue warned about, now realized.usp_wifi_settings_servicecopy lacks abounds.length != 2check and aremoveWhere((ch) => ch <= 0)filter, so malformed backend input ("0","0-13") would parse into an unclean list. This is a low-severity defensive-coding gap, not a user-reachable functional bug — the settings-page dropdown is a selection menu (no free-text input), and PR feat(wifi): add channel dropdown to edit dialog (#1023) #1027 does not modify that page's UI. (See re-evaluation in PR feat(wifi): add channel dropdown to edit dialog (#1023) #1027 review.)Suggested fix
Extract to a single shared utility (e.g.
lib/core/utils/wifi_channel_utils.dart,parsePossibleChannels(String raw) -> List<int>) and import from both services. Move the associated unit tests to cover the shared function once.★ The shared utility MUST carry the hardened logic (sentinel
"0"filtering,bounds.length != 2guard, range-notation coverage), taking theusp_wifi_data_servicecopy as the correct baseline — NOT the un-hardenedusp_wifi_settings_servicecopy. Extracting from the wrong baseline would spread the gap rather than close it. This subsumes the "C-1" finding raised in PR #1027 review (Round 3), which was downgraded there and folded into this issue.Notes
Related functional fixes (band normalization for DFS annotation,
"0"sentinel filtering, range-notation test coverage) were handled directly in #1023 / PR #1027 for theusp_wifi_data_servicepath. This issue tracks the deduplication tech-debt AND re-convergence of the two now-diverged copies (hardening the settings-service path in the process), deferred from #1027 to avoid scope-creep.