feat(ios,p0): iOS P0 platform, audio fixes, channel UX

This commit is contained in:
Edison Jwa
2026-05-17 22:00:00 +09:00
parent a1fefc8ab6
commit 7a59f5b9a1
38 changed files with 1705 additions and 674 deletions
+19 -28
View File
@@ -46,9 +46,7 @@ use zbus::blocking::Connection as BlockingConnection;
use zbus::zvariant::{OwnedValue, Value};
use zbus::{proxy, Connection as AsyncConnection};
use super::{
AudioTransmitGate, DesktopPttBackend, PttBackendError, PttBinding, PttInputClass,
};
use super::{AudioTransmitGate, DesktopPttBackend, PttBackendError, PttBinding, PttInputClass};
use crate::ptt::{PttBackendDescriptor, PttCapabilityLevel};
/// Try to construct a `LinuxGnomeWaylandBackend`. Returns `None`
@@ -84,7 +82,9 @@ fn is_gnome_on_wayland() -> bool {
let desktop = env::var("XDG_CURRENT_DESKTOP")
.unwrap_or_default()
.to_ascii_lowercase();
desktop.split(':').any(|s| s == "gnome" || s == "gnome-flashback")
desktop
.split(':')
.any(|s| s == "gnome" || s == "gnome-flashback")
}
// ---------- D-Bus proxies ----------
@@ -171,11 +171,7 @@ trait Request {
/// is `0` for success, `1` for user cancellation, `2` for
/// other failure.
#[zbus(signal)]
fn response(
&self,
response: u32,
results: HashMap<String, OwnedValue>,
) -> zbus::Result<()>;
fn response(&self, response: u32, results: HashMap<String, OwnedValue>) -> zbus::Result<()>;
/// Cancel an in-flight request.
fn close(&self) -> zbus::Result<()>;
@@ -246,13 +242,11 @@ impl LinuxGnomeWaylandBackend {
let join_result = std::thread::Builder::new()
.name("chanora-ptt-portal-probe".to_string())
.spawn(|| -> Result<u32, String> {
let conn = BlockingConnection::session()
.map_err(|e| format!("session bus: {e}"))?;
let proxy = BlockingGlobalShortcutsProxy::new(&conn)
.map_err(|e| format!("proxy: {e}"))?;
proxy
.version()
.map_err(|e| format!("portal version: {e}"))
let conn =
BlockingConnection::session().map_err(|e| format!("session bus: {e}"))?;
let proxy =
BlockingGlobalShortcutsProxy::new(&conn).map_err(|e| format!("proxy: {e}"))?;
proxy.version().map_err(|e| format!("portal version: {e}"))
})
.map_err(|e| PttBackendError::Init(format!("probe thread spawn: {e}")))?
.join()
@@ -309,9 +303,10 @@ impl DesktopPttBackend for LinuxGnomeWaylandBackend {
// Stash command + worker handles. `try_lock` is fine: the
// backend isn't yet shared, and `start` is called once at
// engine init.
let mut inner = self.inner.try_lock().map_err(|_| {
PttBackendError::Init("backend inner mutex contended".to_string())
})?;
let mut inner = self
.inner
.try_lock()
.map_err(|_| PttBackendError::Init("backend inner mutex contended".to_string()))?;
// Clean up any prior worker (defensive — `start` is
// expected to be called exactly once per backend
// instance).
@@ -546,7 +541,9 @@ async fn create_session(
.get("session_handle")
.and_then(|v| <&str>::try_from(v).ok())
.map(|s| s.to_string())
.ok_or_else(|| zbus::Error::Failure("CreateSession returned no session_handle".to_string()))?;
.ok_or_else(|| {
zbus::Error::Failure("CreateSession returned no session_handle".to_string())
})?;
Ok(zbus::zvariant::OwnedObjectPath::try_from(session_handle)
.map_err(|e| zbus::Error::Failure(format!("session_handle path parse: {e}")))?)
}
@@ -714,19 +711,13 @@ mod tests {
#[test]
fn classify_returns_keyboard_for_typical_trigger_description() {
let v = shortcuts_owned_value(vec![shortcut_entry(SHORTCUT_ID, Some("Ctrl+Alt+P"))]);
assert_eq!(
classify_shortcuts_value(&v),
Some(PttInputClass::Keyboard)
);
assert_eq!(classify_shortcuts_value(&v), Some(PttInputClass::Keyboard));
}
#[test]
fn classify_returns_keyboard_when_trigger_description_missing() {
let v = shortcuts_owned_value(vec![shortcut_entry(SHORTCUT_ID, None)]);
assert_eq!(
classify_shortcuts_value(&v),
Some(PttInputClass::Keyboard)
);
assert_eq!(classify_shortcuts_value(&v), Some(PttInputClass::Keyboard));
}
#[test]