Files
Alvin-Zilverstand fe72a53a23
Build Android APKs / build (push) Successful in 2m54s
Add release candidate file and media features
2026-11-14 11:54:14 +01:00

13 KiB
Raw Permalink Blame History

S24 SMB Share Explorer — implementation plan

This is the first-release acceptance plan, not a description of the current app. See README.md for implemented behavior and RELEASE_NOTES.md for current validation gaps. Offline files remain a later feature.

Product goal and working assumptions

Build a fast, native-feeling Android file explorer for a Samba share hosted in a Debian container on home Wi-Fi. The Galaxy S24 is the primary performance test device, and Android 9 (API 28) is the minimum supported version. The first release supports browsing, searching within the current folder, downloading, deleting files and empty folders, and built-in video, image, and animated GIF viewing. Use authenticated SMB2/3 and no server-side companion app. The media library contains varied containers and codecs, so playback support must be established with a tested format matrix rather than a blanket claim.

Use Kotlin, Jetpack Compose, coroutines, and a small modular Android app with minSdk = 28. Native Android provides the most direct path to MediaCodec hardware decoding, Media3 playback, image decoding, secure credential storage, and accurate device benchmarking. A cross-platform UI adds integration work without clear benefit for an Android-only app. Keep the SMB, cache, and media interfaces independent of Compose so they can be tested and replaced. Validate all flows on both the S24 and an Android 9 device or emulator; use physical devices for media and performance conclusions.

Suggested modules: app (navigation and dependency wiring), core:model, core:smb, core:cache, feature:browse, feature:image, feature:video, and feature:transfers. Start as one Gradle module if iteration speed is more important; split once interfaces settle.

First-release behavior

  1. Connections: Add a NAS by hostname or IP, share name, port (default 445), username/password, and optional domain. Test credentials before saving. Show clear errors for DNS, timeout, authentication, share permission, and protocol mismatch. Keep a list of saved connections and recent folders. Manual entry ships first; discovery can follow.
  2. Browsing: Breadcrumbs, folders first, list/grid toggle, name/date/size sorting, file type filters, pull to refresh, selection mode, file details, and recent paths. Preserve scroll position on return. Use a virtualized list with stable file IDs. Show directory contents quickly without waiting for thumbnails.
  3. File actions: Download and delete in the first release. Save to the system Downloads folder by default, with progress, cancellation, and a clear completion action. Confirm deletes with the file name. Allow deletion of files and empty folders only; explain when a folder is not empty and never recurse into it. Upload, rename, create folder, copy, and move are later additions. Never hide partial-download failures.
  4. Image/GIF viewer: Full-screen swipe navigation, pinch zoom, pan, double-tap zoom, fit/fill, image metadata, and original-size option. Decode at the displayed size by default. GIFs animate only when visible; stop decoding when backgrounded. Cap memory use and retain a small adjacent-image prefetch window.
  5. Video viewer: Direct SMB streaming with play/pause, scrub, seek, resume position, subtitle/audio track selection, playback speed, and orientation controls. Picture-in-Picture is a later option. Use hardware decode through Media3/ExoPlayer where supported. For an unsupported codec, offer to open the file in another app through a temporary, permission-scoped content URI. Avoid copying the whole video before handoff when possible; verify the receiving player can seek through the URI. No bundled software decoder in the first release.

Data path and architecture

Compose screens
  -> ViewModels / immutable UI state
  -> use cases (browse, open media, transfer)
  -> repository interfaces
  -> SMB session pool + metadata cache + media cache
  -> NAS over SMB2/3
  • Use SMBJ as the initial SMB2/3 client, behind an SmbGateway interface. Validate its behavior on the actual NAS before committing to it. Keep one authenticated connection per server where practical, reuse shares/sessions, bound concurrency, and reconnect with backoff after network changes. Never open a separate connection for each thumbnail.
  • Represent remote files with a stable connection/share/path key plus size and modification time. Treat directory listings as snapshots; refresh on navigation and explicit pull. Invalidate metadata and thumbnail keys after mutations.
  • Keep network and decoding off the main thread. Every navigation, thumbnail, and transfer request must be cancellable. Prioritize the visible directory and current media over prefetch and background indexing.
  • Use an in-memory metadata cache and a bounded disk thumbnail cache. Avoid storing original media by default. Key thumbnails by server/share/path/size/modified time; provide a clear-cache control.
  • Build a seekable Media3 DataSource over SMBJ's offset reads. open(DataSpec) positions at the requested byte offset; read performs bounded sequential reads with a reusable buffer; close releases the remote file handle. Limit buffered bytes, reopen cleanly after disconnect, and propagate auth/network errors to playback UI. Test random seeks and end-of-file carefully.
  • For images, use Coil with a custom SMB fetcher or bounded local staging file where random access is required. Generate thumbnails at target pixel dimensions. For large images, use region/subsample decoding where supported so zoom does not force a full-resolution bitmap into memory. Coil's GIF extension can use Android's animated decoder on the S24.

Performance strategy and acceptance targets

Targets below are provisional and must be measured on the actual S24 and NAS under both strong and weak home Wi-Fi. Record NAS model, Wi-Fi band, signal strength, share size, and file mix with each run.

