Files
Claude 5def368984 Merge branch 'codex/android-server-connection' into HEAD
# Conflicts:
#	android/app/src/main/java/uk/labus/webslicer/MainActivity.kt
#	android/app/src/main/res/values/strings.xml
#	web/backend/orca_web/filament_library.py
#	web/backend/tests/test_filament_product_api.py
#	web/frontend/src/FilamentPresetBrowser.tsx
#	web/frontend/src/FilamentProductLibrary.tsx
#	web/frontend/src/Imports.tsx
#	web/frontend/src/i18n/messages.json
2026-11-30 21:25:13 +00:00
..

Android app

An offline Android build of Web Slicer for arm64 phones (Android 10+). It runs beside the browser client and server; it does not replace them. The app packs the same pieces as the server deployment:

  • orca-headless, cross-built with the NDK and shipped as liborca_headless.so in the native library directory, the only place an app may execute files from;
  • CPython 3.14 for Android from python.org, embedded through libpyhost.so, running the FastAPI backend on 127.0.0.1 in the separate :server process; libpylauncher.so is the sys.executable for the backend's subprocesses;
  • the web client in a WebView, served by the same local origin (python/android_main.py), with the slicer resources and profiles.

The offline workspace has one local user. Everything the embedded backend reads is packed into assets/payload.zip and unpacked into the app's private storage once per payload version.

Connecting to a server

Open Preferences and help → Connection settings in the application menu. Offline on this device is the default. To use a server, enter its HTTPS origin, such as https://slicer.example.com, and sign in with your Web Slicer account. The app remembers the selected mode and server. If the server is unavailable, you can retry or return to the offline workspace. The theme selected in the app applies to both workspaces. The system theme is the default.

Each mode has its own projects, presets and account session. In server mode the web client uses the selected server for slicing and storage. Server attachments are saved to Android Downloads. The native Bambu sign-in and native blob download bridge run in the offline WebView.

Syncing filament libraries

After signing in to the server in the app, choose Sync filament library in Preferences and help → Connection settings. Select a library on each side and compare them before confirming. You can sync libraries you manage. The server needs an authenticated Web Slicer installation with library sync support.

The preview lists the number of products that will be created or updated in each workspace. Sync carries a product's name, material, colour and other metadata. A shared product can follow edits made on one side since the last match. Products edited on both sides stay as they are, with their names shown for review. Deletions, machine availability, slicing profiles and AMS slot assignments stay with their own workspace.

Building

Tools live outside the repository in ~/android: JDK 21, the Android SDK with NDK 28.2.13676358, Gradle 8.11.1, the python.org Android CPython prefix (~/android/python/prefix/prefix), a Python 3.14 venv with cibuildwheel and Rust with the aarch64-linux-android target. Every step runs through web/scripts/run-bounded.py.

  1. android/scripts/build-deps.sh: dependency superbuild into deps/build-android (about 9 GB).
  2. android/scripts/build-headless.sh: orca-headless for arm64.
  3. android/scripts/build-wheels.sh pydantic-core==… websockets==… zeroconf==… and Pillow with ZLIB_ROOT=<prefix with the NDK's zlib.h and libz.so> CIBW_BEFORE_ALL=true CIBW_CONFIG_SETTINGS="platform-guessing=disable jpeg=disable tiff=disable freetype=disable lcms=disable webp=disable avif=disable xcb=disable imagequant=disable raqm=disable jpeg2000=disable". Versions follow android/requirements.txt; PyPI has no Android wheels for them. cryptography and cffi are built the same way (the script special-cases both). cryptography links the prebuilt Android OpenSSL, our cp314 headers, and libpython; its host build dependency cffi needs the host's libffi-dev. The Android cffi wheel needs a static Android libffi the NDK does not ship: cross-build libffi (./configure --host=aarch64-linux-android --enable-static --disable-shared with the NDK clang) into ~/android/libffi-android, which the script advertises to cffi via PKG_CONFIG_PATH.
  4. android/scripts/stage-payload.sh: native libraries and payload.zip in android/build/stage (builds the web client with emsdk).
  5. In android/: gradle assembleDebug.

For the cloud build (the -cloud release APK, which bundles the open-bamboo-networking plugin and the Bambu sign-in host), initialise the submodule (git submodule update --init third_party/open-bamboo-networking), run android/scripts/build-bambu-cloud.sh to cross-build the plugin and host for arm64, then stage with ORCA_ANDROID_BAMBU_CLOUD=1 before assembleDebug. See cloud-and-connectivity.md for the plugin source (a submodule of our fork) and the distribution decision.

cryptography is packaged (installed with --no-deps by stage-payload.sh; its declared cffi dependency is never imported by the code paths we use) so Anycubic LAN sign-in works. argon2 is still not packaged: the backend loads it only for local accounts.

Testing on a phone

Two layers run against a phone reached over adb. DEVICE_ADB names an adb-compatible command bound to one test phone; without it the scripts use DEVICE_CTL (default ~/android/adb-guard), which only touches this app.

  • android/scripts/e2e-device.sh desktop|mobile REPORT_DIR [SPEC...] runs the browser suite in host Chromium against the backend in the app, so the phone's worker, Python, profiles and storage do the work. Each batch of specs starts from cleared app data. Playwright treats the phone as a bundled build (ORCA_E2E_BUNDLED=1: tests that import Vite development modules are skipped), and fixture servers such as simulated printers take ports 18700–18799 (ORCA_E2E_DEVICE_PORTS), which the script reverses into the phone. Specs that need the accounts fixture server are left out.
  • android/scripts/e2e-webview.sh [SPEC...] drives the app's own WebView through DevTools (debug builds only) with playwright.webview.config.ts: WebGL, the WebAssembly preview and the download handler, which saves files to the shared Downloads collection.

A phone's backend is slower than a local one, so tests must wait for the state they check (a saved revision, a loaded overlay) rather than for a control that is also disabled while work is in flight.