Skip to content

Rename to WiFi Config Tuner (v7.0.0) + maintenance audit

Choose a tag to compare

@sms1sis sms1sis released this 20 Aug 14:43
· 5 commits to main since this release

v7.0.0 — Rename & Maintenance Audit

Renamed

  • Project renamed: WiFi Config Switcher → WiFi Config Tuner. Module id changed from wifi_config_switcher to wifi_config_tuner (module.prop), which also updates the on-disk install path (/data/adb/modules/<id>/) and the WebUI's hardcoded actionScript path in lockstep — both were updated together since a mismatch here silently breaks every WebUI action. Display name, install banner, About page, and GitHub source links updated to match. The new name also resolves a naming inconsistency that predated this release: the WebUI <title> already said "Wi-Fi Config Tuner" while module.prop said "WiFi Config Switcher" — everything now agrees.
  • Breaking for existing installs: because the module id changed, flashing this version installs alongside any existing "WiFi Config Switcher" install rather than replacing it in place. See the README's "Upgrading" section — the old module must be removed manually via KernelSU Manager. Saved profile state in /data/adb/wcs/ is unaffected and carries over automatically.
  • update.json and module.prop's updateJson now point at the renamed WiFi-Config-Tuner repository.

Reliability & Portability

  • Removed non-POSIX local keyword (17 uses across detect_driver_type, get_driver_name, find_wifi_config, find_patch_dir, apply_patch). local is a bash/toybox/mksh extension, not POSIX sh — on ROMs whose /system/bin/sh doesn't support it, these variables would silently become global instead of raising an error, a dangerous failure mode. Replaced with per-function variable-name prefixes so correctness no longer depends on shell-specific behaviour.
  • Fix: apply_patch used a fixed /tmp/wcs_patch_count path for passing the applied-key count out of an awk subprocess — a race risk if apply_mode were ever triggered twice concurrently (e.g. a double-tap on the WebUI profile button before it disables itself). Now uses mktemp under the module's own state directory, with the temp file cleaned up immediately after use.
  • Removed dead code: the non-JSON get_debug_info action (~90 lines). The WebUI has only ever called get_debug_info_json; the plain-text twin was unreferenced and had already drifted slightly out of sync with it.
  • Removed dead code: legacy pre-v5.0.4 config-overlay path fallback in find_wifi_config(). MODDIR is wiped on every flash (see service.sh), so a module update always re-runs customize.sh fresh — there was no upgrade path left that could still hit this branch.

Internal Cleanup

  • Externalized the SoC-ID → Wi-Fi-chip-name table (~90 lines of hardcoded case statements) into a new chip_map.tsv data file, looked up via awk. Contributing a new SoC ID is now a one-line data edit instead of a shell patch. The SDM665/SD732G (SoC 394) disambiguation and the WCSS-address fallback stay in backend.sh since they need logic beyond a flat lookup.
  • Deduplicated the device-alias map (sunny→mojito, sweet_k/sweetin→sweet, willow→ginkgo) out of customize.sh and backend.sh into a single shared device_aliases.txt, read by both customize.sh (install time) and a new resolve_device_alias() helper in backend.sh (runtime sideload fallback). Previously the same map had to be updated by hand in two places.
  • Promoted the inline _esc() JSON-escaping helper out of get_driver_info into the top-level Helpers section, next to log_json().
  • detect_driver_type() is now a thin memoizing wrapper around the original detection logic (renamed _detect_driver_type_impl), guarding against any future code path calling it twice within the same action (it re-runs a zcat /proc/config.gz decompression each time). Does not cache across separate WebUI actions — each is its own fresh process.

WebUI Fixes

  • Fix: parseJson() used naive indexOf('{')/lastIndexOf('}') brace matching, which would silently grab the wrong substring if any JSON string value ever legitimately contained a literal { or } (e.g. an unescaped device-tree compatible string). Replaced with a proper depth-tracking scanner that respects quoted strings and escape sequences, so it finds the actual end of the intended object.
  • Google Fonts stylesheet now loads asynchronously (media="print" swapped to all on load, with a <noscript> fallback) instead of render-blocking. This is a Wi-Fi tuning tool — plausibly opened while the device's own connectivity is down or misconfigured — so first paint no longer waits on a network request that may never succeed. The existing monospace/sans-serif fallbacks in --mono/--head mean the UI stays fully legible either way.

