Android: build with the build-tools the workflows install; this wave in the docs

The release workflow and the Docker build install build-tools 36.0.0, as
docs/android.md asks, but AGP 8.13 wanted its default, 35.0.0: it
installed that one itself where the SDK licences were accepted, and
elsewhere the build stopped. app/build.gradle.kts now pins 36.0.0, and
the debug APK (arm64-v8a and x86_64) builds with an SDK that has only
platform 36, build-tools 36.0.0 and the NDK 27.3: the Gradle 8.14.3
wrapper on Temurin JDK 17, Kotlin without warnings.

docs/android.md had none of this wave: the voice notification as the
app's voice card (Mute, Deafen, Leave, tap to open the voice screen), the
live stream's notification, the screen drawn straight into the encoder's
input surface and the reader for simulcast, the app picker with icons,
Camera2 cameras with the CAMERA permission, Share to Voelin, what was
tested where (the Rust sides, headless screenshots, compile-only parts),
a known gap (no camera foreground service) and how to try it on Waydroid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 22:56:58 +03:00
1 parent a61d0af370
commit 7a404a439d
2 files changed
+100 -17

No files matched your search

+3
View File
@@ -34,6 +34,9 @@ val releaseStoreFile = signing("voelin.signing.storeFile", "VOELIN_SIGNING_STORE
android {
namespace = "io.github.faumaray.voelin"
compileSdk = 36
// What the release workflow and the Docker build install (AGP's
// default would be 35.0.0).
buildToolsVersion = "36.0.0"
ndkVersion = "27.3.13750724"
defaultConfig {
+97 -17
View File
@@ -2,23 +2,30 @@
The Android app is the desktop UI (`voelin-ui`, Slint) running in a
`NativeActivity`, plus a thin Kotlin layer for what only Java APIs can do:
foreground services, the screen-capture consent, the Keystore.
foreground services and their notifications, the screen-capture consent,
the cameras, the share sheet, the Keystore.
```
android/ Gradle project (AGP 8.13, Kotlin 2.3, Gradle 8.14.3 wrapper)
app/src/main/java/.../voelin/ MainActivity (NativeActivity), Bridge, Native,
VoiceService, ScreenCaptureService, SecretStore
app/src/main/java/.../voelin/ MainActivity (NativeActivity, Share to Voelin), Bridge,
Native, VoiceService, ScreenCaptureService, Notifications,
CameraCapture, SecretStore
crates/voelin-android/ libvoelin_android.so: android_main, engine host,
JNI glue, capture providers, Keystore secrets
JNI glue, capture and camera providers, notifications
(foreground.rs), Keystore secrets
```
The phone layout of the UI (the voice channel with a stream, the bottom
navigation, the studio, the share dialog) is described in
[ui.md](ui.md); its screenshots are taken on the desktop at 390×844.
## Building
Requirements:
- Android SDK with `platforms;android-36` and `build-tools;36.0.0`
(`ANDROID_HOME`, or `sdk.dir` in `android/local.properties`), NDK
`27.3.13750724` (`ndk;27.3.13750724`; the version is pinned in
`27.3.13750724` (`ndk;27.3.13750724`; the versions are pinned in
`app/build.gradle.kts`)
- JDK 17 or newer
- Rust targets: `rustup target add aarch64-linux-android x86_64-linux-android`
@@ -28,7 +35,7 @@ Requirements:
```sh
cd android
./gradlew assembleDebug # arm64-v8a + x86_64 (emulator)
./gradlew assembleDebug # arm64-v8a + x86_64 (emulator, Waydroid)
./gradlew assembleDebug -Pvoelin.abis=arm64-v8a # phones only, half the build
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb logcat -s RustStdoutStderr ScreenCaptureService VoiceService SecretStore
@@ -79,19 +86,61 @@ capture, NDK MediaCodec format queries); targetSdk and compileSdk 36.
to the background instead of finishing the activity; configuration changes
do not recreate it.
- **Voice in the background**: while any session has a voice connection,
`VoiceService` runs as a foreground service of type `microphone` with a
notification ("In voice on …", Mute or Unmute, Disconnect). Rust drives it
from engine events (`foreground.rs`, `Bridge.setVoiceNotification`). Audio
itself is cpal on AAudio, as on desktop.
`VoiceService` runs as a foreground service of type `microphone`. Its
notification reads like the app's voice card: the channel as the title,
the server and who is there ("Home · 3 in voice", "just you"), the time
in voice as a chronometer, and Mute, Deafen and Leave, which act on every
voice session; with several servers, "In voice on 2 servers" and their
names. Tapping it opens the voice channel screen (the activity hands the
request to Rust, which queues it until the window runs:
`voelin_ui::request`). Rust drives it from engine events (`foreground.rs`,
`Bridge.setVoiceNotification`). Audio itself is cpal on AAudio, as on
desktop.
- **Sharing the screen**: `voelin_media::capture::default_screen_capture()`
returns the MediaProjection provider (`capture.rs`) registered at start.
Starting shows the system consent dialog; on consent `ScreenCaptureService`
(type `mediaProjection`) mirrors the display into an `ImageReader` at the
requested frame rate, longest side at most 1920 px, and hands RGBA frames to
`Native.onScreenFrame`. System audio (`default_audio_capture()`) is
(type `mediaProjection`) mirrors the display, longest side at most
1920 px. While one MediaCodec encoder runs (one simulcast layer, one
codec: the common case) the virtual display renders straight into that
encoder's input surface, with no copy of a frame on the CPU; with more
encoders (layers, or a codec a viewer chose) it renders into an
`ImageReader` again, whose RGBA buffers go to the encoders borrowed
(`Native.onScreenFrame`), until one encoder is left ([media.md](media.md),
MediaCodec). System audio (`default_audio_capture()`) is
`AudioPlaybackCapture` of media, game and unknown usages, 48 kHz stereo
float, only while the projection runs. Ending the projection from the
status bar or the notification closes the capture channels.
float, only while the projection runs; single apps are captured by their
uid (`addMatchingUid`), "every app but ours" excludes ours. While our
stream is live the notification says where and who watches ("Live in
Chill Zone", "Home · 2 watching") with Stop sharing. Ending the
projection from the status bar or the notification closes the capture
channels.
- **Choosing the stream's sound**: the share dialog and the Stream Studio
pick the sources of `stream.audio_sources` in the studio's picker:
the microphone, every app but ours, and the launchable apps
(PackageManager) with their own icons, several at once. Kotlin draws each
app's icon once per installed version into a 96 px PNG in the cache
(`Bridge.launchableApps`, `AudioApp::icon`). The shared window's audio is not
offered: a phone shares the whole screen.
- **Cameras** (the Stream Studio's camera sources): `CameraCapture.kt`
lists the Camera2 cameras (front first, their YUV sizes and highest frame
rate) and asks for the `CAMERA` permission when a camera is first opened
(the source shows why if it is refused). It opens the camera into an
`ImageReader` (`YUV_420_888`) at the wished size or the nearest (16:9
first, 1280×720 by default) and hands each frame's planes to Rust as
direct buffers valid during the call, with the turn that makes it
upright. Rust (`camera.rs`) passes upright planar or NV12 pictures on as
they are and gathers NV21 or turned ones into I420 in a buffer each
camera keeps: nothing is allocated per frame. Cameras that face the user
are mirrored by default; the source menu's Switch camera moves a source
to the next camera ([studio.md](studio.md)).
- **Share to Voelin**: the activity takes `ACTION_SEND` and
`ACTION_SEND_MULTIPLE` of any type. Text and links go into the composer
of the current chat, which the phone then shows (one tap sends them).
Files are copied out of the sending app while its content URIs are
readable, on a thread of their own, under the name the app gives (made
safe as a path component), then uploaded to the current chat's channel
(or the channel we are in) and linked there as the attach button does.
The copies live in the cache and are removed at the next start.
- **Watching and encoding**: `voelin_media::Codecs` uses the device's
MediaCodec encoders (hardware first) and decoders on Android
([media.md](media.md)).
@@ -107,7 +156,8 @@ capture, NDK MediaCodec format queries); targetSdk and compileSdk 36.
Permissions: `INTERNET`, `ACCESS_NETWORK_STATE`, `RECORD_AUDIO`,
`MODIFY_AUDIO_SETTINGS`, `FOREGROUND_SERVICE` with `_MICROPHONE` and
`_MEDIA_PROJECTION`, `POST_NOTIFICATIONS`.
`_MEDIA_PROJECTION`, `POST_NOTIFICATIONS`, `CAMERA` (asked for when a camera
is first opened; `android.hardware.camera.any` is optional).
## Status
@@ -115,8 +165,14 @@ Permissions: `INTERNET`, `ACCESS_NETWORK_STATE`, `RECORD_AUDIO`,
|---|---|---|
| `libvoelin_android.so` for `aarch64-linux-android` (Slint Android backend with Skia, AAudio, AWS-LC, SQLite, libopus) | `cargo ndk -t arm64-v8a build -p voelin-android` | builds; exports `android_main` and the `Native` methods |
| Debug APK | `./gradlew assembleDebug -Pvoelin.abis=arm64-v8a` | builds |
| Engine host replay, voice service policy | unit tests (`cargo test -p voelin-android`) | tested |
| Debug APK for phones and Waydroid (`arm64-v8a` + `x86_64`) | `./gradlew assembleDebug` on Linux: the Gradle 8.14.3 wrapper, Temurin JDK 17, an SDK with only `platforms;android-36`, `build-tools;36.0.0` and the NDK 27.3 | builds (Kotlin without warnings) |
| Engine host replay, voice service policy, the voice notification's text (deafen across sessions, several servers), the live stream's notice | unit tests (`cargo test -p voelin-android`) | tested |
| External capture providers, MediaCodec buffer layouts | `voelin-media` unit tests | tested |
| The phone screens: voice channel with a stream, Home, Servers, Chats, Activity, You, Settings, Stream Studio, the share dialog with its sound | headless screenshots at 390×844 ([ui.md](ui.md)) | tested on the desktop (the same Slint UI; not on a device) |
| A tapped voice notification opens the voice screen; text shared to the app lands in the composer | `VOELIN_OPEN=notification`, `VOELIN_OPEN=shared:<text>` on the desktop | the Rust side tested headless; the notifications, their actions, the share sheet and file uploads from it compile only |
| Cameras: YUV planes borrowed, gathered into I420, turned | `voelin-media` `camera::tests::camera_planes_are_borrowed_gathered_and_turned` | the Rust side tested; Camera2, the permission flow and switching compile only |
| The virtual display into the encoder's input surface, back to the reader for simulcast | `cargo ndk -t arm64-v8a clippy` | compiles only: frames per second and CPU use not measured (no device; Waydroid's encoders are software ones, if any) |
| The app picker with icons | the studio's and the share dialog's picker with sample data (headless) | the UI tested; the PackageManager list and its icons compile only |
| The app on a device: UI, voice in the background, screen sharing, watching, Keystore | manual matrix row IN3 and the Android rows | not run yet (no device or emulator in this environment) |
| Waydroid (Mesa GL) | the debug APK, `waydroid logcat` | works with the EGL workaround (below); before it, the app ended at start because Skia could not create its GL context |
@@ -128,6 +184,9 @@ Known gaps:
`Codecs` uses MediaCodec.
- Rotating the device while sharing letterboxes the picture (the virtual
display keeps its size).
- Cameras deliver while the app is in front: there is no foreground service
of type `camera`, so Android stops a camera source when the app goes to
the background (the screen share goes on).
- The safe area (status and navigation bars) and the on-screen keyboard pad
the main window; dialogs drawn over it do not account for them yet.
- Only `arm64-v8a` and `x86_64` are built; 32-bit devices are not supported.
@@ -154,3 +213,24 @@ I RustStdoutStderr: … Could not create Skia Direct Context from GL interface
at start, before Slint's surface, so they get slots first (logcat:
`EGL: N of 83 Skia extension functions resolved`). Vendor GPU drivers on
phones return nothing for desktop-only names and are not affected.
### Trying it on Waydroid
Waydroid on a PC runs the `x86_64` library, which the default
`assembleDebug` builds (`rustup target add x86_64-linux-android` first):
```sh
cd android && ./gradlew assembleDebug
waydroid app install app/build/outputs/apk/debug/app-debug.apk
waydroid app launch io.github.faumaray.Voelin
waydroid logcat | grep -E 'RustStdoutStderr|MainActivity|VoiceService|ScreenCaptureService|CameraCapture'
```
Things to try there: the bottom navigation (Home, Servers, Chats,
Activity, You), joining a voice channel and its screen from the top bar's
voice button, the voice notification (pull down the shade: Mute, Deafen,
Leave, tap it), Share from another app's share sheet (text, then a file),
the voice screen's Share (the screen share dialog) with sound from the
audio picker (app icons) and its gain and mute while live, and Go Live's
Stream Studio with a camera source (Waydroid usually has no camera: the
source then says why).