Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
Faster file transfers, prompter phone media, and a refresh button
Bee404fcb94b0ce
diff --git a/Cargo.lock b/Cargo.lockindex 2fb0c77..07ca185 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2319,6 +2319,7 @@ dependencies = [name = "nectarlink-core"version = "0.0.1"dependencies = [+ "bytes","iroh","iroh-mdns-address-lookup","n0-future",diff --git a/Cargo.toml b/Cargo.tomlindex b04d90d..0cf548b 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -43,6 +43,7 @@ rusqlite = { version = "0.40", features = ["bundled"] }serde = { version = "1", features = ["derive"] }serde_json = "1"serde_bytes = "0.11"+bytes = "1"sha2 = "0.11"tempfile = "3"thiserror = "2"diff --git a/android/app/src/main/kotlin/app/nectarlink/android/core/Core.kt b/android/app/src/main/kotlin/app/nectarlink/android/core/Core.ktindex 91a3f02..aa2d0a7 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/core/Core.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/core/Core.kt@@ -341,6 +341,12 @@ class Core(context: Context, private val scope: CoroutineScope) : EventListenerfun ring(id: String, on: Boolean) = command { it.ring(id, on) }+ /** Reconnects to PCs that aren't connected and syncs connected ones. */+ fun refresh() {+ refreshNotificationAccess()+ command { it.refresh() }+ }+fun unpair(id: String) = command { it.unpair(id) }/** Stops this phone ringing. */diff --git a/android/app/src/main/kotlin/app/nectarlink/android/media/PhoneMedia.kt b/android/app/src/main/kotlin/app/nectarlink/android/media/PhoneMedia.ktindex 87d6af1..a4f47c2 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/media/PhoneMedia.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/media/PhoneMedia.kt@@ -65,6 +65,8 @@ class PhoneMedia(context: Context, private val onChange: (List<MediaPlayer>) ->watched.clear()controllers = emptyMap()main.removeCallbacks(publish)+ scheduled = false+ lastSent = nullonChange(emptyList())}@@ -86,13 +88,26 @@ class PhoneMedia(context: Context, private val onChange: (List<MediaPlayer>) ->schedule()}- /** Changes come in bursts (metadata, then state, then artwork). */+ /** Whether a publish is on its way. */+ private var scheduled = false+ /** What was sent last, and when (for telling real changes from time passing). */+ private var lastSent: List<MediaPlayer>? = null+ private var lastSentAt = 0L++ /**+ * Changes come in bursts (metadata, then state, then artwork), so they're+ * sent together shortly after the first one. Not later: some players+ * report their state several times a second, and waiting for a quiet+ * moment would hold the update back for as long as they play.+ */private fun schedule() {- main.removeCallbacks(publish)+ if (scheduled) return+ scheduled = truemain.postDelayed(publish, SETTLE_MS)}private fun publishNow() {+ scheduled = falseval ids = mutableMapOf<String, MediaController>()val players = watched.keys.mapNotNull { controller -> read(controller)?.let { controller to it } }@@ -110,6 +125,10 @@ class PhoneMedia(context: Context, private val onChange: (List<MediaPlayer>) ->reading.player.copy(id = id)}controllers = ids+ val now = SystemClock.elapsedRealtime()+ if (sameButLater(lastSent, lastSentAt, players, now)) return+ lastSent = players+ lastSentAt = nowonChange(players)}@@ -143,7 +162,9 @@ class PhoneMedia(context: Context, private val onChange: (List<MediaPlayer>) ->val picture = metadata.getBitmap(MediaMetadata.METADATA_KEY_ART)?: metadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART)?: metadata.getBitmap(MediaMetadata.METADATA_KEY_DISPLAY_ICON)- val (artKey, artBytes) = picture?.let(art::get) ?: (null to null)+ val track = listOf(controller.packageName, title, metadata.getString(MediaMetadata.METADATA_KEY_ARTIST),+ metadata.getString(MediaMetadata.METADATA_KEY_ALBUM)).joinToString("\u0001")+ val (artKey, artBytes) = picture?.let { art.get(track, it) } ?: (null to null)val player = MediaPlayer(id = controller.packageName,app = appName(controller.packageName),@@ -182,14 +203,17 @@ class PhoneMedia(context: Context, private val onChange: (List<MediaPlayer>) ->}}- /** Artwork as a small JPEG, made once per picture. */+ /**+ * Artwork as a small JPEG, made once per track and picture size (apps+ * hand over a new copy of the same picture with every update).+ */private class ArtCache {private val made = object : LinkedHashMap<String, Pair<String, ByteArray>>(8, 0.75f, true) {override fun removeEldestEntry(eldest: MutableMap.MutableEntry<String, Pair<String, ByteArray>>) = size > 8}- fun get(bitmap: Bitmap): Pair<String, ByteArray> {- val identity = "${System.identityHashCode(bitmap)}:${bitmap.generationId}"+ fun get(track: String, bitmap: Bitmap): Pair<String, ByteArray> {+ val identity = "$track\u0001${bitmap.width}x${bitmap.height}"made[identity]?.let { return it }val scale = minOf(1f, ART_SIZE.toFloat() / maxOf(bitmap.width, bitmap.height))val small = if (scale < 1f) {@@ -205,6 +229,22 @@ class PhoneMedia(context: Context, private val onChange: (List<MediaPlayer>) ->}private companion object {+ /**+ * Whether [next] only differs from [last] by time passing: positions+ * moved on as they would while playing (or not at all while paused).+ */+ fun sameButLater(last: List<MediaPlayer>?, lastAt: Long, next: List<MediaPlayer>, now: Long): Boolean {+ if (last == null || last.size != next.size) return false+ return last.zip(next).all { (a, b) ->+ val expected = a.position?.toLong()?.plus(if (a.playing) now - lastAt else 0)+ val actual = b.position+ val drift = if (expected != null && actual != null) kotlin.math.abs(actual.toLong() - expected) else 0+ a.copy(position = null, art = null) == b.copy(position = null, art = null) && drift < POSITION_SLACK_MS+ }+ }++ /** Position jitter that isn't a seek. */+ const val POSITION_SLACK_MS = 1_500Lconst val TAG = "PhoneMedia"const val SETTLE_MS = 200Lconst val MAX_PLAYERS = 4diff --git a/android/app/src/main/kotlin/app/nectarlink/android/ui/MainActivity.kt b/android/app/src/main/kotlin/app/nectarlink/android/ui/MainActivity.ktindex 366bd39..21a69e7 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/ui/MainActivity.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/ui/MainActivity.kt@@ -162,6 +162,7 @@ private fun App(core: Core, state: CoreState, preferences: Preferences) {core::ring,core::stopRinging,onPairNew = { pairing = true },+ onRefresh = core::refresh,onSendFiles = core::sendFiles,onCancelTransfer = core::cancelTransfer,modifier = modifier,diff --git a/android/app/src/main/kotlin/app/nectarlink/android/ui/home/HomeScreen.kt b/android/app/src/main/kotlin/app/nectarlink/android/ui/home/HomeScreen.ktindex 1901423..cd8e3f6 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/ui/home/HomeScreen.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/ui/home/HomeScreen.kt@@ -54,6 +54,10 @@ import app.nectarlink.core.TransferDirectionimport app.nectarlink.core.TransferStatusimport app.nectarlink.android.notifications.NotificationListenerimport app.nectarlink.core.Link+import androidx.compose.material3.IconButton+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.ui.graphics.graphicsLayer+import kotlinx.coroutines.launch/*** Home: each paired PC with its connection and quick actions. When a PC@@ -65,6 +69,7 @@ fun HomeScreen(onRing: (id: String, on: Boolean) -> Unit,onStopRinging: () -> Unit,onPairNew: () -> Unit,+ onRefresh: () -> Unit,onSendFiles: (pcId: String, uris: List<Uri>) -> Unit,onCancelTransfer: (id: String) -> Unit,modifier: Modifier = Modifier,@@ -81,6 +86,22 @@ fun HomeScreen(style = MaterialTheme.typography.headlineMedium,modifier = Modifier.weight(1f),)+ // Reconnects and syncs with the PCs; spins once to say so.+ val spin = remember { androidx.compose.animation.core.Animatable(0f) }+ val scope = rememberCoroutineScope()+ IconButton(onClick = {+ onRefresh()+ scope.launch {+ spin.snapTo(0f)+ spin.animateTo(360f, androidx.compose.animation.core.tween(700))+ }+ }) {+ Icon(+ painterResource(R.drawable.ic_refresh),+ contentDescription = stringResource(R.string.action_refresh),+ modifier = Modifier.graphicsLayer { rotationZ = spin.value },+ )+ }FilledTonalIconButton(onClick = onPairNew) {Icon(painterResource(R.drawable.ic_qr), contentDescription = stringResource(R.string.action_pair_new))}diff --git a/android/app/src/main/res/drawable/ic_refresh.xml b/android/app/src/main/res/drawable/ic_refresh.xmlnew file mode 100644index 0000000..e7b756f--- /dev/null+++ b/android/app/src/main/res/drawable/ic_refresh.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- SPDX-License-Identifier: GPL-3.0-or-later -->+<!-- Refresh: a circular arrow (same shape as the PC app's). -->+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">+ <path+ android:pathData="M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7"+ android:strokeColor="#FF000000"+ android:strokeWidth="1.8"+ android:strokeLineCap="round"+ android:strokeLineJoin="round"+ android:fillColor="#00000000" />+</vector>diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xmlindex 0c8e4a2..4928fbb 100644--- a/android/app/src/main/res/values/strings.xml+++ b/android/app/src/main/res/values/strings.xml@@ -119,6 +119,7 @@<string name="action_stop_ringing">Stop ringing</string><string name="action_unpair">Unpair</string><string name="action_pair_new">Pair another PC</string>+ <string name="action_refresh">Refresh</string><!-- Notifications --><string name="channel_connection">Connection</string>diff --git a/core/nectarlink-core/Cargo.toml b/core/nectarlink-core/Cargo.tomlindex 03fc9fc..225ce95 100644--- a/core/nectarlink-core/Cargo.toml+++ b/core/nectarlink-core/Cargo.toml@@ -17,6 +17,7 @@ rand.workspace = truerusqlite.workspace = trueserde.workspace = truethiserror.workspace = true+bytes.workspace = truetokio.workspace = truetokio-util.workspace = truetracing.workspace = truediff --git a/core/nectarlink-core/src/node.rs b/core/nectarlink-core/src/node.rsindex 3d439a3..6040126 100644--- a/core/nectarlink-core/src/node.rs+++ b/core/nectarlink-core/src/node.rs@@ -51,6 +51,9 @@ const EVENT_CAPACITY: usize = 512;/// device that drops off the network shows as offline within seconds/// instead of after QUIC's default of 30 s.const IDLE_TIMEOUT: Duration = Duration::from_secs(8);+/// Flow-control windows: how much may be in flight per stream and in all.+const STREAM_WINDOW: u32 = 16 * 1024 * 1024;+const CONNECTION_WINDOW: u32 = 32 * 1024 * 1024;/// Capabilities every build offers.const BASE_CAPABILITIES: &[&str] =@@ -702,6 +705,20 @@ impl Node {}}+ /// What a "refresh" button does: reconnects to devices that aren't+ /// connected, and brings connected ones back in sync both ways (their+ /// notifications and media here, this device's there).+ pub async fn refresh(&self) {+ self.network_changed().await;+ self.shared.refresh_all_capabilities();+ for session in self.shared.live_sessions() {+ let _ = session.send(Envelope::empty(types::NOTIFY_SYNC)).await;+ let _ = session.send(Envelope::empty(types::MEDIA_SYNC)).await;+ self.shared.send_notification_snapshot(&session).await;+ self.shared.send_media_state(&session).await;+ }+ }+/// Devices discovered on the local network that aren't paired yet.pub fn discovered_devices(&self) -> Vec<DiscoveredDevice> {lock(&self.shared.discovered).values().cloned().collect()@@ -1028,6 +1045,12 @@ async fn bind_endpoint() -> Result<Endpoint> {let transport = QuicTransportConfig::builder().max_idle_timeout(Some(IDLE_TIMEOUT.try_into().expect("the idle timeout fits a QUIC varint")))+ // Room for a file transfer to keep the link busy through Wi-Fi's+ // latency spikes (the defaults suit ~100 Mbit/s at 100 ms; a phone+ // on Wi-Fi 6 does several times that, with bursts of delay).+ .stream_receive_window(VarInt::from_u32(STREAM_WINDOW))+ .receive_window(VarInt::from_u32(CONNECTION_WINDOW))+ .send_window(u64::from(CONNECTION_WINDOW)).build();let mut builder = Endpoint::builder(presets::Minimal).secret_key(secret)diff --git a/core/nectarlink-core/src/transfer.rs b/core/nectarlink-core/src/transfer.rsindex f2a0231..0090e2a 100644--- a/core/nectarlink-core/src/transfer.rs+++ b/core/nectarlink-core/src/transfer.rs@@ -9,6 +9,7 @@ use std::{time::{Duration, Instant},};+use bytes::Bytes;use iroh::endpoint::{ReadError, RecvStream, SendStream, VarInt, WriteError};use nectarlink_protocol::{DeviceId, Envelope, ErrorCode,@@ -17,7 +18,7 @@ use nectarlink_protocol::{},read_frame, write_frame,};-use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};+use tokio::io::AsyncWriteExt;use tokio_util::sync::CancellationToken;use crate::{Error, Result, events::NodeEvent, node::Shared, session::Session};@@ -34,6 +35,13 @@ const PROGRESS_EVERY: Duration = Duration::from_millis(200);/// Partly received files are kept this long for resuming.const KEEP_PARTIAL: Duration = Duration::from_secs(60 * 60);const CHUNK: usize = 256 * 1024;+/// The sender reads ahead in blocks of this size, this many at a time, so+/// the disk is read while the network sends.+const BLOCK: usize = 1024 * 1024;+const READ_AHEAD: usize = 8;+/// The receiver writes the disk in pieces this large (QUIC delivers a few+/// kilobytes at a time).+const WRITE_BUFFER: usize = 4 * 1024 * 1024;#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum Direction {@@ -315,51 +323,47 @@ async fn attempt(reporter.set(TransferState::Running);let mut done: u64 = files.iter().zip(&have).map(|((_, size, _), have)| (*have).min(*size)).sum();reporter.progress(done);- let mut buf = vec![0u8; CHUNK];- for ((_, size, file), have) in files.iter_mut().zip(&have) {+ // What's left of each file, read on a thread of its own that keeps a+ // few blocks ready; it stops when this attempt ends and drops them.+ let mut plan = Vec::with_capacity(files.len());+ for ((_, size, file), have) in files.iter().zip(&have) {let start = (*have).min(*size);- if file.seek(std::io::SeekFrom::Start(start)).await.is_err() {+ let Ok(clone) = file.try_clone().await else {return Attempt::Fatal(TransferFailure::Other("can't read a file".into()));- }- let mut left = *size - start;- while left > 0 {- let want = buf.len().min(usize::try_from(left).unwrap_or(usize::MAX));- let read = tokio::select! {- _ = cancel.cancelled() => {- let _ = send.reset(VarInt::from_u32(files::CANCELLED));- return Attempt::Cancelled;- }- read = file.read(&mut buf[..want]) => read,- };- let n = match read {- Ok(0) => {- return Attempt::Fatal(TransferFailure::Other("a file got shorter while sending".into()));- }- Ok(n) => n,- Err(e) => {- return Attempt::Fatal(TransferFailure::Other(format!(- "can't read a file: {}",- e.kind()- )));- }- };- let written = tokio::select! {- _ = cancel.cancelled() => {- let _ = send.reset(VarInt::from_u32(files::CANCELLED));- return Attempt::Cancelled;- }- written = send.write_all(&buf[..n]) => written,- };- if let Err(e) = written {- return match e {- WriteError::Stopped(code) => stopped(code),- _ => Attempt::Retry,- };+ };+ plan.push((clone.into_std().await, start, *size - start));+ }+ let (blocks, mut ready) = tokio::sync::mpsc::channel(READ_AHEAD);+ tokio::task::spawn_blocking(move || read_ahead(plan, &blocks));+ loop {+ let block = tokio::select! {+ _ = cancel.cancelled() => {+ let _ = send.reset(VarInt::from_u32(files::CANCELLED));+ return Attempt::Cancelled;}- left -= n as u64;- done += n as u64;- reporter.progress(done);+ block = ready.recv() => block,+ };+ let block = match block {+ None => break,+ Some(Ok(block)) => block,+ Some(Err(failure)) => return Attempt::Fatal(failure),+ };+ let n = block.len() as u64;+ let written = tokio::select! {+ _ = cancel.cancelled() => {+ let _ = send.reset(VarInt::from_u32(files::CANCELLED));+ return Attempt::Cancelled;+ }+ written = send.write_chunk(block) => written,+ };+ if let Err(e) = written {+ return match e {+ WriteError::Stopped(code) => stopped(code),+ _ => Attempt::Retry,+ };}+ done += n;+ reporter.progress(done);}if send.finish().is_err() {return Attempt::Retry;@@ -521,6 +525,38 @@ async fn receive(shared: Arc<Shared>, peer: DeviceId, mut send: SendStream, mut}#[allow(clippy::too_many_arguments)]+/// Reads each file's remaining bytes, from where the receiver is, in+/// blocks; stops early when the sending side is gone.+fn read_ahead(+ plan: Vec<(std::fs::File, u64, u64)>,+ blocks: &tokio::sync::mpsc::Sender<std::result::Result<Bytes, TransferFailure>>,+) {+ use std::io::{Read, Seek, SeekFrom};+ for (mut file, start, mut left) in plan {+ if let Err(e) = file.seek(SeekFrom::Start(start)) {+ let failure = TransferFailure::Other(format!("can't read a file: {}", e.kind()));+ let _ = blocks.blocking_send(Err(failure));+ return;+ }+ while left > 0 {+ let mut block = vec![0u8; BLOCK.min(usize::try_from(left).unwrap_or(usize::MAX))];+ if let Err(e) = file.read_exact(&mut block) {+ let failure = if e.kind() == std::io::ErrorKind::UnexpectedEof {+ TransferFailure::Other("a file got shorter while sending".into())+ } else {+ TransferFailure::Other(format!("can't read a file: {}", e.kind()))+ };+ let _ = blocks.blocking_send(Err(failure));+ return;+ }+ left -= block.len() as u64;+ if blocks.blocking_send(Ok(Bytes::from(block))).is_err() {+ return;+ }+ }+ }+}+async fn receive_bytes(reporter: &mut Reporter,offer: &FilesOffer,@@ -532,7 +568,7 @@ async fn receive_bytes() -> std::result::Result<(), TransferState> {let mut done: u64 = have.iter().sum();for (i, (file, have)) in offer.files.iter().zip(have).enumerate() {- let mut out =+ let out =tokio::fs::OpenOptions::new().create(true).append(true).open(part(i)).await.map_err(|e| {TransferState::Failed(TransferFailure::Other(format!("can't write: {}", e.kind())))})?;@@ -540,6 +576,7 @@ async fn receive_bytes(if *have < out.metadata().await.map(|m| m.len()).unwrap_or(0) {out.set_len(*have).await.ok();}+ let mut out = tokio::io::BufWriter::with_capacity(WRITE_BUFFER, out);let mut left = file.size - have;while left > 0 {let max = CHUNK.min(usize::try_from(left).unwrap_or(usize::MAX));@@ -553,12 +590,19 @@ async fn receive_bytes(};let bytes = match chunk {Ok(Some(bytes)) => bytes,- Ok(None) => return Err(TransferState::Waiting),+ Ok(None) => {+ out.flush().await.ok();+ return Err(TransferState::Waiting);+ }Err(ReadError::Reset(code)) if code.into_inner() == u64::from(files::CANCELLED) => {return Err(TransferState::Cancelled);}- // The connection dropped: the sender resumes when it's back.- Err(_) => return Err(TransferState::Waiting),+ // The connection dropped: keep what arrived; the sender+ // resumes from there when it's back.+ Err(_) => {+ out.flush().await.ok();+ return Err(TransferState::Waiting);+ }};if let Err(e) = out.write_all(&bytes).await {let no_space = e.kind() == std::io::ErrorKind::StorageFull;@@ -574,7 +618,16 @@ async fn receive_bytes(done += bytes.len() as u64;reporter.progress(done);}- out.flush().await.ok();+ if let Err(e) = out.flush().await {+ let no_space = e.kind() == std::io::ErrorKind::StorageFull;+ let code = if no_space { ErrorCode::Busy } else { ErrorCode::Internal };+ let _ = recv.stop(VarInt::from_u32(code.close_code()));+ return Err(TransferState::Failed(if no_space {+ TransferFailure::NoSpace+ } else {+ TransferFailure::Other(format!("can't write: {}", e.kind()))+ }));+ }}Ok(())}diff --git a/core/nectarlink-ffi/src/lib.rs b/core/nectarlink-ffi/src/lib.rsindex 3facb82..f3bcda2 100644--- a/core/nectarlink-ffi/src/lib.rs+++ b/core/nectarlink-ffi/src/lib.rs@@ -1215,6 +1215,12 @@ impl NectarlinkNode {self.run(async move { node.update_power(power.into(), capabilities).await }).await;}+ /// Reconnects to PCs that aren't connected and syncs connected ones.+ pub async fn refresh(&self) {+ let node = self.node.clone();+ self.run(async move { node.refresh().await }).await;+ }+/// Call when connectivity changes (Android doesn't tell native code).pub async fn network_changed(&self) {let node = self.node.clone();diff --git a/desktop/app/qml/MainWindow.qml b/desktop/app/qml/MainWindow.qmlindex 3cad59f..8f89d62 100644--- a/desktop/app/qml/MainWindow.qml+++ b/desktop/app/qml/MainWindow.qml@@ -150,6 +150,29 @@ NativeWindow {role: "headline"size: 20}+ // Reconnects and syncs with the phones (the title bar lets+ // clicks through here).+ IconButton {+ id: refresh+ anchors.right: parent.right+ anchors.rightMargin: 8+ anchors.verticalCenter: parent.verticalCenter+ visible: window.page === "home" && AppController.hasDevices+ iconPath: Icons.refresh+ label: qsTr("Refresh")+ onClicked: {+ AppController.syncNow()+ if (!Theme.reduceMotion) spin.restart()+ }+ RotationAnimation on rotation {+ id: spin+ running: false+ from: 0; to: 360+ duration: 700+ easing.type: Easing.OutCubic+ }+ Component.onCompleted: window.addCaptionHole(refresh)+ }}Divider { anchors.top: topBar.bottom; width: parent.width }diff --git a/desktop/app/src/bridge/app.rs b/desktop/app/src/bridge/app.rsindex b4b1466..4a0c410 100644--- a/desktop/app/src/bridge/app.rs+++ b/desktop/app/src/bridge/app.rs@@ -68,6 +68,10 @@ pub mod qobject {/// Stops this PC ringing.#[qinvokable]fn stop_ringing(self: Pin<&mut AppController>);+ /// Reconnects to phones that aren't connected and syncs connected+ /// ones (notifications, media).+ #[qinvokable]+ fn sync_now(self: Pin<&mut AppController>);#[qinvokable]fn unpair(self: Pin<&mut AppController>, device: &QString);@@ -318,6 +322,12 @@ impl qobject::AppController {}}+ pub fn sync_now(self: Pin<&mut Self>) {+ if let Some(node) = core_host::node() {+ core_host::spawn(async move { node.refresh().await });+ }+ }+pub fn stop_ringing(self: Pin<&mut Self>) {sound::stop_ringing();core_host::host()