Bug Fixes

  • Fix (critical): apply_patch corrupts values containing & or | — the old implementation used sed -i "s|...|${key}=${value}|" directly. Any value containing & expanded to the matched text in sed's replacement, silently writing wrong data. A | in the value broke the s|...| delimiter entirely. Current patch files only use integers so this was latent, but would have triggered the moment a patch added a string-typed value. Rewritten with awk — keys and values are passed as awk variables, never interpolated into a regex or replacement pattern.

  • Fix (critical): apply_patch inserts literal \n on Android (toybox sed bug) — when a key was new and the config contained an END marker, the old code used sed -i "s|^END|${key}=${value}\nEND|". Android's toybox sed does not support \n in replacements; it writes the two characters \n literally instead of a newline, producing a malformed config line. The awk rewrite handles END insertion with correct newline semantics on all POSIX shells.

  • Fix: apply_patch rewrites the whole file on every key — the old implementation ran one sed -i per key, rewriting the entire config file N times (23 times for sm6125). The awk rewrite makes a single pass over the file regardless of patch size.

  • Fix: apply_patch write is now atomic — the old implementation wrote directly to the config file. A kill mid-write (OOM killer, force-stop) left a truncated config the driver could not parse. The new implementation writes to a .wcs_tmp sibling and mvs it into place — mv on the same filesystem is atomic.

  • Fix: write_config (config editor save) is now atomic — same issue as above. The base64 decode now targets a .wcs_tmp file; mv replaces the live config only after a successful decode.

  • Fix: get_mode sanitizes mode file — cat mode_status.txt was written raw into a JSON string. A corrupt or manually edited file could produce invalid JSON, breaking the dashboard on next open. The value is now validated against the three known modes (perf, balanced, stock) and defaults to stock for anything else.

  • Fix: apply_mode ran detect_driver_type twice — once in the stock-restore branch and once after applying a patch, each triggering a full sysfs scan. Now runs once at the top of the action, result shared by both paths.

  • Fix: duplicate willow alias in customize.sh — two identical willow) ALIAS="ginkgo" entries in the device alias case block. Second entry was dead code but a maintenance hazard. Removed.

New Features

  • Boot-time profile re-application (service.sh) — after a module update or reflash, customize.sh copies a fresh unpatched config from /vendor into the overlay, silently reverting the tuning even though the saved mode still says perf or balanced. service.sh now reads the saved mode on every boot and re-applies it automatically. Output is logged to /data/adb/wcs/boot_restore.log for verification. Stock mode takes no action.

WebUI Fixes

  • Fix: theme flash (FOUC) on open — the saved theme was applied by JS after the page rendered, causing a brief Sci-Fi flash before switching to Light or Dark. A blocking inline <script> in <head> now reads localStorage and sets data-theme before the first paint. A visibility: hidden guard covers the remaining gap while the JS module loads. No visible flash at any network/CPU speed.

  • Fix: data-theme used empty string for Sci-Fi — setTheme('scifi') set data-theme="" (empty string). While functional, it means [data-theme] attribute selectors would match the empty value unexpectedly. All theme paths now use explicit string values ("scifi", "normal", "normal-dark"). :root and [data-theme="scifi"] are co-selectors for the Sci-Fi variables.

  • Fix: settings checkmarks hardcoded in HTML — check-scifi and check-interval-5 had ✔ baked into the HTML. If the user had changed those settings, reopening Settings briefly showed the wrong checkmark before JS corrected it. All checkmarks are now blank in HTML; JS always writes them via _syncThemeChecks / _syncIntervalChecks.

  • Fix: theme checkmarks not updated on Settings visit — navigate('settings') only called _syncIntervalChecks. If the theme was changed in the same session the checkmarks on the Settings page were stale until the page was re-visited. Now calls both sync functions on every visit.

  • Fix: deprecated escape()/unescape() removed — three decodeURIComponent(escape(atob(...))) calls and one btoa(unescape(encodeURIComponent(...))) replaced with TextDecoder / TextEncoder. The old functions are removed from the Web standard and log deprecation warnings in modern WebViews.

  • Fix: stats interval timer not cleaned up — setInterval for stats polling had no clearInterval on page unload. Added a pagehide listener to clean it up when the WebView is destroyed.

  • Removed dead .theme-toggle CSS — three rule blocks for .theme-toggle (a button replaced by the Settings page in an earlier version) were still in the stylesheet. Removed.