Build 9e37201 confirmed on-device that Usage::VoiceCommunication +
MODE_IN_COMMUNICATION + speakerphoneOn=false routes Oboe playout to the
handset earpiece and the callback drains the ring correctly. Next step:
let the user flip speakerphoneOn at runtime so the existing Speaker
button actually switches audio routing instead of just gating writes.
- Cargo.toml (android target): pull in `jni = 0.21` and
`ndk-context = 0.1`. Both are already transitively in the lockfile
via Tauri/Wry, so this just promotes them to direct deps.
- desktop/src-tauri/src/android_audio.rs: new module. Grabs the JavaVM +
current Activity from `ndk_context::android_context()`, attaches a
JNI thread, calls `activity.getSystemService("audio")` to get the
AudioManager, and exposes `set_speakerphone(bool)` +
`is_speakerphone_on()` helpers that call the AudioManager method of
the same name. All gated behind `#[cfg(target_os = "android")]`.
- lib.rs: adds `mod android_audio;` (android only), two new Tauri
commands `set_speakerphone(on)` and `is_speakerphone_on()` — desktop
gets no-op stubs so the same frontend invoke() works everywhere.
Both registered in the invoke_handler.
- desktop/src/main.ts: the Speaker button (previously toggled the
playout-write gate via `toggle_speaker`) now calls `set_speakerphone`
and reads back the new routing state. Labels switched from
"Spk" / "Spk Off" to "Earpiece" / "Speaker" so users can't be
confused into thinking clicking turns audio off. pollStatus no longer
clobbers the spkBtn label based on engine spk_muted, since the two
concepts are now decoupled.
WIP because this has NOT been built or tested yet — committing at night
to save the work. Tomorrow: build #50 with this change, smoke-test the
Handset↔Speaker toggle, then move on to call history + last-contacts UI
and the Speaker-button mute bug on the other phone.
85 lines
3.4 KiB
TOML
85 lines
3.4 KiB
TOML
[package]
|
|
name = "wzp-desktop"
|
|
version = "0.1.0"
|
|
edition = "2024"
|
|
description = "WarzonePhone Desktop — encrypted VoIP client"
|
|
default-run = "wzp-desktop"
|
|
|
|
# Library target — required for Tauri mobile (Android/iOS link the app as a cdylib)
|
|
# and also used by the desktop binary below.
|
|
#
|
|
# `staticlib` was DROPPED from crate-type because rust-lang/rust#104707
|
|
# documents that having staticlib alongside cdylib leaks non-exported
|
|
# symbols from staticlibs into the cdylib. Bionic's private `__init_tcb`
|
|
# / `pthread_create` symbols end up bound LOCALLY inside our .so instead
|
|
# of resolved dynamically against libc.so at dlopen time — which crashes
|
|
# at launch as soon as tao tries to std::thread::spawn() from the JNI
|
|
# onCreate callback. The legacy wzp-android crate uses ["cdylib", "rlib"]
|
|
# and runs fine on the same phone with the same NDK + Rust toolchain.
|
|
#
|
|
# iOS Tauri builds that actually need staticlib can re-add it behind a
|
|
# target cfg if we ever ship on iOS.
|
|
[lib]
|
|
name = "wzp_desktop_lib"
|
|
crate-type = ["cdylib", "rlib"]
|
|
|
|
[[bin]]
|
|
name = "wzp-desktop"
|
|
path = "src/main.rs"
|
|
|
|
[build-dependencies]
|
|
tauri-build = { version = "2", features = [] }
|
|
# cc is no longer needed — all C++ moved to crates/wzp-native (built with
|
|
# cargo-ndk and loaded via libloading at runtime). wzp-desktop's .so on
|
|
# Android is now pure Rust.
|
|
|
|
[dependencies]
|
|
tauri = { version = "2", features = [] }
|
|
tauri-plugin-shell = "2"
|
|
serde = { version = "1", features = ["derive"] }
|
|
serde_json = "1"
|
|
tokio = { version = "1", features = ["full"] }
|
|
tracing = "0.1"
|
|
tracing-subscriber = "0.3"
|
|
anyhow = "1"
|
|
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
|
|
|
|
# WarzonePhone crates — protocol layer is platform-independent
|
|
wzp-proto = { path = "../../crates/wzp-proto" }
|
|
wzp-codec = { path = "../../crates/wzp-codec" }
|
|
wzp-fec = { path = "../../crates/wzp-fec" }
|
|
wzp-crypto = { path = "../../crates/wzp-crypto" }
|
|
wzp-transport = { path = "../../crates/wzp-transport" }
|
|
|
|
# wzp-client pulls CPAL + (on macOS) VoiceProcessingIO — desktop only.
|
|
# Android gets an oboe/AAudio backend in Step 3 of the Tauri mobile rewrite.
|
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
|
wzp-client = { path = "../../crates/wzp-client", features = ["audio", "vpio"] }
|
|
|
|
# Step B: depend on wzp-client on Android WITHOUT the audio/vpio features,
|
|
# so we pull in only the platform-independent modules (call, handshake,
|
|
# audio_ring, codec bindings). Deliberately no imports in lib.rs yet — we
|
|
# only want to verify that compiling + linking these crates on android
|
|
# doesn't regress the working build.
|
|
[target.'cfg(target_os = "android")'.dependencies]
|
|
wzp-client = { path = "../../crates/wzp-client", default-features = false }
|
|
# libloading: runtime dlopen of libwzp_native.so — the standalone cdylib
|
|
# crate that owns all C++ (Oboe bridge). Keeps wzp-desktop's .so free of
|
|
# any C/C++ static archives that would otherwise leak bionic's internal
|
|
# pthread_create into our cdylib and trigger the __init_tcb crash.
|
|
libloading = "0.8"
|
|
# jni + ndk-context: called from android_audio.rs to invoke
|
|
# AudioManager.setSpeakerphoneOn on the JVM side at runtime, so the
|
|
# Oboe playout stream (opened with Usage::VoiceCommunication) can route
|
|
# between earpiece and loud speaker without restarting.
|
|
jni = "0.21"
|
|
ndk-context = "0.1"
|
|
|
|
# Platform-specific
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
coreaudio-rs = "0.11"
|
|
|
|
[features]
|
|
default = ["custom-protocol"]
|
|
custom-protocol = ["tauri/custom-protocol"]
|