feat(Android): add wifi auto connect demo with AI - #245
Conversation
Dokploy Preview Deployment
|
PR Preview BuildsBuild Number: 1065 Android (Firebase App Distribution) |
f7838be to
69da6e6
Compare
e82ef86 to
4b6cf1a
Compare
4b6cf1a to
896491f
Compare
c0ef6bb to
615760a
Compare
af78b1e to
533d732
Compare
# Conflicts: # ios/Podfile.lock # lib/i18n/en-US.i18n.yaml # lib/i18n/strings.g.dart # lib/i18n/strings_en_US.g.dart # lib/i18n/strings_zh_TW.g.dart # lib/i18n/zh-TW.i18n.yaml # lib/repositories/auth_repository.dart # lib/router/app_router.dart # lib/screens/main/profile/profile_screen.dart # pubspec.lock # pubspec.yaml
rileychh
left a comment
There was a problem hiding this comment.
Bugs (block-worthy)
-
Tests don't compile —
isDemois a requiredAuthRepositoryarg but is omitted in three test files — test/repositories/auth_repository_test.dart:29, test/repositories/campus_wifi_repository_test.dart:267, test/screens/main/profile/profile_screen_test.dart:116 (Codex + Claude; verified by runningflutter analyze, all three reportmissing_required_argument).login_screen_test.dart:151correctly passesisDemo: false. CI will fail. Fix: addisDemo: falseto eachAuthRepository(...)/super(...)call. -
Android 10 (API 29) crash path on automatic provisioning — android/app/src/main/kotlin/club/ntut/tattoo/campuswifi/Ntut8021xProvisioner.kt:291-296 (Codex).
provisionNtut8021xonly gates onSDK_INT < Q(29), butWifiNetworkSuggestion.Builder.setCredentialSharedWithUserwas added in API 30 (R). On real Android 10 devices where suggestion permission is not "disallowed" (the assistant screen would then be innormalmode andcanProvisionAutomatically == true), tapping the auto button throwsNoSuchMethodErrorbefore any result is returned. The PR description's "Android 10 behaved as manual-only" appears to be specific to the emulator image used (its suggestion permission state happened to gate the UI to manualOnly via campus_wifi_repository.dart:450-456). Fix: either guardsetCredentialSharedWithUser/setIsInitialAutojoinEnabledwithSDK_INT >= R, or refuse suggestion provisioning entirely on API 29 (matches the existing intent —canCompatProvisionalready requires R). -
profile_screen_test.dartasserts a UI entry the production code doesn't render — test/screens/main/profile/profile_screen_test.dart:62-63 (Codex + Claude). The test expectst.profile.options.ntutWifi("Connect to NTUT-802.1X") inProfileScreen, but the production entry was added only toMainHomeScreen(home_screen.dart:52-58).lib/screens/main/profile/profile_screen.dartis unchanged on this branch (git diff main -- lib/screens/main/profile/profile_screen.dartis empty), so the i18n keyprofile.options.ntutWifiis dead. Decide whether the entry belongs in Profile (then add it) or only on Home (then drop the test + i18n key).
Suggestions / nits (not blockers)
-
Unused
cryptodependency — pubspec.yaml:21 (Claude).crypto: ^3.0.7is added butgrep -r "package:crypto" lib testreturns nothing. Likely vestigial from an earlier "credential fingerprint" implementation (the legacy keyntut8021x.lastCredentialFingerprintis still being scrubbed on every state-store read at ntut8021x_state_store.dart:46). Remove the dep. -
Reflection on
setCaPathis unnecessary on the supported version range — Ntut8021xProvisioner.kt:312-346 (Claude).WifiEnterpriseConfig.setCaPath(String)is a public API since API 26, and provisioning is gated to API ≥ 29. The reflection wrapper, thesystem_certificate_validation_unavailablepath, andsupportsSystemCertificateValidation()can be replaced with a direct call — simpler and removes a silent-fail branch. -
Auto-reprovision can be silently enabled but never disabled — campus_wifi_platform.dart:247-250 (Claude).
Ntut8021xAutoReprovision.enable()is auto-called the first time provisioning succeeds (in bothprovisionNtut8021xandsaveNtut8021xToSystem). There is nodisable(), no toggle on the NTUT Wi-Fi screen, no Preferences entry. Users who change their mind have to clear app data. Either add a UI toggle or keep enabling explicit (driven by a checkbox in the prompt/screen). -
Ntut8021xStateStore.read()writes on every call — ntut8021x_state_store.dart:45-46 (Claude). It calls_prefs.remove(_legacyFingerprintKey)on every read (and again onmarkProvisioned). One-time migration on app startup is enough; doing it on every read churns IPC. -
getSuggestionApprovalStatusblocks the Android main thread for up to 500ms — Ntut8021xProvisioner.kt:381-398 (Claude). MethodChannel handlers run on the platform main thread by default, so a 500 mslatch.awaithere can cause jank or, on bad devices, trigger an ANR-adjacent warning. Consider dispatchingprovisionNtut8021xon a background executor and posting theMethodChannel.Resultback to the main thread. -
Plaintext previous password crosses the MethodChannel — campus_wifi_platform.dart:138-148, Ntut8021xProvisioner.kt:76-86 (Claude). Today the previous password is sent across the bridge only to rebuild the old
WifiNetworkSuggestionforremoveNetworkSuggestions. According to Android docs,WifiManager.removeNetworkSuggestions(emptyList())removes all suggestions from the calling app — worth verifying and, if it works back to API 29, dropping thepreviousPasswordchannel arg entirely so it never leaves the Dart side. Defensible as-is; just a smaller attack surface if avoidable. -
_logCampusWifidouble-emits — campus_wifi_platform.dart:16-19 (Claude). Calls bothdart:developer log()anddebugPrint()for every line. Pick one (probablylog).
Process note
Codex's headline framed everything as a single "P1 cluster" of compile + crash; Claude's reading confirms its three findings (all verified — items 1, 2, 3 above) and adds seven nits. None of the additions are blockers, but #4 and #5 are zero-cost cleanups worth folding into the same fix-up commit. The most urgent are #1 (CI red), #2 (real-device crash on Android 10), and #3 (CI red).
|
測試紀錄: 倒是發現對於帳號不可登入的情形,App 僅會在觸發網路查詢時確認(並且引導至登入畫面),可能需要重新思考這件事情的 UX。 |
Summary
Adds an Android-only
NTUT-802.1Xassistant that:WifiNetworkSuggestionas the default pathACTION_WIFI_ADD_NETWORKSon Android 11+ when suggestion permission is denied or silent refresh can no longer proceedImplementation
MainActivityintoCampusWifiChannelHandlerandNtut8021xProvisionerNTUT Wi‑Fiscreen to shownormal,compatRetry, andmanualOnlystatesValidation
flutter analyzeflutter test test/repositories/campus_wifi_repository_test.dart test/services/campus_wifi/ntut8021x_auto_reprovision_test.dart test/screens/main/profile/ntut_wifi_screen_test.dart test/screens/welcome/login_screen_test.dartflutter build apk --debugEmulator Results
Notes