Runs discovery thread to ping the server on regular intervals (health + availability) + launches a child process which runs the GGML backend w/ specified number of threads (for easier interruption).
- Android Studio + JDK (tested w/ JDK 21)
- Android SDK + platform-tools (adb, tested w/ 36) + NDK + CMake
Install Android Studio, then install SDK/NDK/CMake packages via the Setup Wizard or SDK Manager.
Check with:
java -version
adb versioncd android-app
./gradlew assembleDebug
adb install -r app/build/outputs/apk/debug/app-debug.apk
-
app/src/main/java/com/llama/rpcapp/MainActivity.java- Owns user input UI (host/port/discovery/threads) and start/stop actions.
- Loads saved values on screen open.
- Persists edited values only when user taps Start.
- Starts/stops
RpcServerService.
-
app/src/main/java/com/llama/rpcapp/ServerConfig.java- Config model shared by UI/repository/service.
- Normalizes config values (like host and discovery IP formatting).
-
app/src/main/java/com/llama/rpcapp/SettingsRepository.java- SharedPreferences-backed persistence.
loadConfig()reads app config from XML.saveConfig()writes app config to XML.
-
app/src/main/java/com/llama/rpcapp/RpcServerService.java- Foreground service and runtime owner for server execution.
- Loads config from
SettingsRepositoryat startup. - Chooses an available RPC port and writes resolved config back to storage.
- Launches native RPC binary (
librpc-server.so) viaProcessBuilder. - Streams native process output to logcat.
- Runs discovery announce loop to tracker.
- Stops the child process when the user taps Stop Server.
-
app/src/main/java/com/llama/rpcapp/NativeRpcServer.java- JNI wrapper exposing
getMaxSize()for native backend capacity probes; discovery now uses Android runtime memory estimates.
- JNI wrapper exposing
-
app/src/main/cpp/native-lib.cpp- JNI implementation for app-process native helpers (
getMaxSize()only right now).
- JNI implementation for app-process native helpers (
-
app/src/main/cpp/rpc-server-main.cpp- Standalone C++ entrypoint for the RPC server process.
-
app/src/main/cpp/CMakeLists.txt- Builds both native outputs:
llama-rpc(JNI library used inside app process)rpc-server(server binary packaged as launchable.so)
- Builds both native outputs:
- User edits values in
MainActivityUI and taps Start. MainActivitysaves config to SharedPreferences throughSettingsRepository.RpcServerServicestarts in foreground mode and loads saved config.- Service resolves an available listening port and writes resolved config back.
- Service launches
librpc-server.soviaProcessBuilder. - Native
rpc-server-main.cppinitializes GGML backend and enters RPC serve loop. - Discovery thread sends periodic tracker announces including:
- host/IP, service port, device model, estimated usable RAM, battery, temperature.
- On stop/destroy, service interrupts discovery loop and destroys child process.