Scenario Initial target Design lever
Warm app launch to saved shares p95 under 1.5 s Defer network work; baseline profile
Open a 1,000-entry folder Names visible p95 under 2 s on healthy LAN Single listing, parse off main thread, virtualized rows
Scroll large folder No noticeable sustained jank; measure frame timing Stable keys, bounded thumbnail work, no per-row SMB requests
Open cached thumbnail p95 under 150 ms Memory/disk cache
Open uncached photo First fitted frame p95 under 2 s for typical photos Size-aware decode and foreground priority
Start typical 1080p video First frame p95 under 3 s on healthy LAN Reused session, hardware decode, read-ahead
Seek typical video Resume p95 under 2 s Offset reads and bounded buffering
Memory No OOM with a folder of thousands of files or very large photos Cache limits, sampling, lifecycle cleanup

Do not treat these as guaranteed values. Build a benchmark corpus with 10,000 mixed entries, 5–20 MB photos, large GIFs, and 1080p/4K MP4 and MKV samples. Test cold and warm runs, poor Wi-Fi, NAS sleep/wake, interrupted transfers, and reconnect. Use Macrobenchmark for launch/scroll and trace network, decode, and playback startup separately. Add a Baseline Profile after the main flows stabilize.

Create a playback matrix with representative MP4, MKV, WebM, and AVI files; H.264, HEVC, AV1, VP9, and older codecs where present; AAC, AC-3/E-AC-3, DTS, Opus, and FLAC audio where present; embedded and external SRT/ASS subtitles; and 1080p/4K plus HDR samples. Record container, codec/profile, resolution, bitrate, audio, subtitle type, Android device, first-frame time, seeking result, and fallback result. The app should advertise built-in support only for combinations verified on that device. AVI and unsupported codecs should take the external-app path without crashing or forcing a full download when streaming handoff works.

Security and reliability

  • Require SMB2/3; do not enable SMB1. Support signing and encryption according to server negotiation, and expose incompatibility clearly. Do not silently weaken authentication or protocol settings.
  • Store credentials with Android Keystore-backed encryption, keep secrets out of logs/crash reports, and redact paths if diagnostic export is added. Do not embed credentials in media URIs or share intents.
  • Connect to a NAS by explicit address on the local network; remote access can later be supported over a user-managed VPN. Do not expose SMB port 445 directly to the internet.
  • Use least-privilege share credentials when possible. For delete/overwrite, distinguish permission errors from network failures and avoid automatic retries that might duplicate a write.
  • For downloads, write to a temporary local destination where the chosen storage API allows it, verify byte count, and publish the final name only after success. On cancellation, remove the partial file where possible. Keep progress visible.
  • Respect Android lifecycle: release decoders and remote handles when viewers close, pause GIFs in background, and use the appropriate system-managed foreground flow for long transfers or background playback.

Delivery sequence

Phase 0 — NAS compatibility spike

Create a minimal Android proof of concept on the S24 against the Debian-container Samba server: authenticate, list a large directory, read byte ranges from a large file, and test reconnect after toggling Wi-Fi. Capture Samba version/configuration, negotiated SMB dialect, signing/encryption settings, latency, and throughput. Exit gate: stable listing and random reads on the actual share.

Phase 1 — Explorer foundation

Connection management, credential storage, browsing, sort/filter, errors, refresh, and navigation state. Add fake-SMB tests for path handling, sorting, cancellation, and stale responses. Exit gate: browse 10,000 entries without UI stalls and recover from NAS sleep/disconnect.

Phase 2 — Image and GIF viewing

Thumbnail pipeline, bounded caches, full-screen viewer, swipe/zoom, animated GIF lifecycle. Validate with giant images, EXIF orientation, corrupt files, and many rapid swipes. Exit gate: no OOM and no background animation work.

Phase 3 — Video playback

Media3 SMB data source, MP4/MKV playback, seek, tracks/subtitles, resume, orientation, and error states. Build a format matrix using real NAS files; test hardware decode, 4K, high-bitrate files, and interrupted Wi-Fi. Exit gate: reliable playback and seeking for agreed formats.

Phase 4 — File management

Downloads to the system Downloads folder, file and empty-folder deletion, confirmation, progress/cancel, and mutation-driven cache invalidation. Exit gate: verified download integrity after interruption; nonempty folders cannot be deleted; failures remain visible. Upload, rename, mkdir, copy, and move belong to a later phase.

Phase 5 — Polish and release

Accessibility, dark mode, adaptive layout, battery and network profiling, performance regression runs, crash diagnostics with redaction, backup/restore policy, and installable signed build. If Play Store distribution is desired, add store and policy work.

Main technical risks

  1. NAS compatibility: SMBJ behavior, authentication modes, signing, and directory metadata vary by server. Phase 0 resolves this early.
  2. Media format claims: A container such as MKV can hold unsupported audio/video codecs. Test the actual S24 and user library; do not promise universal playback without a separate decoder strategy.
  3. Video seeking: Some files have indexes at the end, and SMB seek/read patterns can be chatty. Instrument offsets and read sizes, then tune readahead against memory and latency.
  4. Huge images/GIFs: Full decode may exhaust memory. Sample/region decode and strict GIF lifecycle limits are required.
  5. Directory scale: A folder with thousands of media files can trigger excessive thumbnail reads. Queue visible items first and cap parallel remote work.

Decisions to finalize with the owner

  • Samba version/configuration, negotiated SMB dialect and auth method; typical folder sizes and representative video files. Discover these during Phase 0.
  • Whether distribution stays private or later includes a Play Store release.
  • Whether offline pinned files, LAN discovery, background playback, and Picture-in-Picture should be added after the first release.

Source notes