Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
Your phone on Home: its real screen, and what's new on it
Bee7b3022f52632
diff --git a/README.md b/README.mdindex 3e6c781..853c576 100644--- a/README.md+++ b/README.md@@ -67,8 +67,11 @@ tests; there are no releases yet.- **Encrypted connections** over the local network (QUIC through[iroh](https://iroh.computer)), with automatic reconnection after restarts,sleep and network changes.-- **Live status** of each paired device: connection, round-trip time, battery,- power level.+- **Live status** of each paired device: connection, round-trip time, battery+ (with charging source and estimated time to full when available), power level,+ a vector preview of the phone's measured front screen shape (aspect ratio,+ corner radii and camera cutout), and a glanceable Home summary of unread+ messages, missed calls and the latest photo or screenshot.- **Find my device** in both directions. The phone rings on the alarm stream,even in silent mode.- **Lock, sleep or wake the PC** from the phone (when the PC is offline, Wakediff --git a/android/app/src/main/kotlin/app/nectarlink/android/core/SystemMonitors.kt b/android/app/src/main/kotlin/app/nectarlink/android/core/SystemMonitors.ktindex 60d90e3..18d0fbf 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/core/SystemMonitors.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/core/SystemMonitors.kt@@ -5,6 +5,9 @@ import android.content.BroadcastReceiverimport android.content.Contextimport android.content.Intentimport android.content.IntentFilter+import android.graphics.Path+import android.graphics.PathMeasure+import android.hardware.display.DisplayManagerimport android.net.ConnectivityManagerimport android.net.LinkPropertiesimport android.net.Network@@ -12,10 +15,19 @@ import android.net.NetworkCapabilitiesimport android.os.BatteryManagerimport android.os.Buildimport android.provider.Settings+import android.util.DisplayMetrics+import android.view.Display+import android.view.RoundedCorner+import android.view.Surface+import android.view.WindowManagerimport androidx.core.content.ContextCompatimport app.nectarlink.core.Batteryimport app.nectarlink.core.DeviceInfoimport app.nectarlink.core.DeviceKind+import app.nectarlink.core.ScreenCorners+import app.nectarlink.core.ScreenRect+import app.nectarlink.core.ScreenShape+import java.util.Locale/** How this phone presents itself to PCs. */fun deviceInfo(context: Context): DeviceInfo {@@ -29,9 +41,217 @@ fun deviceInfo(context: Context): DeviceInfo {osVersion = Build.VERSION.RELEASE,model = "${Build.MANUFACTURER.replaceFirstChar(Char::uppercase)} ${Build.MODEL}",accent = null,+ screen = measureScreenShape(context),)}+/**+ * Measures the phone's physical front screen shape in its natural (`ROTATION_0`)+ * orientation, normalized to fractions of the display so the PC can draw the+ * exact aspect ratio, corner radii and camera cutout without model tables.+ */+fun measureScreenShape(context: Context): ScreenShape? = runCatching {+ val wm = context.getSystemService(WindowManager::class.java) ?: return null+ val display = context.getSystemService(DisplayManager::class.java)+ ?.getDisplay(Display.DEFAULT_DISPLAY)+ val rotation = display?.rotation ?: Surface.ROTATION_0++ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {+ val metrics = wm.maximumWindowMetrics+ val bounds = metrics.bounds+ val rawW = bounds.width()+ val rawH = bounds.height()+ val (w0, h0) = unrotateDimensions(rawW, rawH, rotation)+ if (w0 <= 0 || h0 <= 0) return null++ val insets = metrics.windowInsets+ val cutout = insets.displayCutout+ val cutouts = cutout?.boundingRects.orEmpty()+ .take(4)+ .mapNotNull { r ->+ normalizeCutoutRect(r.left, r.top, r.right, r.bottom, rawW, rawH, rotation)+ }++ val corners = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {+ fun cornerRadius(pos: Int): Int =+ insets.getRoundedCorner(pos)?.radius+ ?: display?.getRoundedCorner(pos)?.radius+ ?: 0+ normalizeCorners(+ topLeftPx = cornerRadius(RoundedCorner.POSITION_TOP_LEFT),+ topRightPx = cornerRadius(RoundedCorner.POSITION_TOP_RIGHT),+ bottomRightPx = cornerRadius(RoundedCorner.POSITION_BOTTOM_RIGHT),+ bottomLeftPx = cornerRadius(RoundedCorner.POSITION_BOTTOM_LEFT),+ rawW = rawW,+ rawH = rawH,+ rotation = rotation,+ )+ } else {+ null+ }++ val cutoutPath = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {+ cutout?.cutoutPath?.let { sampleCutoutPath(it, rawW, rawH, rotation) }+ } else {+ null+ }++ ScreenShape(+ aspect = (w0.toFloat() / h0.toFloat()).coerceIn(0.25f, 2.5f),+ corners = corners,+ cutouts = cutouts,+ cutoutPath = cutoutPath,+ )+ } else {+ @Suppress("DEPRECATION")+ val legacyDisplay = display ?: wm.defaultDisplay ?: return null+ val dm = DisplayMetrics()+ @Suppress("DEPRECATION")+ legacyDisplay.getRealMetrics(dm)+ val rawW = dm.widthPixels+ val rawH = dm.heightPixels+ val (w0, h0) = unrotateDimensions(rawW, rawH, rotation)+ if (w0 <= 0 || h0 <= 0) return null++ val cutouts = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {+ legacyDisplay.cutout?.boundingRects.orEmpty()+ .take(4)+ .mapNotNull { r ->+ normalizeCutoutRect(r.left, r.top, r.right, r.bottom, rawW, rawH, rotation)+ }+ } else {+ emptyList()+ }++ ScreenShape(+ aspect = (w0.toFloat() / h0.toFloat()).coerceIn(0.25f, 2.5f),+ corners = null,+ cutouts = cutouts,+ cutoutPath = null,+ )+ }+}.getOrNull()++internal fun unrotateDimensions(rawW: Int, rawH: Int, rotation: Int): Pair<Int, Int> = when (rotation) {+ Surface.ROTATION_90, Surface.ROTATION_270 -> rawH to rawW+ else -> rawW to rawH+}++internal fun unrotatePoint(x: Float, y: Float, rawW: Float, rawH: Float, rotation: Int): Pair<Float, Float> =+ when (rotation) {+ Surface.ROTATION_90 -> (rawH - y) to x+ Surface.ROTATION_180 -> (rawW - x) to (rawH - y)+ Surface.ROTATION_270 -> y to (rawW - x)+ else -> x to y+ }++internal fun normalizeCutoutRect(+ left: Int,+ top: Int,+ right: Int,+ bottom: Int,+ rawW: Int,+ rawH: Int,+ rotation: Int,+): ScreenRect? {+ if (rawW <= 0 || rawH <= 0 || right <= left || bottom <= top) return null+ val (w0, h0) = unrotateDimensions(rawW, rawH, rotation)+ if (w0 <= 0 || h0 <= 0) return null+ val (x1, y1) = unrotatePoint(left.toFloat(), top.toFloat(), rawW.toFloat(), rawH.toFloat(), rotation)+ val (x2, y2) = unrotatePoint(right.toFloat(), bottom.toFloat(), rawW.toFloat(), rawH.toFloat(), rotation)+ val minX = minOf(x1, x2)+ val maxX = maxOf(x1, x2)+ val minY = minOf(y1, y2)+ val maxY = maxOf(y1, y2)+ val nx = (minX / w0.toFloat()).coerceIn(0f, 1f)+ val ny = (minY / h0.toFloat()).coerceIn(0f, 1f)+ val nw = ((maxX - minX) / w0.toFloat()).coerceIn(0f, 1f - nx)+ val nh = ((maxY - minY) / h0.toFloat()).coerceIn(0f, 1f - ny)+ if (nw <= 0f || nh <= 0f) return null+ return ScreenRect(x = nx, y = ny, w = nw, h = nh)+}++internal fun normalizeCorners(+ topLeftPx: Int,+ topRightPx: Int,+ bottomRightPx: Int,+ bottomLeftPx: Int,+ rawW: Int,+ rawH: Int,+ rotation: Int,+): ScreenCorners? {+ val (w0, _) = unrotateDimensions(rawW, rawH, rotation)+ if (w0 <= 0) return null+ val (tl, tr, br, bl) = when (rotation) {+ Surface.ROTATION_90 -> listOf(bottomLeftPx, topLeftPx, topRightPx, bottomRightPx)+ Surface.ROTATION_180 -> listOf(bottomRightPx, bottomLeftPx, topLeftPx, topRightPx)+ Surface.ROTATION_270 -> listOf(topRightPx, bottomRightPx, bottomLeftPx, topLeftPx)+ else -> listOf(topLeftPx, topRightPx, bottomRightPx, bottomLeftPx)+ }+ if (tl <= 0 && tr <= 0 && br <= 0 && bl <= 0) return null+ val w = w0.toFloat()+ return ScreenCorners(+ tl = (tl.coerceAtLeast(0) / w).coerceIn(0f, 0.5f),+ tr = (tr.coerceAtLeast(0) / w).coerceIn(0f, 0.5f),+ br = (br.coerceAtLeast(0) / w).coerceIn(0f, 0.5f),+ bl = (bl.coerceAtLeast(0) / w).coerceIn(0f, 0.5f),+ )+}++private fun sampleCutoutPath(path: Path, rawW: Int, rawH: Int, rotation: Int): String? {+ val pm = PathMeasure(path, false)+ val contours = mutableListOf<List<Pair<Float, Float>>>()+ val pos = FloatArray(2)+ do {+ val len = pm.length+ if (len > 0f && contours.size < 4) {+ val steps = 20+ val pts = ArrayList<Pair<Float, Float>>(steps)+ for (i in 0 until steps) {+ if (pm.getPosTan(len * i / steps.toFloat(), pos, null)) {+ pts.add(pos[0] to pos[1])+ }+ }+ if (pts.size >= 3) contours.add(pts)+ }+ } while (pm.nextContour() && contours.size < 4)+ return buildNormalizedSvgPath(contours, rawW, rawH, rotation)+}++internal fun buildNormalizedSvgPath(+ contours: List<List<Pair<Float, Float>>>,+ rawW: Int,+ rawH: Int,+ rotation: Int,+): String? {+ val (w0, h0) = unrotateDimensions(rawW, rawH, rotation)+ if (w0 <= 0 || h0 <= 0 || contours.isEmpty()) return null+ val sb = StringBuilder()+ fun fmt(v: Float): String =+ String.format(Locale.US, "%.4f", v.coerceIn(0f, 1f))+ .trimEnd('0')+ .trimEnd('.')+ .ifEmpty { "0" }++ for (pts in contours) {+ if (pts.size < 3) continue+ pts.forEachIndexed { idx, (px, py) ->+ val (ux, uy) = unrotatePoint(px, py, rawW.toFloat(), rawH.toFloat(), rotation)+ val nx = fmt(ux / w0.toFloat())+ val ny = fmt(uy / h0.toFloat())+ if (idx == 0) {+ if (sb.isNotEmpty()) sb.append(' ')+ sb.append("M ").append(nx).append(' ').append(ny)+ } else {+ sb.append(" L ").append(nx).append(' ').append(ny)+ }+ }+ sb.append(" Z")+ }+ val out = sb.toString()+ return out.takeIf { it.isNotEmpty() && it.length <= 512 }+}+/** Reports the battery whenever it changes meaningfully. */class BatteryMonitor(private val context: Context, private val onChange: (Battery) -> Unit) {private var last: Battery? = null@@ -50,7 +270,18 @@ class BatteryMonitor(private val context: Context, private val onChange: (Batterval status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1)val charging = status == BatteryManager.BATTERY_STATUS_CHARGING ||status == BatteryManager.BATTERY_STATUS_FULL- val battery = Battery((level * 100 / scale).coerceIn(0, 100).toUByte(), charging, plugged)+ val fullIn: UShort? = if (charging && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {+ val bm = context.getSystemService(BatteryManager::class.java)+ val remainingMs = runCatching { bm?.computeChargeTimeRemaining() ?: -1L }.getOrDefault(-1L)+ if (remainingMs > 0L) {+ ((remainingMs + 59_999L) / 60_000L).coerceIn(1L, 1440L).toUShort()+ } else {+ null+ }+ } else {+ null+ }+ val battery = Battery((level * 100 / scale).coerceIn(0, 100).toUByte(), charging, plugged, fullIn)if (battery != last) {last = batteryonChange(battery)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 23dbcad..d76d7ed 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@@ -394,7 +394,28 @@ private fun PcCard(contentColor = MaterialTheme.colorScheme.onPrimaryContainer,) {Column(Modifier.fillMaxWidth().padding(24.dp)) {- Row(verticalAlignment = Alignment.CenterVertically) {+ val context = LocalContext.current+ // Secondary buttons take their colors from the card, so they+ // stand out on it in every theme (the theme's own tonal color+ // can be the card's color, as in Graphite).+ val ink = MaterialTheme.colorScheme.onPrimaryContainer+ val primaryBtn = ButtonDefaults.buttonColors(+ disabledContainerColor = ink.copy(alpha = 0.08f),+ disabledContentColor = ink.copy(alpha = 0.38f),+ )+ val tonal = ButtonDefaults.filledTonalButtonColors(+ containerColor = ink.copy(alpha = 0.10f),+ contentColor = ink,+ disabledContainerColor = ink.copy(alpha = 0.05f),+ disabledContentColor = ink.copy(alpha = 0.38f),+ )+ val outlined = ButtonDefaults.outlinedButtonColors(contentColor = ink, disabledContentColor = ink.copy(alpha = 0.38f))+ val outline = BorderStroke(1.dp, ink.copy(alpha = if (device.online) 0.45f else 0.15f))++ Row(+ modifier = Modifier.fillMaxWidth(),+ verticalAlignment = Alignment.CenterVertically,+ ) {Box(Modifier.size(10.dp).padding(1.dp),) {@@ -412,7 +433,23 @@ private fun PcCard(linkText(device.link)},style = MaterialTheme.typography.labelLarge,+ modifier = Modifier.weight(1f),)+ if (!device.online && device.canWake && device.wakeState != WakeState.Waking) {+ Spacer(Modifier.width(8.dp))+ FilledTonalButton(+ colors = tonal,+ onClick = { onWake(device.id) },+ contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 14.dp, vertical = 4.dp),+ modifier = Modifier.heightIn(min = 32.dp),+ ) {+ Text(+ stringResource(R.string.action_wake_pc),+ style = MaterialTheme.typography.labelMedium,+ maxLines = 1,+ )+ }+ }}Spacer(Modifier.height(12.dp))Text(device.name, style = MaterialTheme.typography.headlineLarge)@@ -432,55 +469,22 @@ private fun PcCard()}Spacer(Modifier.height(20.dp))- val context = LocalContext.current- // Secondary buttons take their colors from the card, so they- // stand out on it in every theme (the theme's own tonal color- // can be the card's color, as in Graphite).- val ink = MaterialTheme.colorScheme.onPrimaryContainer- val tonal = ButtonDefaults.filledTonalButtonColors(- containerColor = ink.copy(alpha = 0.10f),- contentColor = ink,- disabledContainerColor = ink.copy(alpha = 0.05f),- disabledContentColor = ink.copy(alpha = 0.38f),- )- val outlined = ButtonDefaults.outlinedButtonColors(contentColor = ink, disabledContentColor = ink.copy(alpha = 0.38f))- val outline = BorderStroke(1.dp, ink.copy(alpha = if (device.online) 0.45f else 0.15f))Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {- if (!device.online && device.wakeState == WakeState.Idle && device.canWake) {- Button(- enabled = device.wakeState != WakeState.Waking,- onClick = { onWake(device.id) },- modifier = Modifier.fillMaxWidth(),- ) {- Text(- if (device.wakeState == WakeState.Waking) stringResource(R.string.wake_waking, device.name)- else stringResource(R.string.action_wake_pc),- )- }- } else if (!device.online && device.canWake) {- Button(- enabled = device.wakeState != WakeState.Waking,- onClick = { onWake(device.id) },- modifier = Modifier.fillMaxWidth(),- ) {- Text(- if (device.wakeState == WakeState.Waking) stringResource(R.string.wake_waking, device.name)- else stringResource(R.string.action_wake_pc),- )- }- }// Primary 2x2 grid: Control PC, Deck, Webcam, Send filesRow(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.spacedBy(8.dp),) {Button(+ enabled = device.online,+ colors = primaryBtn,onClick = { onRemote(device.id) },modifier = Modifier.weight(1f),) {Text(stringResource(R.string.action_remote_pc), maxLines = 1, overflow = TextOverflow.Ellipsis)}FilledTonalButton(+ enabled = device.online,colors = tonal,onClick = { onDeck(device.id) },modifier = Modifier.weight(1f),@@ -493,6 +497,7 @@ private fun PcCard(horizontalArrangement = Arrangement.spacedBy(8.dp),) {FilledTonalButton(+ enabled = device.online,colors = tonal,onClick = { onWebcam(device.id) },modifier = Modifier.weight(1f),@@ -516,7 +521,6 @@ private fun PcCard(pcName = device.name,deckState = deckState,ink = ink,- tonal = tonal,onSetPcAudio = { vol, muted -> onSetPcAudio(device.id, vol, muted) },)}@@ -668,7 +672,6 @@ private fun PcAudioCardSection(pcName: String,deckState: DeckState,ink: Color,- tonal: androidx.compose.material3.ButtonColors,onSetPcAudio: (volume: Int?, muted: Boolean?) -> Unit,) {var draggingVolume by remember { mutableStateOf<Float?>(null) }@@ -682,23 +685,25 @@ private fun PcAudioCardSection(contentColor = ink,) {Column(- modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 10.dp),- verticalArrangement = Arrangement.spacedBy(4.dp),+ modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp, vertical = 6.dp),+ verticalArrangement = Arrangement.spacedBy(0.dp),) {Row(modifier = Modifier.fillMaxWidth(),verticalAlignment = Alignment.CenterVertically,- horizontalArrangement = Arrangement.spacedBy(8.dp),+ horizontalArrangement = Arrangement.spacedBy(6.dp),) {- FilledTonalButton(- colors = tonal,+ IconButton(onClick = { onSetPcAudio(null, !deckState.muted) },- contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 12.dp, vertical = 6.dp),+ modifier = Modifier.size(32.dp),) {- Text(- stringResource(if (deckState.muted) R.string.pc_audio_unmute else R.string.pc_audio_mute),- style = MaterialTheme.typography.labelLarge,- maxLines = 1,+ Icon(+ painter = painterResource(if (deckState.muted) R.drawable.ic_sound_off else R.drawable.ic_speaker),+ contentDescription = stringResource(+ if (deckState.muted) R.string.pc_audio_unmute else R.string.pc_audio_mute,+ ),+ tint = ink.copy(alpha = if (deckState.muted) 0.55f else 0.9f),+ modifier = Modifier.size(20.dp),)}Slider(@@ -714,7 +719,7 @@ private fun PcAudioCardSection(activeTrackColor = ink,inactiveTrackColor = ink.copy(alpha = 0.22f),),- modifier = Modifier.weight(1f),+ modifier = Modifier.weight(1f).height(32.dp),)Text(text = if (deckState.muted) {@@ -722,7 +727,7 @@ private fun PcAudioCardSection(} else {stringResource(R.string.deck_volume_percent, shownVolume)},- style = MaterialTheme.typography.labelLarge,+ style = MaterialTheme.typography.labelMedium,)}if (defaultOutput != null) {@@ -730,14 +735,14 @@ private fun PcAudioCardSection(modifier = Modifier.fillMaxWidth().clickable { showOutputs = true }- .padding(horizontal = 4.dp, vertical = 4.dp),+ .padding(start = 38.dp, end = 4.dp, bottom = 2.dp),verticalAlignment = Alignment.CenterVertically,horizontalArrangement = Arrangement.SpaceBetween,) {Text(- text = stringResource(R.string.pc_audio_output, defaultOutput.name),- style = MaterialTheme.typography.bodySmall,- color = ink.copy(alpha = 0.85f),+ text = defaultOutput.name,+ style = MaterialTheme.typography.labelSmall,+ color = ink.copy(alpha = 0.68f),maxLines = 1,overflow = TextOverflow.Ellipsis,modifier = Modifier.weight(1f),@@ -747,7 +752,7 @@ private fun PcAudioCardSection(Text(text = "${deckState.outputDevices.size}",style = MaterialTheme.typography.labelSmall,- color = ink.copy(alpha = 0.7f),+ color = ink.copy(alpha = 0.55f),)}}diff --git a/android/app/src/main/kotlin/app/nectarlink/android/ui/remote/RemoteScreen.kt b/android/app/src/main/kotlin/app/nectarlink/android/ui/remote/RemoteScreen.ktindex 250f664..eb9c671 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/ui/remote/RemoteScreen.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/ui/remote/RemoteScreen.kt@@ -20,9 +20,9 @@ import androidx.activity.compose.rememberLauncherForActivityResultimport androidx.activity.result.contract.ActivityResultContractsimport androidx.compose.foundation.BorderStrokeimport androidx.compose.foundation.Canvas+import androidx.compose.foundation.clickableimport androidx.compose.foundation.gestures.awaitEachGestureimport androidx.compose.foundation.gestures.awaitFirstDown-import androidx.compose.foundation.horizontalScrollimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Column@@ -35,14 +35,12 @@ import androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.width-import androidx.compose.foundation.rememberScrollStateimport androidx.compose.foundation.shape.CircleShapeimport androidx.compose.foundation.text.KeyboardActionsimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Buttonimport androidx.compose.material3.ButtonDefaultsimport androidx.compose.material3.FilledTonalButton-import androidx.compose.material3.FilterChipimport androidx.compose.material3.Iconimport androidx.compose.material3.IconButtonimport androidx.compose.material3.LinearProgressIndicator@@ -509,48 +507,52 @@ private fun TouchpadView(// Mouse buttons + Keyboard toggle rowRow(modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),+ horizontalArrangement = Arrangement.spacedBy(6.dp),) {FilledTonalButton(onClick = { core.remoteButton(pcId, "left", "click", onStatus) },- contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),- modifier = Modifier.weight(1f).height(48.dp),+ contentPadding = PaddingValues(horizontal = 6.dp, vertical = 6.dp),+ modifier = Modifier.weight(0.88f).height(46.dp),) {Text(stringResource(R.string.remote_left_click),+ style = MaterialTheme.typography.labelLarge,maxLines = 1,overflow = TextOverflow.Ellipsis,)}OutlinedButton(onClick = { core.remoteButton(pcId, "middle", "click", onStatus) },- contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),- modifier = Modifier.weight(1f).height(48.dp),+ contentPadding = PaddingValues(horizontal = 6.dp, vertical = 6.dp),+ modifier = Modifier.weight(1.04f).height(46.dp),) {Text(stringResource(R.string.remote_middle_click),+ style = MaterialTheme.typography.labelLarge,maxLines = 1,overflow = TextOverflow.Ellipsis,)}FilledTonalButton(onClick = { core.remoteButton(pcId, "right", "click", onStatus) },- contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),- modifier = Modifier.weight(1f).height(48.dp),+ contentPadding = PaddingValues(horizontal = 6.dp, vertical = 6.dp),+ modifier = Modifier.weight(0.94f).height(46.dp),) {Text(stringResource(R.string.remote_right_click),+ style = MaterialTheme.typography.labelLarge,maxLines = 1,overflow = TextOverflow.Ellipsis,)}Button(onClick = { showKeyboard = !showKeyboard },- contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),- modifier = Modifier.height(48.dp),+ contentPadding = PaddingValues(horizontal = 8.dp, vertical = 6.dp),+ modifier = Modifier.weight(1.26f).height(46.dp),) {Text(stringResource(R.string.remote_keyboard),+ style = MaterialTheme.typography.labelLarge,maxLines = 1,overflow = TextOverflow.Ellipsis,)@@ -569,6 +571,7 @@ private fun TouchpadView(// Special keys & modifiers bar (always accessible in Touchpad mode)SpecialKeysBar(activeMods = activeMods,+ showExtraKeys = showKeyboard,onToggleMod = { mod ->if (mod in activeMods) activeMods.remove(mod) else activeMods.add(mod)},@@ -1171,25 +1174,61 @@ private fun VoiceTypingBar(@Composableprivate fun SpecialKeysBar(activeMods: List<String>,+ showExtraKeys: Boolean,onToggleMod: (String) -> Unit,onKey: (key: String, forceMods: List<String>?) -> Unit,) {- Row(- modifier = Modifier- .fillMaxWidth()- .horizontalScroll(rememberScrollState()),- horizontalArrangement = Arrangement.spacedBy(6.dp),- verticalAlignment = Alignment.CenterVertically,+ Column(+ modifier = Modifier.fillMaxWidth(),+ verticalArrangement = Arrangement.spacedBy(6.dp),) {+ // Modifier keys row: 4 equal columns that fit at every font scale without overflowingval mods = listOf("ctrl" to "Ctrl", "alt" to "Alt", "shift" to "Shift", "win" to "Win")- for ((id, label) in mods) {- FilterChip(- selected = id in activeMods,- onClick = { onToggleMod(id) },- label = { Text(label) },- )+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(6.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ for ((id, label) in mods) {+ val selected = id in activeMods+ Surface(+ shape = MaterialTheme.shapes.small,+ color = if (selected) {+ MaterialTheme.colorScheme.secondaryContainer+ } else {+ MaterialTheme.colorScheme.surfaceContainer+ },+ contentColor = if (selected) {+ MaterialTheme.colorScheme.onSecondaryContainer+ } else {+ MaterialTheme.colorScheme.onSurface+ },+ border = BorderStroke(+ width = 1.dp,+ color = if (selected) {+ MaterialTheme.colorScheme.primary+ } else {+ MaterialTheme.colorScheme.outlineVariant+ },+ ),+ modifier = Modifier+ .weight(1f)+ .height(36.dp)+ .clickable { onToggleMod(id) },+ ) {+ Box(contentAlignment = Alignment.Center, modifier = Modifier.padding(horizontal = 4.dp)) {+ Text(+ text = label,+ style = MaterialTheme.typography.labelMedium,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ }+ }+ }}+ // Navigation & special keys row: 6 equal columns across the full widthval keys = listOf("escape" to "Esc","tab" to "Tab",@@ -1197,35 +1236,69 @@ private fun SpecialKeysBar("up" to "↑","down" to "↓","right" to "→",- "backspace" to "Bksp",- "enter" to "Enter",- "space" to "Space",- "home" to "Home",- "end" to "End",- "page_up" to "PgUp",- "page_down" to "PgDn",- "delete" to "Del",)- for ((key, label) in keys) {- OutlinedButton(- onClick = { onKey(key, null) },- contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp),- ) {- Text(label, style = MaterialTheme.typography.labelMedium)+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(6.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ for ((key, label) in keys) {+ Surface(+ shape = MaterialTheme.shapes.small,+ color = MaterialTheme.colorScheme.surface,+ contentColor = MaterialTheme.colorScheme.onSurface,+ border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),+ modifier = Modifier+ .weight(1f)+ .height(36.dp)+ .clickable { onKey(key, null) },+ ) {+ Box(contentAlignment = Alignment.Center, modifier = Modifier.padding(horizontal = 2.dp)) {+ Text(+ text = label,+ style = MaterialTheme.typography.labelMedium,+ maxLines = 1,+ )+ }+ }}}- val shortcuts = listOf(- "copy" to "Copy",- "paste" to "Paste",- "undo" to "Undo",- )- for ((shortcut, label) in shortcuts) {- OutlinedButton(- onClick = { onKey(shortcut, emptyList()) },- contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp),+ if (showExtraKeys) {+ val extra = listOf(+ "home" to "Home",+ "end" to "End",+ "delete" to "Del",+ "copy" to "Copy",+ "paste" to "Paste",+ )+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(6.dp),+ verticalAlignment = Alignment.CenterVertically,) {- Text(label, style = MaterialTheme.typography.labelMedium)+ for ((key, label) in extra) {+ val isShortcut = key == "copy" || key == "paste"+ Surface(+ shape = MaterialTheme.shapes.small,+ color = MaterialTheme.colorScheme.surface,+ contentColor = MaterialTheme.colorScheme.onSurface,+ border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),+ modifier = Modifier+ .weight(1f)+ .height(36.dp)+ .clickable { onKey(key, if (isShortcut) emptyList() else null) },+ ) {+ Box(contentAlignment = Alignment.Center, modifier = Modifier.padding(horizontal = 2.dp)) {+ Text(+ text = label,+ style = MaterialTheme.typography.labelMedium,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ }+ }+ }}}}diff --git a/android/app/src/main/res/drawable/ic_sound_off.xml b/android/app/src/main/res/drawable/ic_sound_off.xmlnew file mode 100644index 0000000..32e478c--- /dev/null+++ b/android/app/src/main/res/drawable/ic_sound_off.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- SPDX-License-Identifier: GPL-3.0-or-later -->+<!-- Muted speaker: same stroke icon as the PC app's Icons.soundOff. -->+<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="M4 9h3.5L12 5v14l-4.5-4H4zM16 9.5l5 5M21 9.5l-5 5"+ 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/drawable/ic_speaker.xml b/android/app/src/main/res/drawable/ic_speaker.xmlnew file mode 100644index 0000000..cbf3046--- /dev/null+++ b/android/app/src/main/res/drawable/ic_speaker.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- SPDX-License-Identifier: GPL-3.0-or-later -->+<!-- Speaker: same stroke icon as the PC app's Icons.speaker. -->+<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="M4 9h3.5L12 5v14l-4.5-4H4zM15.5 9a4 4 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11"+ android:strokeColor="#FF000000"+ android:strokeWidth="1.8"+ android:strokeLineCap="round"+ android:strokeLineJoin="round"+ android:fillColor="#00000000" />+</vector>diff --git a/android/app/src/test/kotlin/app/nectarlink/android/core/CoreStateTest.kt b/android/app/src/test/kotlin/app/nectarlink/android/core/CoreStateTest.ktindex 53e3305..e22b83a 100644--- a/android/app/src/test/kotlin/app/nectarlink/android/core/CoreStateTest.kt+++ b/android/app/src/test/kotlin/app/nectarlink/android/core/CoreStateTest.kt@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-3.0-or-laterpackage app.nectarlink.android.core+import android.view.Surfaceimport app.nectarlink.core.Batteryimport app.nectarlink.core.DeviceInfoimport app.nectarlink.core.DeviceKind@@ -11,6 +12,7 @@ import app.nectarlink.core.Notificationimport app.nectarlink.core.PairedDeviceimport app.nectarlink.core.PairingFailureimport org.junit.Assert.assertEquals+import org.junit.Assert.assertNotNullimport org.junit.Assert.assertNullimport org.junit.Assert.assertTrueimport org.junit.Test@@ -37,10 +39,11 @@ class CoreStateTest {assertEquals(WakeState.Waking, state.device("a")!!.wakeState)state = state.reduce(Event.LinkChanged("a", Link.Online(false, 5u)))- .reduce(Event.Battery("a", Battery(42u, true, "ac")))+ .reduce(Event.Battery("a", Battery(42u, true, "ac", 28u)))assertTrue(state.device("a")!!.online)assertEquals(WakeState.Idle, state.device("a")!!.wakeState)assertEquals(42.toUByte(), state.device("a")!!.battery!!.level)+ assertEquals(28.toUShort(), state.device("a")!!.battery!!.fullIn)// Unknown devices are ignored; removal drops the device.state = state.reduce(Event.LinkChanged("zz", Link.Connecting)).reduce(Event.DeviceRemoved("b"))@@ -114,5 +117,38 @@ class CoreStateTest {assertEquals(2, ds.outputDevices.size)assertEquals("Speakers (Realtek Audio)", ds.outputDevices.first { it.isDefault }.name)}++ @Test+ fun screenShapeUnrotatesCutoutAndCornersToUprightOrientation() {+ // Upright 1080x2400 screen with a top-left corner punch-hole at x=60..140, y=30..110.+ val r0 = normalizeCutoutRect(60, 30, 140, 110, 1080, 2400, Surface.ROTATION_0)!!+ // In ROTATION_90 (2400x1080), physical top-left (60..140, 30..110) sits near bottom-left:+ // x_rot = y_0 = 30..110, y_rot = 1080 - x_0 = 940..1020.+ val r90 = normalizeCutoutRect(30, 940, 110, 1020, 2400, 1080, Surface.ROTATION_90)!!+ // In ROTATION_270 (2400x1080), physical top-left sits near top-right:+ // x_rot = 2400 - y_0 = 2290..2370, y_rot = x_0 = 60..140.+ val r270 = normalizeCutoutRect(2290, 60, 2370, 140, 2400, 1080, Surface.ROTATION_270)!!++ assertEquals(r0.x, r90.x, 1e-4f)+ assertEquals(r0.y, r90.y, 1e-4f)+ assertEquals(r0.w, r90.w, 1e-4f)+ assertEquals(r0.h, r90.h, 1e-4f)+ assertEquals(r0.x, r270.x, 1e-4f)+ assertEquals(r0.y, r270.y, 1e-4f)++ val corners = normalizeCorners(120, 120, 100, 100, 1080, 2400, Surface.ROTATION_0)!!+ assertEquals(120f / 1080f, corners.tl, 1e-4f)+ assertEquals(100f / 1080f, corners.br, 1e-4f)+ assertNull(normalizeCorners(0, 0, 0, 0, 1080, 2400, Surface.ROTATION_0))++ val svg = buildNormalizedSvgPath(+ contours = listOf(listOf(540f to 36f, 576f to 72f, 540f to 108f, 504f to 72f)),+ rawW = 1080,+ rawH = 2400,+ rotation = Surface.ROTATION_0,+ )+ assertNotNull(svg)+ assertEquals("M 0.5 0.015 L 0.5333 0.03 L 0.5 0.045 L 0.4667 0.03 Z", svg)+ }}diff --git a/core/nectarlink-cli/src/main.rs b/core/nectarlink-cli/src/main.rsindex 4bcfb89..3871bf0 100644--- a/core/nectarlink-cli/src/main.rs+++ b/core/nectarlink-cli/src/main.rs@@ -11,7 +11,8 @@ use clap::{Parser, Subcommand, ValueEnum};use nectarlink_core::{Battery, ConnectionPath, DeviceId, DeviceInfo, DeviceKind, Direction, FeatureState, LinkState,MediaAction, MediaError, MediaPlayer, Node, NodeConfig, NodeEvent, Notification, NotificationAction,- NotificationError, PairedDevice, PairingEvent, Platform, PowerAction, PowerLevel, TransferState,+ NotificationError, PairedDevice, PairingEvent, Platform, PowerAction, PowerLevel, ScreenCorners,+ ScreenRect, ScreenShape, TransferState,features::{Effort, FEATURES, Role, UnsupportedReason, Upgrade, UpgradeAction},};use tokio::sync::broadcast::error::RecvError;@@ -43,12 +44,18 @@ struct Cli {/// Power level to announce with --as-phone.#[arg(long, global = true, value_enum, default_value_t = Power::Basic, requires = "as_phone")]power: Power,+ /// Front-screen geometry to announce with --as-phone.+ #[arg(long, global = true, value_enum, requires = "as_phone")]+ screen: Option<PhoneScreen>,/// Battery level (0–100) to report, to test a PC without a phone.#[arg(long, global = true, value_parser = clap::value_parser!(u8).range(0..=100))]battery: Option<u8>,/// Report the battery as charging (with --battery).#[arg(long, global = true, requires = "battery")]charging: bool,+ /// Estimated minutes until full when charging (with --charging).+ #[arg(long, global = true, requires = "charging")]+ full_in: Option<u16>,/// Extra capability to announce, e.g. clip.read.auto (repeatable).#[arg(long = "offer", global = true, value_name = "CAPABILITY")]offers: Vec<String>,@@ -431,6 +438,68 @@ enum Power {Elevated,}+#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]+enum PhoneScreen {+ CenterHole,+ CornerHole,+ Notch,+ Pill,+ Plain,+}++impl PhoneScreen {+ fn to_shape(self) -> ScreenShape {+ match self {+ PhoneScreen::CenterHole => ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(ScreenCorners { tl: 0.088, tr: 0.088, br: 0.088, bl: 0.088 }),+ cutouts: vec![ScreenRect { x: 0.462, y: 0.018, w: 0.076, h: 0.0342 }],+ cutout_path: Some(+ "M 0.5 0.018 A 0.038 0.0171 0 1 0 0.5 0.0522 A 0.038 0.0171 0 1 0 0.5 0.018 Z".into(),+ ),+ },+ PhoneScreen::CornerHole => ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(ScreenCorners { tl: 0.082, tr: 0.082, br: 0.082, bl: 0.082 }),+ cutouts: vec![ScreenRect { x: 0.068, y: 0.018, w: 0.076, h: 0.0342 }],+ cutout_path: Some(+ "M 0.106 0.018 A 0.038 0.0171 0 1 0 0.106 0.0522 A 0.038 0.0171 0 1 0 0.106 0.018 Z"+ .into(),+ ),+ },+ PhoneScreen::Notch => ScreenShape {+ v: 1,+ aspect: 0.46,+ corners: Some(ScreenCorners { tl: 0.095, tr: 0.095, br: 0.095, bl: 0.095 }),+ cutouts: vec![ScreenRect { x: 0.28, y: 0.0, w: 0.44, h: 0.038 }],+ cutout_path: Some(+ "M 0.28 0.0 L 0.72 0.0 L 0.72 0.022 Q 0.72 0.038 0.685 0.038 L 0.315 0.038 Q 0.28 0.038 0.28 0.022 Z"+ .into(),+ ),+ },+ PhoneScreen::Pill => ScreenShape {+ v: 1,+ aspect: 0.46,+ corners: Some(ScreenCorners { tl: 0.105, tr: 0.105, br: 0.105, bl: 0.105 }),+ cutouts: vec![ScreenRect { x: 0.36, y: 0.016, w: 0.28, h: 0.034 }],+ cutout_path: Some(+ "M 0.397 0.016 L 0.603 0.016 A 0.037 0.017 0 0 1 0.603 0.05 L 0.397 0.05 A 0.037 0.017 0 0 1 0.397 0.016 Z"+ .into(),+ ),+ },+ PhoneScreen::Plain => ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(ScreenCorners { tl: 0.072, tr: 0.072, br: 0.072, bl: 0.072 }),+ cutouts: Vec::new(),+ cutout_path: None,+ },+ }+ }+}+#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]enum PowerArg {Lock,@@ -2091,7 +2160,13 @@ async fn start_node(cli: &Cli) -> Result<Node> {} else {(DeviceKind::Desktop, std::env::consts::OS.into(), String::new())};- let device = DeviceInfo { name, kind, os, os_ver, model: None, accent: None };+ let is_demo = matches!(cli.command, Command::Demo { .. });+ let screen = if cli.as_phone {+ cli.screen.or_else(|| is_demo.then_some(PhoneScreen::CenterHole)).map(PhoneScreen::to_shape)+ } else {+ None+ };+ let device = DeviceInfo { name, kind, os, os_ver, model: None, accent: None, screen };let power = node_power(cli);let mut config = NodeConfig::new(data_dir.clone(), device, env!("CARGO_PKG_VERSION"));config.downloads_dir = cli.downloads_dir.clone();@@ -2152,9 +2227,15 @@ async fn start_node(cli: &Cli) -> Result<Node> {}node.update_power(power, offers).await;}- if let Some(level) = cli.battery {+ if let Some(level) = cli.battery.or_else(|| is_demo.then_some(78)) {let plugged = cli.charging.then(|| "ac".to_owned());- node.update_battery(Battery { level, charging: cli.charging, plugged }).await;+ node.update_battery(Battery {+ level,+ charging: cli.charging,+ plugged,+ full_in: cli.charging.then_some(cli.full_in).flatten(),+ })+ .await;}Ok(node)}diff --git a/core/nectarlink-core/src/lib.rs b/core/nectarlink-core/src/lib.rsindex ab7da1a..0095284 100644--- a/core/nectarlink-core/src/lib.rs+++ b/core/nectarlink-core/src/lib.rs@@ -66,9 +66,10 @@ pub use nectarlink_protocol::{ContactNumber, DeviceInfo, DeviceKind, MediaPlayer, MirrorAudioConfig, MirrorConfig, MirrorInput,MirrorResize, MirrorStart, Notification, NotificationAction, PcAudioSet, PcWakeInfo, PhoneApp,PhoneToggleSet, PhoneToggleValue, PhoneToggles, PhotoAlbum, PhotoItem, PhotoNew as Photo, PhotoThumb,- PowerLevel, SmsMessage, SmsPart, SmsThread, StorageChanged, StorageDelete, StorageEntries,- StorageEntry, StorageList, StorageMkdir, StorageRead, StorageReadMeta, StorageRename,- StorageWriteAccept, StorageWriteDone, StorageWriteOffer, TouchAction, WebcamConfig, WebcamStart,+ PowerLevel, ScreenCorners, ScreenRect, ScreenShape, SmsMessage, SmsPart, SmsThread, StorageChanged,+ StorageDelete, StorageEntries, StorageEntry, StorageList, StorageMkdir, StorageRead, StorageReadMeta,+ StorageRename, StorageWriteAccept, StorageWriteDone, StorageWriteOffer, TouchAction, WebcamConfig,+ WebcamStart,calls::{CONTROL as CALLS_CONTROL, DIAL as CALLS_DIAL, IN_CALL as CALLS_IN_CALL, LOG as CALLS_LOG,SHOW as CALLS_SHOW, STATE as CALLS_STATE,@@ -88,7 +89,7 @@ pub use nectarlink_protocol::{MAX_THUMB_BATCH as PHOTO_MAX_THUMB_BATCH, MAX_THUMB_BYTES as PHOTO_MAX_THUMB_BYTES,READ as PHOTOS_READ, SHOW as PHOTOS_SHOW,},- ringer_modes,+ ringer_modes, screen_limits,sms::{READ as SMS_READ, SEND as SMS_SEND, SHOW as SMS_SHOW},storage::{MOUNT as STORAGE_MOUNT, READ as STORAGE_READ, WRITE as STORAGE_WRITE},toggle_ids,diff --git a/core/nectarlink-core/src/node.rs b/core/nectarlink-core/src/node.rsindex bcc56ba..cc8871b 100644--- a/core/nectarlink-core/src/node.rs+++ b/core/nectarlink-core/src/node.rs@@ -298,6 +298,7 @@ impl Shared {/// Stores a newly paired device and starts keeping it connected.pub async fn complete_pairing(self: &Arc<Self>, peer: DeviceId, info: DeviceInfo) -> Result<()> {+ let info = info.sanitized();let paired_at = crate::now_unix();self.store.upsert_peer(&peer, &info, paired_at)?;tracing::info!(peer = %peer.short(), "paired");@@ -374,14 +375,15 @@ impl Shared {tracing::warn!(error = %e, "failed to record peer addresses");}self.remember_addrs(&peer, &addrs);- if let Err(e) = self.store.update_info(&peer, &remote.device) {+ let remote_device = remote.device.sanitized();+ if let Err(e) = self.store.update_info(&peer, &remote_device) {tracing::warn!(error = %e, "failed to update peer info");}let caps = features::sanitize_capabilities(remote.caps);if let Err(e) = self.store.update_capabilities(&peer, Some(&caps), Some(remote.power.effective())) {tracing::warn!(error = %e, "failed to update peer capabilities");}- self.emit(NodeEvent::PeerInfoChanged { device: peer, info: remote.device });+ self.emit(NodeEvent::PeerInfoChanged { device: peer, info: remote_device });self.emit(NodeEvent::PeerPowerChanged { device: peer, power: remote.power.effective() });self.refresh_capabilities(&peer);self.publish_online(&session);@@ -1678,6 +1680,7 @@ impl Node {/// Reports this device's battery; forwarded to connected devices.pub async fn update_battery(&self, battery: Battery) {+ let battery = battery.sanitized();self.shared.local.write().unwrap_or_else(|e| e.into_inner()).battery = Some(battery.clone());if let Ok(env) = Envelope::new(types::EVENT_BATTERY, &battery) {self.shared.broadcast(env).await;@@ -1686,6 +1689,7 @@ impl Node {/// Updates this device's description (e.g. after a rename).pub async fn update_device_info(&self, device: DeviceInfo) {+ let device = device.sanitized();self.shared.local.write().unwrap_or_else(|e| e.into_inner()).device = device.clone();let update = HelloUpdate { device: Some(device), ..Default::default() };if let Ok(env) = Envelope::new(types::HELLO_UPDATE, &update) {diff --git a/core/nectarlink-core/src/session.rs b/core/nectarlink-core/src/session.rsindex cc00dab..b524a04 100644--- a/core/nectarlink-core/src/session.rs+++ b/core/nectarlink-core/src/session.rs@@ -352,17 +352,17 @@ async fn handle(shared: &Arc<Shared>, session: &Arc<Session>, env: Envelope) ->session.send(Envelope::new(types::PONG, &ping)?.reply_to(env.id)).await?;}types::EVENT_BATTERY => {- let battery: Battery = env.body()?;+ let battery = env.body::<Battery>()?.sanitized();shared.emit(NodeEvent::Battery { device: peer, battery });}types::EVENT_DEVICE => {- let info: DeviceInfo = env.body()?;+ let info = env.body::<DeviceInfo>()?.sanitized();shared.store.update_info(&peer, &info)?;shared.emit(NodeEvent::PeerInfoChanged { device: peer, info });}types::HELLO_UPDATE => {let update: HelloUpdate = env.body()?;- if let Some(info) = update.device {+ if let Some(info) = update.device.map(DeviceInfo::sanitized) {shared.store.update_info(&peer, &info)?;shared.emit(NodeEvent::PeerInfoChanged { device: peer, info });}diff --git a/core/nectarlink-core/src/store.rs b/core/nectarlink-core/src/store.rsindex 569b3e0..e58927d 100644--- a/core/nectarlink-core/src/store.rs+++ b/core/nectarlink-core/src/store.rs@@ -11,7 +11,7 @@ use std::{use nectarlink_protocol::{DeviceId,- messages::{DeviceInfo, DeviceKind, PcWakeInfo, PowerLevel},+ messages::{DeviceInfo, DeviceKind, PcWakeInfo, PowerLevel, ScreenShape},};use rusqlite::{Connection, OptionalExtension, params};@@ -46,6 +46,8 @@ const MIGRATIONS: &[&str] = &[) STRICT;",// v3: Wake-on-LAN adapter MAC and subnet broadcast addresses per paired PC."ALTER TABLE peers ADD COLUMN wake_info TEXT NOT NULL DEFAULT '';",+ // v4: measured phone/tablet front-screen geometry (`DeviceInfo.screen`).+ "ALTER TABLE peers ADD COLUMN screen TEXT NOT NULL DEFAULT '';",];/// A paired device as stored on disk.@@ -92,14 +94,16 @@ impl Store {/// Adds or replaces a paired device.pub fn upsert_peer(&self, id: &DeviceId, info: &DeviceInfo, paired_at: i64) -> Result<()> {+ let screen = encode_screen(info.screen.as_ref());self.with(|c| {c.execute(- "INSERT INTO peers (id, name, kind, os, os_ver, model, accent, paired_at)- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)+ "INSERT INTO peers (id, name, kind, os, os_ver, model, accent, paired_at, screen)+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)ON CONFLICT(id) DO UPDATE SETname = excluded.name, kind = excluded.kind, os = excluded.os,os_ver = excluded.os_ver, model = excluded.model, accent = excluded.accent,- paired_at = excluded.paired_at",+ paired_at = excluded.paired_at,+ screen = CASE WHEN excluded.screen = '' THEN peers.screen ELSE excluded.screen END",params![id.as_bytes().as_slice(),info.name,@@ -108,7 +112,8 @@ impl Store {info.os_ver,info.model,info.accent.map(i64::from),- paired_at+ paired_at,+ screen],).map(drop)@@ -117,9 +122,11 @@ impl Store {/// Updates the stored description of a device (e.g. after a rename).pub fn update_info(&self, id: &DeviceId, info: &DeviceInfo) -> Result<()> {+ let screen = encode_screen(info.screen.as_ref());self.with(|c| {c.execute(- "UPDATE peers SET name = ?2, kind = ?3, os = ?4, os_ver = ?5, model = ?6, accent = ?7+ "UPDATE peers SET name = ?2, kind = ?3, os = ?4, os_ver = ?5, model = ?6, accent = ?7,+ screen = CASE WHEN ?8 = '' THEN screen ELSE ?8 ENDWHERE id = ?1",params![id.as_bytes().as_slice(),@@ -128,7 +135,8 @@ impl Store {info.os,info.os_ver,info.model,- info.accent.map(i64::from)+ info.accent.map(i64::from),+ screen],).map(drop)@@ -225,7 +233,22 @@ impl Store {}const SELECT: &str = "SELECT id, name, kind, os, os_ver, model, accent, paired_at, last_seen, last_addrs, \- caps, power, wake_info FROM peers";+ caps, power, wake_info, screen FROM peers";++fn encode_screen(screen: Option<&ScreenShape>) -> String {+ screen+ .cloned()+ .and_then(ScreenShape::sanitized)+ .and_then(|s| serde_json::to_string(&s).ok())+ .unwrap_or_default()+}++fn decode_screen(s: &str) -> Option<ScreenShape> {+ if s.is_empty() {+ return None;+ }+ serde_json::from_str::<ScreenShape>(s).ok().and_then(ScreenShape::sanitized)+}fn row_to_peer(row: &rusqlite::Row<'_>) -> rusqlite::Result<PeerRecord> {let id: Vec<u8> = row.get(0)?;@@ -238,6 +261,7 @@ fn row_to_peer(row: &rusqlite::Row<'_>) -> rusqlite::Result<PeerRecord> {let caps: String = row.get(10)?;let power: String = row.get(11)?;let wake_info: String = row.get(12)?;+ let screen: String = row.get(13)?;Ok(PeerRecord {id: DeviceId(id),info: DeviceInfo {@@ -247,6 +271,7 @@ fn row_to_peer(row: &rusqlite::Row<'_>) -> rusqlite::Result<PeerRecord> {os_ver: row.get(4)?,model: row.get(5)?,accent: accent.and_then(|a| u32::try_from(a).ok()),+ screen: decode_screen(&screen),},paired_at: row.get(7)?,last_seen: row.get(8)?,@@ -318,6 +343,7 @@ fn migrate(conn: &Connection) -> Result<()> {#[cfg(test)]mod tests {use super::*;+ use nectarlink_protocol::messages::{ScreenCorners, ScreenRect};fn info(name: &str) -> DeviceInfo {DeviceInfo {@@ -327,6 +353,13 @@ mod tests {os_ver: "16".into(),model: None,accent: Some(0xFF8A5100),+ screen: Some(ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(ScreenCorners { tl: 0.085, tr: 0.085, br: 0.085, bl: 0.085 }),+ cutouts: vec![ScreenRect { x: 0.46, y: 0.018, w: 0.08, h: 0.036 }],+ cutout_path: Some("M 0.5 0.018 L 0.54 0.036 L 0.5 0.054 L 0.46 0.036 Z".into()),+ }),}}@@ -351,6 +384,7 @@ mod tests {assert_eq!(peer.last_seen, Some(200));assert_eq!(peer.last_addrs, addrs);assert_eq!(peer.info.name, "Pixel 9");+ assert_eq!(peer.info.screen, info("Pixel 9").screen);assert!(store.remove_peer(&id).unwrap());assert!(!store.remove_peer(&id).unwrap());diff --git a/core/nectarlink-core/tests/two_devices.rs b/core/nectarlink-core/tests/two_devices.rsindex 1dcf03a..eefe3c5 100644--- a/core/nectarlink-core/tests/two_devices.rs+++ b/core/nectarlink-core/tests/two_devices.rs@@ -547,6 +547,7 @@ fn info(name: &str, kind: DeviceKind) -> DeviceInfo {os_ver: "test".into(),model: None,accent: None,+ screen: None,}}@@ -659,7 +660,7 @@ async fn ring_and_battery_flow_between_devices() {with_timeout("stop ring", pc.node.ring(phone_id, false)).await.expect("stop succeeds");assert_eq!(*phone.platform.rings.lock().unwrap(), vec![true, false]);- let battery = Battery { level: 82, charging: true, plugged: Some("usb".into()) };+ let battery = Battery { level: 82, charging: true, plugged: Some("usb".into()), full_in: Some(28) };phone.node.update_battery(battery.clone()).await;let received = wait_for(&mut pc, "battery", |e| match e {NodeEvent::Battery { device, battery } if *device == phone_id => Some(battery.clone()),@@ -670,6 +671,13 @@ async fn ring_and_battery_flow_between_devices() {let mut renamed = info("Pixel 9 Pro", DeviceKind::Phone);renamed.accent = Some(0xFF65558F);+ renamed.screen = Some(nectarlink_core::ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(nectarlink_core::ScreenCorners { tl: 0.088, tr: 0.088, br: 0.088, bl: 0.088 }),+ cutouts: vec![nectarlink_core::ScreenRect { x: 0.46, y: 0.018, w: 0.08, h: 0.036 }],+ cutout_path: None,+ });phone.node.update_device_info(renamed.clone()).await;let info = wait_for(&mut pc, "rename", |e| match e {NodeEvent::PeerInfoChanged { device, info } if *device == phone_id && info.name == "Pixel 9 Pro" => {@@ -679,7 +687,9 @@ async fn ring_and_battery_flow_between_devices() {}).await;assert_eq!(info, renamed);- assert_eq!(pc.node.paired_devices().unwrap()[0].info.name, "Pixel 9 Pro", "rename is persisted");+ let stored = &pc.node.paired_devices().unwrap()[0].info;+ assert_eq!(stored.name, "Pixel 9 Pro", "rename is persisted");+ assert_eq!(stored.screen, renamed.screen, "screen geometry is persisted");let _ = pc_id;}diff --git a/core/nectarlink-ffi/src/lib.rs b/core/nectarlink-ffi/src/lib.rsindex 69ea21e..3b2f2de 100644--- a/core/nectarlink-ffi/src/lib.rs+++ b/core/nectarlink-ffi/src/lib.rs@@ -31,6 +31,41 @@ pub enum DeviceKind {Unknown,}+#[derive(Debug, Clone, Copy, PartialEq, uniffi::Record)]+pub struct ScreenRect {+ pub x: f32,+ pub y: f32,+ pub w: f32,+ pub h: f32,+}++impl Eq for ScreenRect {}++#[derive(Debug, Clone, Copy, PartialEq, uniffi::Record)]+pub struct ScreenCorners {+ pub tl: f32,+ pub tr: f32,+ pub br: f32,+ pub bl: f32,+}++impl Eq for ScreenCorners {}++#[derive(Debug, Clone, PartialEq, uniffi::Record)]+pub struct ScreenShape {+ #[uniffi(default = 1)]+ pub v: u32,+ pub aspect: f32,+ #[uniffi(default = None)]+ pub corners: Option<ScreenCorners>,+ #[uniffi(default = [])]+ pub cutouts: Vec<ScreenRect>,+ #[uniffi(default = None)]+ pub cutout_path: Option<String>,+}++impl Eq for ScreenShape {}+#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)]pub struct DeviceInfo {pub name: String,@@ -41,6 +76,8 @@ pub struct DeviceInfo {pub model: Option<String>,/// ARGB seed color for Material You sync.pub accent: Option<u32>,+ #[uniffi(default = None)]+ pub screen: Option<ScreenShape>,}#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)]@@ -59,6 +96,9 @@ pub struct Battery {pub charging: bool,/// "ac", "usb" or "wireless".pub plugged: Option<String>,+ /// Estimated minutes until full when charging, if known.+ #[uniffi(default = None)]+ pub full_in: Option<u16>,}#[derive(Debug, Clone, PartialEq, Eq, uniffi::Enum)]@@ -1276,6 +1316,54 @@ impl From<DeviceKind> for core::DeviceKind {}}+impl From<core::ScreenRect> for ScreenRect {+ fn from(r: core::ScreenRect) -> Self {+ ScreenRect { x: r.x, y: r.y, w: r.w, h: r.h }+ }+}++impl From<ScreenRect> for core::ScreenRect {+ fn from(r: ScreenRect) -> Self {+ core::ScreenRect { x: r.x, y: r.y, w: r.w, h: r.h }+ }+}++impl From<core::ScreenCorners> for ScreenCorners {+ fn from(c: core::ScreenCorners) -> Self {+ ScreenCorners { tl: c.tl, tr: c.tr, br: c.br, bl: c.bl }+ }+}++impl From<ScreenCorners> for core::ScreenCorners {+ fn from(c: ScreenCorners) -> Self {+ core::ScreenCorners { tl: c.tl, tr: c.tr, br: c.br, bl: c.bl }+ }+}++impl From<core::ScreenShape> for ScreenShape {+ fn from(s: core::ScreenShape) -> Self {+ ScreenShape {+ v: s.v,+ aspect: s.aspect,+ corners: s.corners.map(Into::into),+ cutouts: s.cutouts.into_iter().map(Into::into).collect(),+ cutout_path: s.cutout_path,+ }+ }+}++impl From<ScreenShape> for core::ScreenShape {+ fn from(s: ScreenShape) -> Self {+ core::ScreenShape {+ v: s.v,+ aspect: s.aspect,+ corners: s.corners.map(Into::into),+ cutouts: s.cutouts.into_iter().map(Into::into).collect(),+ cutout_path: s.cutout_path,+ }+ }+}+impl From<core::DeviceInfo> for DeviceInfo {fn from(i: core::DeviceInfo) -> Self {DeviceInfo {@@ -1285,6 +1373,7 @@ impl From<core::DeviceInfo> for DeviceInfo {os_version: i.os_ver,model: i.model,accent: i.accent,+ screen: i.screen.map(Into::into),}}}@@ -1298,7 +1387,9 @@ impl From<DeviceInfo> for core::DeviceInfo {os_ver: i.os_version,model: i.model,accent: i.accent,+ screen: i.screen.map(Into::into),}+ .sanitized()}}@@ -1326,13 +1417,19 @@ impl From<PowerLevel> for core::PowerLevel {impl From<core::Battery> for Battery {fn from(b: core::Battery) -> Self {- Battery { level: b.level, charging: b.charging, plugged: b.plugged }+ Battery { level: b.level, charging: b.charging, plugged: b.plugged, full_in: b.full_in }}}impl From<Battery> for core::Battery {fn from(b: Battery) -> Self {- core::Battery { level: b.level.min(100), charging: b.charging, plugged: b.plugged }+ core::Battery {+ level: b.level.min(100),+ charging: b.charging,+ plugged: b.plugged,+ full_in: b.full_in,+ }+ .sanitized()}}@@ -2832,13 +2929,22 @@ mod tests {os_version: "16".into(),model: Some("Google Pixel 9".into()),accent: Some(0xFF8A5100),+ screen: Some(ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(ScreenCorners { tl: 0.088, tr: 0.088, br: 0.088, bl: 0.088 }),+ cutouts: vec![ScreenRect { x: 0.46, y: 0.018, w: 0.08, h: 0.036 }],+ cutout_path: None,+ }),};assert_eq!(DeviceInfo::from(core::DeviceInfo::from(info.clone())), info);}#[test]fn batteries_are_clamped() {- let b: core::Battery = Battery { level: 140, charging: true, plugged: None }.into();+ let b: core::Battery =+ Battery { level: 140, charging: true, plugged: None, full_in: Some(30) }.into();assert_eq!(b.level, 100);+ assert_eq!(b.full_in, Some(30));}}diff --git a/core/nectarlink-protocol/src/messages.rs b/core/nectarlink-protocol/src/messages.rsindex 20000fc..7f867b9 100644--- a/core/nectarlink-protocol/src/messages.rs+++ b/core/nectarlink-protocol/src/messages.rs@@ -130,6 +130,185 @@ impl PowerLevel {}}+/// Limits for measured display geometry (`DeviceInfo.screen`, protocol §5.1).+pub mod screen_limits {+ pub const VERSION: u32 = 1;+ pub const MIN_ASPECT: f32 = 0.2;+ pub const MAX_ASPECT: f32 = 5.0;+ pub const MAX_CORNER_RADIUS: f32 = 0.5;+ pub const MAX_CUTOUTS: usize = 8;+ pub const MAX_CUTOUT_PATH_BYTES: usize = 4096;+}++fn approx_eq_f32(a: f32, b: f32) -> bool {+ a.to_bits() == b.to_bits() || (a - b).abs() <= 1e-5+}++fn round_norm(v: f32) -> f32 {+ (v * 10000.0).round() / 10000.0+}++/// Normalized `[0.0, 1.0]` bounding rectangle on the upright portrait display.+#[derive(Debug, Clone, Copy, Serialize, Deserialize)]+pub struct ScreenRect {+ pub x: f32,+ pub y: f32,+ pub w: f32,+ pub h: f32,+}++impl PartialEq for ScreenRect {+ fn eq(&self, other: &Self) -> bool {+ approx_eq_f32(self.x, other.x)+ && approx_eq_f32(self.y, other.y)+ && approx_eq_f32(self.w, other.w)+ && approx_eq_f32(self.h, other.h)+ }+}+impl Eq for ScreenRect {}++impl ScreenRect {+ pub fn sanitized(self) -> Option<Self> {+ if !self.x.is_finite()+ || !self.y.is_finite()+ || !self.w.is_finite()+ || !self.h.is_finite()+ || self.w <= 0.0+ || self.h <= 0.0+ {+ return None;+ }+ let x = round_norm(self.x.clamp(0.0, 1.0));+ let y = round_norm(self.y.clamp(0.0, 1.0));+ let w = round_norm(self.w.clamp(0.0, (1.0 - x).max(0.0)));+ let h = round_norm(self.h.clamp(0.0, (1.0 - y).max(0.0)));+ (w > 0.0 && h > 0.0).then_some(Self { x, y, w, h })+ }+}++/// Normalized rounded-corner radii `[tl, tr, br, bl]` as fractions of upright screen width (`0.0..=0.5`).+#[derive(Debug, Clone, Copy, Serialize, Deserialize)]+pub struct ScreenCorners {+ pub tl: f32,+ pub tr: f32,+ pub br: f32,+ pub bl: f32,+}++impl PartialEq for ScreenCorners {+ fn eq(&self, other: &Self) -> bool {+ approx_eq_f32(self.tl, other.tl)+ && approx_eq_f32(self.tr, other.tr)+ && approx_eq_f32(self.br, other.br)+ && approx_eq_f32(self.bl, other.bl)+ }+}+impl Eq for ScreenCorners {}++impl ScreenCorners {+ pub fn sanitized(self) -> Option<Self> {+ if !self.tl.is_finite() || !self.tr.is_finite() || !self.br.is_finite() || !self.bl.is_finite() {+ return None;+ }+ Some(Self {+ tl: round_norm(self.tl.clamp(0.0, screen_limits::MAX_CORNER_RADIUS)),+ tr: round_norm(self.tr.clamp(0.0, screen_limits::MAX_CORNER_RADIUS)),+ br: round_norm(self.br.clamp(0.0, screen_limits::MAX_CORNER_RADIUS)),+ bl: round_norm(self.bl.clamp(0.0, screen_limits::MAX_CORNER_RADIUS)),+ })+ }+}++/// Measured front-display geometry of a phone or tablet (`DeviceInfo.screen`, protocol §5.1).+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct ScreenShape {+ /// Schema version (currently `1`).+ pub v: u32,+ /// Upright display aspect ratio (`width / height`, e.g. `0.45` for 9:20).+ pub aspect: f32,+ /// Measured corner radii as fractions of screen width (`Display.getRoundedCorner()` on API 31+).+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub corners: Option<ScreenCorners>,+ /// Measured cutout bounding boxes (`DisplayCutout.getBoundingRects()`, normalized `0.0..=1.0`).+ #[serde(default, skip_serializing_if = "Vec::is_empty")]+ pub cutouts: Vec<ScreenRect>,+ /// Measured cutout vector path (`DisplayCutout.getCutoutPath()` on API 31+, normalized SVG path in `0.0..=1.0`).+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub cutout_path: Option<String>,+}++impl PartialEq for ScreenShape {+ fn eq(&self, other: &Self) -> bool {+ self.v == other.v+ && approx_eq_f32(self.aspect, other.aspect)+ && self.corners == other.corners+ && self.cutouts == other.cutouts+ && self.cutout_path == other.cutout_path+ }+}+impl Eq for ScreenShape {}++impl ScreenShape {+ pub fn sanitized(self) -> Option<Self> {+ if self.v != screen_limits::VERSION+ || !self.aspect.is_finite()+ || !(screen_limits::MIN_ASPECT..=screen_limits::MAX_ASPECT).contains(&self.aspect)+ {+ return None;+ }+ let cutout_path = self.cutout_path.and_then(|s| {+ let trimmed = s.trim();+ if trimmed.is_empty() || trimmed.len() > screen_limits::MAX_CUTOUT_PATH_BYTES {+ return None;+ }+ let valid_chars = trimmed.chars().all(|c| {+ c.is_ascii_digit()+ || c.is_ascii_whitespace()+ || matches!(+ c,+ 'M' | 'L'+ | 'H'+ | 'V'+ | 'C'+ | 'S'+ | 'Q'+ | 'T'+ | 'A'+ | 'Z'+ | 'm'+ | 'l'+ | 'h'+ | 'v'+ | 'c'+ | 's'+ | 'q'+ | 't'+ | 'a'+ | 'z'+ | '.'+ | '-'+ | '+'+ | ','+ )+ });+ valid_chars.then(|| trimmed.to_owned())+ });+ let cutouts = self+ .cutouts+ .into_iter()+ .filter_map(ScreenRect::sanitized)+ .take(screen_limits::MAX_CUTOUTS)+ .collect();+ Some(Self {+ v: screen_limits::VERSION,+ aspect: round_norm(self.aspect),+ corners: self.corners.and_then(ScreenCorners::sanitized),+ cutouts,+ cutout_path,+ })+ }+}+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]pub struct DeviceInfo {pub name: String,@@ -141,6 +320,16 @@ pub struct DeviceInfo {/// Optional ARGB seed color for Material You sync.#[serde(default, skip_serializing_if = "Option::is_none")]pub accent: Option<u32>,+ /// Optional measured front-display geometry for phones/tablets.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub screen: Option<ScreenShape>,+}++impl DeviceInfo {+ pub fn sanitized(mut self) -> Self {+ self.screen = self.screen.and_then(ScreenShape::sanitized);+ self+ }}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]@@ -180,6 +369,23 @@ pub struct Battery {/// "ac", "usb" or "wireless".#[serde(default, skip_serializing_if = "Option::is_none")]pub plugged: Option<String>,+ /// Estimated minutes until full when charging (`BatteryManager.computeChargeTimeRemaining()`), if known.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub full_in: Option<u16>,+}++impl Battery {+ pub fn sanitized(mut self) -> Self {+ self.level = self.level.min(100);+ if !self.charging {+ self.full_in = None;+ } else if let Some(mins) = self.full_in+ && (mins == 0 || mins > 24 * 60)+ {+ self.full_in = None;+ }+ self+ }}#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]@@ -3169,9 +3375,58 @@ mod tests {os_ver: "16".into(),model: Some("Google Pixel 9".into()),accent: None,+ screen: None,}}+ #[test]+ fn screen_shape_and_battery_full_in_round_trip_and_sanitize() {+ let screen = ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: Some(ScreenCorners { tl: 0.088, tr: 0.088, br: 0.088, bl: 0.088 }),+ cutouts: vec![ScreenRect { x: 0.46, y: 0.018, w: 0.08, h: 0.036 }],+ cutout_path: Some("M 0.5 0.018 L 0.54 0.036 L 0.5 0.054 L 0.46 0.036 Z".into()),+ };+ let mut dev = info();+ dev.screen = Some(screen.clone());+ let env = Envelope::new(types::EVENT_DEVICE, &dev).unwrap();+ let back: DeviceInfo = Envelope::from_cbor(&env.to_cbor()).unwrap().body().unwrap();+ assert_eq!(back.clone().sanitized(), dev);++ // Unknown schema version or out-of-range aspect drops screen cleanly.+ assert!(ScreenShape { v: 2, ..screen.clone() }.sanitized().is_none());+ assert!(ScreenShape { aspect: 0.05, ..screen.clone() }.sanitized().is_none());+ assert!(ScreenShape { aspect: f32::NAN, ..screen.clone() }.sanitized().is_none());++ // Malformed SVG path characters or oversized rect coordinates are sanitized.+ let dirty = ScreenShape {+ v: 1,+ aspect: 0.4495,+ corners: Some(ScreenCorners { tl: 0.9, tr: -0.1, br: 0.08, bl: 0.08 }),+ cutouts: vec![+ ScreenRect { x: -0.1, y: 0.02, w: 0.2, h: 0.04 },+ ScreenRect { x: 0.5, y: 0.5, w: 0.0, h: 0.1 },+ ],+ cutout_path: Some("<script>alert(1)</script>".into()),+ }+ .sanitized()+ .unwrap();+ assert_eq!(dirty.corners, Some(ScreenCorners { tl: 0.5, tr: 0.0, br: 0.08, bl: 0.08 }));+ assert_eq!(dirty.cutouts, vec![ScreenRect { x: 0.0, y: 0.02, w: 0.2, h: 0.04 }]);+ assert!(dirty.cutout_path.is_none());++ // Battery with full_in round-trips and sanitizes when not charging or out of range.+ let b = Battery { level: 68, charging: true, plugged: Some("usb".into()), full_in: Some(34) };+ let env = Envelope::new(types::EVENT_BATTERY, &b).unwrap();+ let back: Battery = Envelope::from_cbor(&env.to_cbor()).unwrap().body().unwrap();+ assert_eq!(back.sanitized(), b);+ assert_eq!(+ Battery { level: 105, charging: false, plugged: None, full_in: Some(25) }.sanitized(),+ Battery { level: 100, charging: false, plugged: None, full_in: None }+ );+ }+#[test]fn hello_round_trips() {let hello = Hello {diff --git a/desktop/app/qml/pages/HomePage.qml b/desktop/app/qml/pages/HomePage.qmlindex 77d9f32..1d2a823 100644--- a/desktop/app/qml/pages/HomePage.qml+++ b/desktop/app/qml/pages/HomePage.qml@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-3.0-or-laterimport QtQuickimport QtQuick.Dialogs+import QtQuick.Shapesimport app.nectarlink// Home: the paired phone at a glance (status, battery, power level) and@@ -29,6 +30,9 @@ Item {if (AppController.currentDevice !== current)AppController.currentDevice = current}+ onCurrentDeviceIdChanged: AppController.watchHomeSummary(visible ? currentDeviceId : "")+ onVisibleChanged: AppController.watchHomeSummary(visible ? currentDeviceId : "")+ Component.onDestruction: AppController.watchHomeSummary("")Connections {target: DeviceListfunction onCountChanged() {@@ -48,6 +52,109 @@ Item {return new Date(unixSeconds * 1000).toLocaleDateString(Qt.locale(), Locale.ShortFormat)}+ function formatChargeEta(minutes) {+ if (!minutes || minutes <= 0)+ return ""+ if (minutes < 60)+ return qsTr("~%1 min to full").arg(minutes)+ const h = Math.floor(minutes / 60)+ const m = minutes % 60+ return m > 0 ? qsTr("~%1h %2m to full").arg(h).arg(m) : qsTr("~%1h to full").arg(h)+ }++ function roundedRectSvg(x, y, w, h, tl, tr, br, bl) {+ if (w <= 0 || h <= 0) return ""+ const maxR = Math.min(w, h) * 0.48+ const rTl = Math.max(0, Math.min(tl, maxR))+ const rTr = Math.max(0, Math.min(tr, maxR))+ const rBr = Math.max(0, Math.min(br, maxR))+ const rBl = Math.max(0, Math.min(bl, maxR))+ const f = (n) => Number(n).toFixed(2)+ return "M " + f(x + rTl) + " " + f(y)+ + " L " + f(x + w - rTr) + " " + f(y)+ + (rTr > 0 ? " A " + f(rTr) + " " + f(rTr) + " 0 0 1 " + f(x + w) + " " + f(y + rTr) : "")+ + " L " + f(x + w) + " " + f(y + h - rBr)+ + (rBr > 0 ? " A " + f(rBr) + " " + f(rBr) + " 0 0 1 " + f(x + w - rBr) + " " + f(y + h) : "")+ + " L " + f(x + rBl) + " " + f(y + h)+ + (rBl > 0 ? " A " + f(rBl) + " " + f(rBl) + " 0 0 1 " + f(x) + " " + f(y + h - rBl) : "")+ + " L " + f(x) + " " + f(y + rTl)+ + (rTl > 0 ? " A " + f(rTl) + " " + f(rTl) + " 0 0 1 " + f(x + rTl) + " " + f(y) : "")+ + " Z"+ }++ function scaleSvgPath(d, w, h, ox, oy) {+ if (!d || d.length === 0 || w <= 0 || h <= 0) return ""+ const tokens = d.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)/g)+ if (!tokens) return ""+ let out = []+ let i = 0+ let cmd = ""+ const fx = (v) => (ox + parseFloat(v) * w).toFixed(2)+ const fy = (v) => (oy + parseFloat(v) * h).toFixed(2)+ const sw = (v) => (parseFloat(v) * w).toFixed(2)+ const sh = (v) => (parseFloat(v) * h).toFixed(2)+ while (i < tokens.length) {+ const t = tokens[i]+ if (/^[a-zA-Z]$/.test(t)) {+ cmd = t.toUpperCase()+ out.push(cmd)+ i+++ if (cmd === "Z") continue+ }+ if (cmd === "M" || cmd === "L" || cmd === "T") {+ if (i + 1 >= tokens.length) break+ out.push(fx(tokens[i]), fy(tokens[i + 1]))+ i += 2+ } else if (cmd === "H") {+ out.push(fx(tokens[i]))+ i += 1+ } else if (cmd === "V") {+ out.push(fy(tokens[i]))+ i += 1+ } else if (cmd === "Q" || cmd === "S") {+ if (i + 3 >= tokens.length) break+ out.push(fx(tokens[i]), fy(tokens[i + 1]), fx(tokens[i + 2]), fy(tokens[i + 3]))+ i += 4+ } else if (cmd === "C") {+ if (i + 5 >= tokens.length) break+ out.push(+ fx(tokens[i]), fy(tokens[i + 1]),+ fx(tokens[i + 2]), fy(tokens[i + 3]),+ fx(tokens[i + 4]), fy(tokens[i + 5])+ )+ i += 6+ } else if (cmd === "A") {+ if (i + 6 >= tokens.length) break+ out.push(+ sw(tokens[i]), sh(tokens[i + 1]),+ tokens[i + 2], tokens[i + 3], tokens[i + 4],+ fx(tokens[i + 5]), fy(tokens[i + 6])+ )+ i += 7+ } else {+ i+++ }+ }+ return out.join(" ")+ }++ function cutoutsToSvgPath(cutouts, w, h, ox, oy) {+ if (!cutouts || !cutouts.length || w <= 0 || h <= 0) return ""+ let parts = []+ for (let i = 0; i < cutouts.length; i++) {+ const c = cutouts[i]+ const rx = ox + c.x * w+ const ry = oy + c.y * h+ const rw = c.w * w+ const rh = c.h * h+ if (rw <= 0.5 || rh <= 0.5) continue+ const topFlush = c.y <= 0.006+ const r = topFlush ? Math.min(rw * 0.35, rh * 0.55) : Math.min(rw, rh) * 0.5+ parts.push(roundedRectSvg(rx, ry, rw, rh, topFlush ? 0 : r, topFlush ? 0 : r, r, r))+ }+ return parts.join(" ")+ }+Flickable {anchors.fill: parentcontentHeight: column.height + Theme.contentPadding * 2@@ -145,9 +252,13 @@ Item {required property int rttMsrequired property int batteryrequired property bool charging+ required property string batteryPlugged+ required property int batteryFullInrequired property string powerrequired property real lastSeenrequired property real pairedAt+ required property string accent+ required property string screen// Dropped files go to the device on screen (and Messages shows it).// Kept while the page is hidden.@@ -164,6 +275,29 @@ Item {function feature(id) {return AppController.capsRevision >= 0 ? AppController.featureState(deviceId, id) : ({})}+ readonly property var screenData: {+ if (!home.screen || home.screen.length === 0)+ return null+ try {+ return JSON.parse(home.screen)+ } catch (e) {+ return null+ }+ }+ readonly property var summaryData: {+ if (AppController.homeSummaryRevision < 0)+ return ({})+ const raw = AppController.homeSummary(home.deviceId)+ if (!raw || raw.length === 0)+ return ({})+ try {+ return JSON.parse(raw)+ } catch (e) {+ return ({})+ }+ }+ readonly property bool canAnimateHero: !Theme.reduceMotion && home.visible && page.visible+ && page.Window.visibility !== Window.Hiddenproperty bool ringing: falseTimer { id: ringTimeout; interval: 30000; onTriggered: home.ringing = false }@@ -176,75 +310,559 @@ Item {// ---- Hero ----Rectangle {+ id: heroCardwidth: parent.width- height: 190+ readonly property bool wide: width >= 540+ readonly property bool hasSms: (home.online && home.feature("messages.sms").state === "available")+ || Boolean(home.summaryData.smsReady)+ readonly property bool hasCalls: (home.online && home.feature("calls.log").state === "available")+ || Boolean(home.summaryData.callsReady)+ readonly property bool hasPhotos: home.feature("files.recent_photos").state === "available"+ && Boolean(home.summaryData.photoReady)+ && Boolean(home.summaryData.photoId && home.summaryData.photoId.length > 0)+ readonly property bool hasGlanceSummary: home.battery >= 0 || hasSms || hasCalls || hasPhotos+ height: wide+ ? Math.max(190, Math.max(phoneArt.height, Math.max(identityCol.height, summaryPanel.height)) + 40)+ : topHeroRow.height + (hasGlanceSummary ? summaryDivider.height + summaryPanel.height + 24 : 0) + 40radius: Theme.radiusXlcolor: Theme.heroColorborder.width: Theme.graphite ? 1 : 0border.color: Theme.outlineVariant- Rectangle {- id: phoneArt- x: 24- anchors.verticalCenter: parent.verticalCenter- width: 86; height: 150- radius: 20- border.width: 3- border.color: Theme.graphite ? Theme.surfaceContent : Theme.primaryContainerContent- gradient: Gradient {- GradientStop { position: 0; color: Theme.graphite ? Theme.surfaceContainerHigh : Theme.primary }- GradientStop { position: 1; color: Theme.graphite ? Theme.surfaceContainerHighest : Qt.darker(Theme.primary, 2.0) }+ Item {+ id: topHeroRow+ x: 22+ y: heroCard.wide ? Math.round((heroCard.height - height) / 2) : 20+ width: heroCard.wide+ ? heroCard.width - 44 - (heroCard.hasGlanceSummary ? summaryPanel.width + 36 : 0)+ : heroCard.width - 44+ height: Math.max(phoneArt.height, identityCol.height)++ // Vector front-only phone preview measured on the phone (no assumed geometry).+ Item {+ id: phoneArt+ anchors.verticalCenter: parent.verticalCenter+ readonly property real aspect: {+ const s = home.screenData+ if (s && s.aspect >= 0.25 && s.aspect <= 2.5)+ return s.aspect+ return home.kind === "tablet" ? 0.70 : 0.45+ }+ height: heroCard.wide ? 148 : 132+ width: Math.round(height * aspect)+ readonly property real bezel: 3.5+ readonly property real innerW: Math.max(10, width - bezel * 2)+ readonly property real innerH: Math.max(20, height - bezel * 2)+ readonly property real defaultCorner: width * 0.135+ readonly property real rTl: home.screenData && home.screenData.corners+ ? Math.max(3, home.screenData.corners.tl * width) : defaultCorner+ readonly property real rTr: home.screenData && home.screenData.corners+ ? Math.max(3, home.screenData.corners.tr * width) : defaultCorner+ readonly property real rBr: home.screenData && home.screenData.corners+ ? Math.max(3, home.screenData.corners.br * width) : defaultCorner+ readonly property real rBl: home.screenData && home.screenData.corners+ ? Math.max(3, home.screenData.corners.bl * width) : defaultCorner+ readonly property color seedColor: home.accent && home.accent.length > 0+ ? Qt.color(home.accent) : Theme.primary+ readonly property color frameFill: Theme.graphite+ ? (Theme.dark ? "#1B1D21" : "#282B30")+ : Qt.darker(seedColor, Theme.dark ? 2.8 : 2.3)+ readonly property color frameStroke: Theme.graphite+ ? Theme.outline+ : Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.42)+ readonly property color screenTop: Theme.graphite+ ? (Theme.dark ? "#262930" : "#E4E7EC")+ : (Theme.dark ? Qt.darker(seedColor, 1.85) : Qt.lighter(seedColor, 1.35))+ readonly property color screenBottom: Theme.graphite+ ? (Theme.dark ? "#17191D" : "#CFD4DC")+ : (Theme.dark ? Qt.darker(seedColor, 2.55) : Qt.darker(seedColor, 1.25))+ readonly property string cutoutSvg: {+ const s = home.screenData+ if (!s) return ""+ if (s.cutout_path && s.cutout_path.length > 0)+ return page.scaleSvgPath(s.cutout_path, innerW, innerH, bezel, bezel)+ if (s.cutouts && s.cutouts.length > 0)+ return page.cutoutsToSvgPath(s.cutouts, innerW, innerH, bezel, bezel)+ return ""+ }++ opacity: home.online ? 1.0 : 0.56+ Behavior on opacity {+ enabled: home.canAnimateHero+ NumberAnimation { duration: Theme.fadeNormal; easing.type: Easing.OutCubic }+ }++ // Soft accent glow behind the phone front while connected.+ Rectangle {+ anchors.centerIn: parent+ width: parent.width + 18+ height: parent.height + 18+ radius: Math.max(phoneArt.rTl, phoneArt.rTr) + 9+ color: Theme.graphite ? Theme.primary : phoneArt.seedColor+ opacity: home.online ? (Theme.dark ? 0.22 : 0.16) : 0.0+ visible: opacity > 0+ Behavior on opacity {+ enabled: home.canAnimateHero+ NumberAnimation { duration: Theme.fadeNormal; easing.type: Easing.OutCubic }+ }+ }++ Shape {+ id: phoneShape+ anchors.fill: parent+ preferredRendererType: Shape.CurveRenderer++ // 1. Outer front chassis outline with measured per-corner radii.+ ShapePath {+ strokeWidth: 1.5+ strokeColor: phoneArt.frameStroke+ fillColor: phoneArt.frameFill+ PathSvg {+ path: page.roundedRectSvg(+ 0.75, 0.75,+ phoneArt.width - 1.5, phoneArt.height - 1.5,+ phoneArt.rTl, phoneArt.rTr, phoneArt.rBr, phoneArt.rBl+ )+ }+ }++ // 2. Active front display surface.+ ShapePath {+ strokeWidth: -1+ fillGradient: LinearGradient {+ x1: phoneArt.bezel; y1: phoneArt.bezel+ x2: phoneArt.width - phoneArt.bezel; y2: phoneArt.height - phoneArt.bezel+ GradientStop { position: 0.0; color: phoneArt.screenTop }+ GradientStop { position: 1.0; color: phoneArt.screenBottom }+ }+ PathSvg {+ path: page.roundedRectSvg(+ phoneArt.bezel, phoneArt.bezel,+ phoneArt.innerW, phoneArt.innerH,+ Math.max(2, phoneArt.rTl - phoneArt.bezel),+ Math.max(2, phoneArt.rTr - phoneArt.bezel),+ Math.max(2, phoneArt.rBr - phoneArt.bezel),+ Math.max(2, phoneArt.rBl - phoneArt.bezel)+ )+ }+ }++ // 3. Measured front camera cutout (SVG path or bounding rects; empty when plain/unknown).+ ShapePath {+ strokeWidth: phoneArt.cutoutSvg.length > 0 ? 0.8 : -1+ strokeColor: Qt.rgba(1, 1, 1, Theme.dark ? 0.16 : 0.22)+ fillColor: phoneArt.cutoutSvg.length > 0 ? phoneArt.frameFill : "transparent"+ PathSvg { path: phoneArt.cutoutSvg }+ }+ }++ // Subtle gesture pill at the bottom of the screen.+ Rectangle {+ anchors.horizontalCenter: parent.horizontalCenter+ anchors.bottom: parent.bottom+ anchors.bottomMargin: phoneArt.bezel + 4+ width: Math.round(phoneArt.innerW * 0.34)+ height: 2.5+ radius: 1.25+ color: Qt.rgba(1, 1, 1, Theme.dark ? 0.32 : 0.45)+ visible: !home.charging+ }++ // Calm charging hint at the bottom edge while the phone charges.+ Rectangle {+ id: chargingHint+ anchors.horizontalCenter: parent.horizontalCenter+ anchors.bottom: parent.bottom+ anchors.bottomMargin: phoneArt.bezel + 4+ height: 16+ width: chargeRow.width + 10+ radius: 8+ color: Qt.rgba(0, 0, 0, Theme.dark ? 0.48 : 0.36)+ border.width: 1+ border.color: Qt.rgba(1, 1, 1, 0.22)+ opacity: home.charging ? 1.0 : 0.0+ visible: opacity > 0+ Behavior on opacity {+ enabled: home.canAnimateHero+ NumberAnimation { duration: Theme.fadeNormal; easing.type: Easing.OutCubic }+ }+ Row {+ id: chargeRow+ anchors.centerIn: parent+ spacing: 3+ Icon {+ anchors.verticalCenter: parent.verticalCenter+ width: 10+ height: 10+ path: Icons.bolt+ color: "#F8D66D"+ }+ Txt {+ anchors.verticalCenter: parent.verticalCenter+ size: 9+ weight: Font.DemiBold+ color: "#FFFFFF"+ text: home.battery >= 0 ? (home.battery + "%") : ""+ }+ }+ }}- Rectangle {- anchors.horizontalCenter: parent.horizontalCenter- y: 8- width: 22; height: 5; radius: 2.5- color: phoneArt.border.color++ Column {+ id: identityCol+ anchors.left: phoneArt.right+ anchors.leftMargin: 20+ anchors.right: parent.right+ anchors.verticalCenter: parent.verticalCenter+ spacing: 6+ Txt {+ width: parent.width+ text: home.name+ role: "displaySmall"+ color: Theme.heroContent+ elide: Text.ElideRight+ }+ Txt {+ width: parent.width+ role: "body"+ color: Theme.heroContent+ opacity: 0.78+ elide: Text.ElideRight+ visible: text.length > 0+ // The model is often a code ("SM-A356E"), so only the version.+ text: home.osVersion.length > 0 ? qsTr("Android %1").arg(home.osVersion) : ""+ }+ Flow {+ width: parent.width+ spacing: 6+ Chip {+ visible: home.battery >= 0 && !heroCard.hasGlanceSummary+ iconPath: Icons.battery+ text: home.charging ? qsTr("%1% · charging").arg(home.battery) : qsTr("%1%").arg(home.battery)+ }+ Chip {+ iconPath: home.online ? Icons.wifi : Icons.unlink+ text: home.online+ ? (home.rttMs >= 1+ ? (home.path === "relay" ? qsTr("Away · %1 ms") : qsTr("Wi‑Fi · %1 ms")).arg(home.rttMs)+ : (home.path === "relay" ? qsTr("Away") : qsTr("Wi‑Fi")))+ : (home.lastSeen > 0 ? qsTr("Offline · seen %1").arg(page.relativeTime(home.lastSeen))+ : qsTr("Not connected yet"))+ }+ Chip {+ visible: home.power === "assist" || home.power === "elevated"+ iconPath: Icons.sparkle+ text: home.power === "elevated" ? qsTr("Elevated") : qsTr("Assist")+ }+ }}}++ // Vertical or horizontal divider between phone identity and glanceable summary.+ Rectangle {+ id: summaryDivider+ visible: heroCard.hasGlanceSummary+ x: heroCard.wide ? heroCard.width - summaryPanel.width - 36 : 22+ y: heroCard.wide ? 22 : topHeroRow.y + topHeroRow.height + 12+ width: heroCard.wide ? 1 : heroCard.width - 44+ height: heroCard.wide ? heroCard.height - 44 : 1+ color: Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.14)+ }++ // Calm, glanceable summary filling the Hero card's right half (or reflowing below on narrow windows).Column {- anchors.left: phoneArt.right- anchors.leftMargin: 24- anchors.right: parent.right- anchors.rightMargin: 24- anchors.verticalCenter: parent.verticalCenter+ id: summaryPanel+ visible: heroCard.hasGlanceSummary+ width: heroCard.wide+ ? Math.min(312, Math.max(228, Math.round(heroCard.width * 0.45)))+ : heroCard.width - 44+ x: heroCard.wide ? heroCard.width - width - 20 : 22+ y: heroCard.wide+ ? Math.round((heroCard.height - height) / 2)+ : summaryDivider.y + summaryDivider.height + 12spacing: 8- Txt {- width: parent.width- text: home.name- role: "displaySmall"- color: Theme.heroContent- }- Txt {++ // 1. Battery progress bar + charging / time to full.+ Rectangle {width: parent.width- role: "body"- color: Theme.heroContent- opacity: 0.78- text: [home.model, home.osVersion.length > 0 ? qsTr("Android %1").arg(home.osVersion) : ""]- .filter(s => s.length > 0).join(" · ")+ height: batteryCol.height + 16+ visible: home.battery >= 0+ radius: Theme.radiusMd+ color: Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.34 : 0.48)+ border.width: 1+ border.color: Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.10)++ Column {+ id: batteryCol+ x: 12+ y: 8+ width: parent.width - 24+ spacing: 6++ Item {+ width: parent.width+ height: Math.max(batteryTitleRow.height, batteryStatusTxt.height)+ Row {+ id: batteryTitleRow+ anchors.left: parent.left+ anchors.verticalCenter: parent.verticalCenter+ spacing: 6+ Icon {+ anchors.verticalCenter: parent.verticalCenter+ width: 15+ height: 15+ path: Icons.battery+ color: home.battery <= 15 && !home.charging ? Theme.danger : Theme.heroContent+ }+ Txt {+ anchors.verticalCenter: parent.verticalCenter+ role: "label"+ color: Theme.heroContent+ text: qsTr("%1%").arg(home.battery)+ }+ }+ Txt {+ id: batteryStatusTxt+ anchors.right: parent.right+ anchors.verticalCenter: parent.verticalCenter+ width: Math.max(60, parent.width - batteryTitleRow.width - 8)+ horizontalAlignment: Text.AlignRight+ elide: Text.ElideRight+ role: "caption"+ color: Theme.heroContent+ opacity: 0.80+ text: {+ if (!home.charging)+ return home.battery <= 20 ? qsTr("Low battery") : qsTr("Battery")+ const eta = page.formatChargeEta(home.batteryFullIn)+ if (eta.length > 0)+ return eta+ if (home.batteryPlugged === "wireless")+ return qsTr("Charging wirelessly")+ if (home.batteryPlugged === "usb")+ return qsTr("Charging via USB")+ return qsTr("Charging")+ }+ }+ }++ Rectangle {+ width: parent.width+ height: 6+ radius: 3+ color: Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.16)+ Rectangle {+ width: Math.max(6, Math.round(parent.width * Math.min(100, Math.max(0, home.battery)) / 100))+ height: parent.height+ radius: 3+ color: home.battery <= 15 && !home.charging+ ? Theme.danger+ : (Theme.graphite ? Theme.heroContent : Theme.primary)+ }+ }+ }}- Flow {++ // 2. Unread messages & missed calls pills (clickable to open Messages / Calls).+ Row {+ id: commRowwidth: parent.widthspacing: 8- Chip {- visible: home.battery >= 0- iconPath: Icons.battery- text: home.charging ? qsTr("%1% · charging").arg(home.battery) : qsTr("%1%").arg(home.battery)+ visible: heroCard.hasSms || heroCard.hasCalls+ readonly property int pillCount: (heroCard.hasSms ? 1 : 0) + (heroCard.hasCalls ? 1 : 0)+ readonly property real pillWidth: pillCount > 1 ? (width - spacing) / 2 : width++ Rectangle {+ visible: heroCard.hasSms+ width: commRow.pillWidth+ height: smsPillRow.height + 14+ radius: Theme.radiusMd+ readonly property int unread: home.summaryData.unreadMessages || 0+ color: smsHover.hovered+ ? Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.48 : 0.68)+ : Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.34 : 0.48)+ border.width: 1+ border.color: unread > 0+ ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.45)+ : Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.10)++ Row {+ id: smsPillRow+ x: 10+ y: 7+ width: parent.width - 20+ spacing: 8+ Icon {+ anchors.verticalCenter: parent.verticalCenter+ width: 15+ height: 15+ path: Icons.messages+ color: (home.summaryData.unreadMessages || 0) > 0 ? Theme.primary : Theme.heroContent+ }+ Column {+ width: parent.width - 23+ anchors.verticalCenter: parent.verticalCenter+ spacing: 1+ Txt {+ width: parent.width+ role: "label"+ color: Theme.heroContent+ elide: Text.ElideRight+ text: (home.summaryData.unreadMessages || 0) > 0+ ? qsTr("%n unread", "", home.summaryData.unreadMessages)+ : qsTr("Messages")+ }+ Txt {+ width: parent.width+ role: "caption"+ color: Theme.heroContent+ opacity: 0.74+ elide: Text.ElideRight+ text: (home.summaryData.unreadMessages || 0) > 0 && home.summaryData.unreadSender+ ? home.summaryData.unreadSender+ : qsTr("All read")+ }+ }+ }+ HoverHandler { id: smsHover; cursorShape: Qt.PointingHandCursor }+ TapHandler { onTapped: AppController.currentPage = "messages" }}- Chip {- iconPath: home.online ? Icons.wifi : Icons.unlink- text: home.online- ? (home.rttMs >= 1- ? (home.path === "relay" ? qsTr("Away · %1 ms") : qsTr("Wi‑Fi · %1 ms")).arg(home.rttMs)- : (home.path === "relay" ? qsTr("Away") : qsTr("Wi‑Fi")))- : (home.lastSeen > 0 ? qsTr("Offline · seen %1").arg(page.relativeTime(home.lastSeen))- : qsTr("Not connected yet"))++ Rectangle {+ visible: heroCard.hasCalls+ width: commRow.pillWidth+ height: callsPillRow.height + 14+ radius: Theme.radiusMd+ readonly property int missed: home.summaryData.missedCalls || 0+ color: callsHover.hovered+ ? Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.48 : 0.68)+ : Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.34 : 0.48)+ border.width: 1+ border.color: missed > 0+ ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.45)+ : Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.10)++ Row {+ id: callsPillRow+ x: 10+ y: 7+ width: parent.width - 20+ spacing: 8+ Icon {+ anchors.verticalCenter: parent.verticalCenter+ width: 15+ height: 15+ path: Icons.call+ color: (home.summaryData.missedCalls || 0) > 0 ? Theme.primary : Theme.heroContent+ }+ Column {+ width: parent.width - 23+ anchors.verticalCenter: parent.verticalCenter+ spacing: 1+ Txt {+ width: parent.width+ role: "label"+ color: Theme.heroContent+ elide: Text.ElideRight+ text: (home.summaryData.missedCalls || 0) > 0+ ? qsTr("%n missed", "", home.summaryData.missedCalls)+ : qsTr("Calls")+ }+ Txt {+ width: parent.width+ role: "caption"+ color: Theme.heroContent+ opacity: 0.74+ elide: Text.ElideRight+ text: (home.summaryData.missedCalls || 0) > 0 && home.summaryData.missedCaller+ ? home.summaryData.missedCaller+ : qsTr("Recent calls")+ }+ }+ }+ HoverHandler { id: callsHover; cursorShape: Qt.PointingHandCursor }+ TapHandler { onTapped: AppController.currentPage = "calls" }}- Chip {- visible: home.power === "assist" || home.power === "elevated"- iconPath: Icons.sparkle- text: home.power === "elevated" ? qsTr("Elevated") : qsTr("Assist")+ }++ // 3. Latest photo or screenshot (rounded thumbnail + relative time; click opens Photos).+ Rectangle {+ width: parent.width+ height: 52+ visible: heroCard.hasPhotos+ radius: Theme.radiusMd+ color: photoHover.hovered+ ? Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.48 : 0.68)+ : Qt.rgba(Theme.surface.r, Theme.surface.g, Theme.surface.b, Theme.dark ? 0.34 : 0.48)+ border.width: 1+ border.color: Qt.rgba(Theme.heroContent.r, Theme.heroContent.g, Theme.heroContent.b, 0.10)++ Row {+ x: 8+ anchors.verticalCenter: parent.verticalCenter+ width: parent.width - 16+ spacing: 10++ Rectangle {+ width: 36+ height: 36+ radius: Theme.radiusSm+ color: Theme.surfaceContainerHigh+ clip: true+ anchors.verticalCenter: parent.verticalCenter++ Image {+ id: latestThumbImg+ anchors.fill: parent+ source: home.summaryData.photoThumb || ""+ fillMode: Image.PreserveAspectCrop+ asynchronous: true+ cache: false+ sourceSize.width: 72+ sourceSize.height: 72+ visible: status === Image.Ready+ }+ Icon {+ anchors.centerIn: parent+ width: 16+ height: 16+ path: Icons.photo+ color: Theme.surfaceContentVariant+ visible: latestThumbImg.status !== Image.Ready+ }+ }++ Column {+ width: parent.width - 46+ anchors.verticalCenter: parent.verticalCenter+ spacing: 1+ Txt {+ width: parent.width+ role: "label"+ color: Theme.heroContent+ elide: Text.ElideRight+ text: home.summaryData.photoIsScreenshot+ ? qsTr("Latest screenshot")+ : (home.summaryData.photoIsVideo ? qsTr("Latest video") : qsTr("Latest photo"))+ }+ Txt {+ width: parent.width+ role: "caption"+ color: Theme.heroContent+ opacity: 0.74+ elide: Text.ElideRight+ text: {+ const when = home.summaryData.photoDate+ ? page.relativeTime(Math.round(home.summaryData.photoDate / 1000))+ : ""+ const name = home.summaryData.photoName || ""+ return [when, name].filter(s => s.length > 0).join(" · ")+ }+ }+ }}+ HoverHandler { id: photoHover; cursorShape: Qt.PointingHandCursor }+ TapHandler { onTapped: AppController.currentPage = "photos" }}}}diff --git a/desktop/app/src/battery.rs b/desktop/app/src/battery.rsindex 0cfa7b6..2cacd96 100644--- a/desktop/app/src/battery.rs+++ b/desktop/app/src/battery.rs@@ -108,7 +108,7 @@ mod tests {use super::*;fn at(level: u8, charging: bool) -> Battery {- Battery { level, charging, plugged: None }+ Battery { level, charging, plugged: None, full_in: None }}#[test]diff --git a/desktop/app/src/bridge/app.rs b/desktop/app/src/bridge/app.rsindex 0ab77e5..fb4e047 100644--- a/desktop/app/src/bridge/app.rs+++ b/desktop/app/src/bridge/app.rs@@ -98,6 +98,9 @@ pub mod qobject {/// Encrypted local clipboard history as JSON:/// `[{ id, kind, text, imageDataUrl, deviceName, incoming, timestamp, pinned }]`.#[qproperty(QString, clipboard_history)]+ /// Bumped whenever the Home card's summary (unread messages, missed calls,+ /// latest photo) changes for the watched phone.+ #[qproperty(i32, home_summary_revision)]type AppController = super::AppControllerRust;/// Asks a paired device to ring (or stop).@@ -189,6 +192,12 @@ pub mod qobject {/// The local sync root folder path for a paired phone.#[qinvokable]fn phone_storage_path(self: &AppController, device: &QString) -> QString;+ /// Tells the event-driven Home summary which phone the Home page is showing (`""` when hidden).+ #[qinvokable]+ fn watch_home_summary(self: &AppController, device: &QString);+ /// Glanceable Home summary for `device` as JSON.+ #[qinvokable]+ fn home_summary(self: &AppController, device: &QString) -> QString;/// Releases idle UI caches and trims the working set when closed to tray.#[qinvokable]fn trim_working_set(self: &AppController);@@ -247,6 +256,7 @@ pub struct AppControllerRust {current_device: i32,pending_dial: QString,clipboard_history: QString,+ home_summary_revision: i32,tray: Option<tray::Tray>,}@@ -807,7 +817,17 @@ impl qobject::AppController {QString::from(&path)}+ pub fn watch_home_summary(&self, device: &QString) {+ watch_home(super::parse_device(device));+ }++ pub fn home_summary(&self, device: &QString) -> QString {+ let Some(id) = super::parse_device(device) else { return QString::default() };+ QString::from(&home_summary_json(id))+ }+pub fn trim_working_set(&self) {+ release_home_summary();crate::webcam::release_idle_resources();crate::photos::release_idle_resources();crate::messages::release_idle_resources();@@ -824,6 +844,301 @@ impl Drop for AppControllerRust {}}+// ---- Event-driven Home card summary (never polled) ----++#[derive(Debug, Clone, Default, PartialEq, Eq)]+struct HomeDeviceSummary {+ sms_loaded: bool,+ sms_busy: bool,+ unread_messages: u32,+ unread_sender: String,+ calls_loaded: bool,+ calls_busy: bool,+ missed_calls: u32,+ missed_caller: String,+ photo_loaded: bool,+ photo_busy: bool,+ photo_id: String,+ photo_name: String,+ photo_date: i64,+ photo_thumb: String,+ photo_is_video: bool,+ photo_is_screenshot: bool,+}++#[derive(Debug, Default)]+struct HomeSummaryStore {+ watched: Option<DeviceId>,+ devices: std::collections::HashMap<DeviceId, HomeDeviceSummary>,+}++static HOME_SUMMARY: Mutex<Option<HomeSummaryStore>> = Mutex::new(None);++fn home_store<T>(f: impl FnOnce(&mut HomeSummaryStore) -> T) -> T {+ f(HOME_SUMMARY.lock().unwrap_or_else(|e| e.into_inner()).get_or_insert_default())+}++fn bump_home_summary() {+ if let Some(qt) = controller() {+ let _ = qt.queue(|mut object| {+ let rev = object.home_summary_revision.wrapping_add(1);+ object.as_mut().set_home_summary_revision(rev);+ });+ }+}++fn release_home_summary() {+ home_store(|s| {+ s.watched = None;+ s.devices.clear();+ });+}++fn home_summary_json(device: DeviceId) -> String {+ home_store(|s| {+ let Some(d) = s.devices.get(&device) else { return String::new() };+ serde_json::json!({+ "smsReady": d.sms_loaded,+ "unreadMessages": d.unread_messages,+ "unreadSender": d.unread_sender,+ "callsReady": d.calls_loaded,+ "missedCalls": d.missed_calls,+ "missedCaller": d.missed_caller,+ "photoReady": d.photo_loaded,+ "photoId": d.photo_id,+ "photoName": d.photo_name,+ "photoDate": d.photo_date,+ "photoThumb": d.photo_thumb,+ "photoIsVideo": d.photo_is_video,+ "photoIsScreenshot": d.photo_is_screenshot,+ })+ .to_string()+ })+}++fn watch_home(device: Option<DeviceId>) {+ home_store(|s| s.watched = device);+ if let Some(id) = device {+ refresh_home_if_needed(id, false, false, false);+ }+}++pub(crate) fn update_home_sms(device: DeviceId, threads: &[nectarlink_core::SmsThread]) {+ let changed = home_store(|s| {+ let entry = s.devices.entry(device).or_default();+ let unread_messages: u32 = threads.iter().map(|t| t.unread).sum();+ let unread_sender =+ threads.iter().find(|t| t.unread > 0).map(crate::messages::title_of).unwrap_or_default();+ let prev = (entry.sms_loaded, entry.unread_messages, entry.unread_sender.clone());+ entry.sms_loaded = true;+ entry.sms_busy = false;+ entry.unread_messages = unread_messages;+ entry.unread_sender = unread_sender;+ prev != (entry.sms_loaded, entry.unread_messages, entry.unread_sender.clone())+ });+ if changed {+ bump_home_summary();+ }+}++pub(crate) fn update_home_calls(device: DeviceId, entries: &[nectarlink_core::CallLogEntry]) {+ let changed = home_store(|s| {+ let entry = s.devices.entry(device).or_default();+ let missed_calls = entries.iter().filter(|e| e.direction == "missed").count() as u32;+ let missed_caller = entries+ .iter()+ .find(|e| e.direction == "missed")+ .map(|e| e.name.clone().filter(|n| !n.trim().is_empty()).unwrap_or_else(|| e.number.clone()))+ .unwrap_or_default();+ let prev = (entry.calls_loaded, entry.missed_calls, entry.missed_caller.clone());+ entry.calls_loaded = true;+ entry.calls_busy = false;+ entry.missed_calls = missed_calls;+ entry.missed_caller = missed_caller;+ prev != (entry.calls_loaded, entry.missed_calls, entry.missed_caller.clone())+ });+ if changed {+ bump_home_summary();+ }+}++pub(crate) fn on_home_event(event: &nectarlink_core::NodeEvent) {+ use nectarlink_core::NodeEvent;+ let watched = home_store(|s| s.watched);+ match event {+ NodeEvent::LinkChanged { device, link: LinkState::Online { .. } } if watched == Some(*device) => {+ refresh_home_if_needed(*device, true, true, true);+ }+ NodeEvent::LinkChanged { device, link: LinkState::Offline { .. } } => {+ home_store(|s| {+ if let Some(d) = s.devices.get_mut(device) {+ d.sms_busy = false;+ d.calls_busy = false;+ d.photo_busy = false;+ }+ });+ }+ NodeEvent::Capabilities(matrix) if watched == Some(matrix.device) => {+ refresh_home_if_needed(matrix.device, false, false, false);+ }+ NodeEvent::SmsChanged { device, .. } if watched == Some(*device) => {+ refresh_home_if_needed(*device, true, false, false);+ }+ NodeEvent::CallLogChanged { device } if watched == Some(*device) => {+ refresh_home_if_needed(*device, false, true, false);+ }+ NodeEvent::Call { device, call } if watched == Some(*device) && call.state == "ended" => {+ let dev = *device;+ core_host::spawn(async move {+ tokio::time::sleep(std::time::Duration::from_millis(650)).await;+ refresh_home_if_needed(dev, false, true, false);+ });+ }+ NodeEvent::PhotoAdded { device, photo } if watched == Some(*device) => {+ let thumb_url = crate::photos::write_thumb(*device, &photo.id, &photo.thumb)+ .or_else(|| {+ let p = crate::photos::thumb_path(*device, &photo.id);+ p.exists().then_some(p)+ })+ .map(|p| crate::icons::file_url(&p))+ .unwrap_or_default();+ home_store(|s| {+ let entry = s.devices.entry(*device).or_default();+ entry.photo_loaded = true;+ entry.photo_busy = false;+ entry.photo_id.clone_from(&photo.id);+ entry.photo_name.clone_from(&photo.name);+ entry.photo_date = photo.taken;+ entry.photo_thumb = thumb_url;+ entry.photo_is_video = photo.id.starts_with("video:");+ entry.photo_is_screenshot = photo.screenshot;+ });+ bump_home_summary();+ }+ NodeEvent::PhotosChanged { device } if watched == Some(*device) => {+ refresh_home_if_needed(*device, false, false, true);+ }+ NodeEvent::DeviceRemoved(device) => {+ home_store(|s| {+ s.devices.remove(device);+ if s.watched == Some(*device) {+ s.watched = None;+ }+ });+ }+ _ => {}+ }+}++fn refresh_home_if_needed(device: DeviceId, force_sms: bool, force_calls: bool, force_photo: bool) {+ let (online, sms_avail, calls_avail, photos_avail) = core_host::host().hub.read(|s| {+ let online = s.devices.iter().any(|d| d.id == device && matches!(d.link, LinkState::Online { .. }));+ let m = s.matrices.get(&device);+ let avail = |f: &str| m.and_then(|m| m.state(f)) == Some(FeatureState::Available);+ (online, avail("messages.sms"), avail("calls.log"), avail("files.recent_photos"))+ });+ if !online {+ return;+ }+ let (do_sms, do_calls, do_photo) = home_store(|s| {+ if s.watched != Some(device) {+ return (false, false, false);+ }+ let d = s.devices.entry(device).or_default();+ let do_sms = sms_avail && !d.sms_busy && (force_sms || !d.sms_loaded);+ let do_calls = calls_avail && !d.calls_busy && (force_calls || !d.calls_loaded);+ let do_photo = photos_avail && !d.photo_busy && (force_photo || !d.photo_loaded);+ if do_sms {+ d.sms_busy = true;+ }+ if do_calls {+ d.calls_busy = true;+ }+ if do_photo {+ d.photo_busy = true;+ }+ (do_sms, do_calls, do_photo)+ });+ let Some(node) = core_host::node() else { return };+ if do_sms {+ let node = node.clone();+ core_host::spawn(async move {+ match node.sms_threads(device, 40).await {+ Ok(threads) => update_home_sms(device, &threads),+ Err(_) => home_store(|s| {+ if let Some(d) = s.devices.get_mut(&device) {+ d.sms_busy = false;+ }+ }),+ }+ });+ }+ if do_calls {+ let node = node.clone();+ core_host::spawn(async move {+ match node.call_log(device, None, 25).await {+ Ok(entries) => update_home_calls(device, &entries),+ Err(_) => home_store(|s| {+ if let Some(d) = s.devices.get_mut(&device) {+ d.calls_busy = false;+ }+ }),+ }+ });+ }+ if do_photo {+ core_host::spawn(async move {+ let Ok(items) = node.photo_list(device, None, None, 1).await else {+ home_store(|s| {+ if let Some(d) = s.devices.get_mut(&device) {+ d.photo_busy = false;+ }+ });+ return;+ };+ let Some(item) = items.into_iter().next() else {+ home_store(|s| {+ let d = s.devices.entry(device).or_default();+ d.photo_loaded = true;+ d.photo_busy = false;+ d.photo_id.clear();+ d.photo_name.clear();+ d.photo_date = 0;+ d.photo_thumb.clear();+ });+ bump_home_summary();+ return;+ };+ let mut disk_path = crate::photos::thumb_path(device, &item.id);+ if !disk_path.exists()+ && let Ok(thumbs) = node.photo_thumbs(device, vec![item.id.clone()]).await+ && let Some(first) = thumbs.into_iter().next()+ && let Some(saved) = crate::photos::write_thumb(device, &first.id, &first.data)+ {+ disk_path = saved;+ }+ let thumb_url =+ if disk_path.exists() { crate::icons::file_url(&disk_path) } else { String::new() };+ let lower_name = item.name.to_ascii_lowercase();+ let is_screenshot = lower_name.contains("screenshot")+ || item.album.as_deref().is_some_and(|a| a.to_ascii_lowercase().contains("screenshot"));+ let is_video = item.duration.is_some() || item.id.starts_with("video:");+ home_store(|s| {+ let d = s.devices.entry(device).or_default();+ d.photo_loaded = true;+ d.photo_busy = false;+ d.photo_id = item.id;+ d.photo_name = item.name;+ d.photo_date = item.date;+ d.photo_thumb = thumb_url;+ d.photo_is_video = is_video;+ d.photo_is_screenshot = is_screenshot;+ });+ bump_home_summary();+ });+ }+}+/// Flattens a feature state for QML.fn feature_state_map(state: Option<FeatureState>) -> QMap<QMapPair_QString_QVariant> {let mut map = QMap::<QMapPair_QString_QVariant>::default();diff --git a/desktop/app/src/bridge/devices.rs b/desktop/app/src/bridge/devices.rsindex 3b69bb8..8af73e8 100644--- a/desktop/app/src/bridge/devices.rs+++ b/desktop/app/src/bridge/devices.rs@@ -119,10 +119,13 @@ const ROLES: &[&str] = &["rttMs","battery","charging",+ "batteryPlugged",+ "batteryFullIn","power","lastSeen","pairedAt","accent",+ "screen",];const USER_ROLE: i32 = 0x0100;@@ -154,6 +157,12 @@ fn role_value(device: &DeviceView, role: &str) -> QVariant {}),"battery" => QVariant::from(&device.battery.as_ref().map_or(-1, |b| i32::from(b.level))),"charging" => QVariant::from(&device.battery.as_ref().is_some_and(|b| b.charging)),+ "batteryPlugged" => {+ text(device.battery.as_ref().and_then(|b| b.plugged.as_deref()).unwrap_or_default())+ }+ "batteryFullIn" => {+ QVariant::from(&device.battery.as_ref().and_then(|b| b.full_in).map_or(-1, i32::from))+ }"power" => text(match device.power {PowerLevel::Assist => "assist",PowerLevel::Elevated => "elevated",@@ -168,6 +177,9 @@ fn role_value(device: &DeviceView, role: &str) -> QVariant {"accent" => {text(&device.info.accent.map(|argb| format!("#{:06X}", argb & 0x00FF_FFFF)).unwrap_or_default())}+ "screen" => {+ text(&device.info.screen.as_ref().and_then(|s| serde_json::to_string(s).ok()).unwrap_or_default())+ }_ => QVariant::default(),}}@@ -272,6 +284,7 @@ mod tests {os_ver: "16".into(),model: None,accent: None,+ screen: None,},paired_at: i64::from(n),link: LinkState::Offline { last_seen: None },@@ -284,12 +297,36 @@ mod tests {fn roles_cover_the_device() {let mut d = device(5, "Pixel");d.link = LinkState::Online { path: ConnectionPath::Lan, rtt_ms: 7 };- d.battery = Some(nectarlink_core::Battery { level: 64, charging: true, plugged: None });+ d.battery = Some(nectarlink_core::Battery {+ level: 64,+ charging: true,+ plugged: Some("usb".into()),+ full_in: Some(42),+ });d.info.accent = Some(0xFF8A5100);+ d.info.screen = Some(nectarlink_core::ScreenShape {+ v: 1,+ aspect: 0.45,+ corners: None,+ cutouts: Vec::new(),+ cutout_path: None,+ });assert_eq!(role_value(&d, "name").value::<QString>().map(String::from).as_deref(), Some("Pixel"));assert_eq!(role_value(&d, "online").value::<bool>(), Some(true));assert_eq!(role_value(&d, "rttMs").value::<i32>(), Some(7));assert_eq!(role_value(&d, "battery").value::<i32>(), Some(64));+ assert_eq!(+ role_value(&d, "batteryPlugged").value::<QString>().map(String::from).as_deref(),+ Some("usb")+ );+ assert_eq!(role_value(&d, "batteryFullIn").value::<i32>(), Some(42));assert_eq!(role_value(&d, "accent").value::<QString>().map(String::from).as_deref(), Some("#8A5100"));+ assert!(+ role_value(&d, "screen")+ .value::<QString>()+ .map(String::from)+ .unwrap_or_default()+ .contains("\"aspect\":0.45")+ );}}diff --git a/desktop/app/src/calls.rs b/desktop/app/src/calls.rsindex 775edd3..0f5a3a8 100644--- a/desktop/app/src/calls.rs+++ b/desktop/app/src/calls.rs@@ -651,6 +651,7 @@ fn load_call_log(before: Option<i64>) {}s.log_photos.extend(photos);s.log_status = Status::Ready;+ crate::bridge::app::update_home_calls(device, &s.log);}Err(e) => {tracing::debug!(error = %e, "can't read call log");diff --git a/desktop/app/src/core_host.rs b/desktop/app/src/core_host.rsindex 8c5c8ca..d53e711 100644--- a/desktop/app/src/core_host.rs+++ b/desktop/app/src/core_host.rs@@ -180,6 +180,7 @@ async fn run(data_dir: PathBuf, platform: Arc<dyn Platform>) {crate::battery::on_event(&event);crate::storage::on_event(&event);crate::webcam::on_event(&event);+ crate::bridge::app::on_home_event(&event);}Err(RecvError::Lagged(missed)) => {// Resynchronize what can be re-read; transient events are lost.@@ -221,6 +222,7 @@ fn this_device() -> DeviceInfo {os_ver: crate::win::os_version(),model: None,accent: None,+ screen: None,}}diff --git a/desktop/app/src/messages.rs b/desktop/app/src/messages.rsindex 6cbfacf..d19ac8c 100644--- a/desktop/app/src/messages.rs+++ b/desktop/app/src/messages.rs@@ -259,6 +259,7 @@ pub fn load_threads() {}match result {Ok(threads) => {+ crate::bridge::app::update_home_sms(device, &threads);s.threads = threads;s.photos.extend(photos);s.status = Status::Ready;diff --git a/desktop/app/src/photos.rs b/desktop/app/src/photos.rsindex f5eb2e5..846f0ac 100644--- a/desktop/app/src/photos.rs+++ b/desktop/app/src/photos.rs@@ -553,11 +553,11 @@ fn prune_cache(device: DeviceId) {}}-fn thumb_path(device: DeviceId, id: &str) -> PathBuf {+pub(crate) fn thumb_path(device: DeviceId, id: &str) -> PathBuf {thumbs_dir(device).join(format!("thumb-{:016x}.jpg", fingerprint(id)))}-fn write_thumb(device: DeviceId, id: &str, jpeg: &[u8]) -> Option<PathBuf> {+pub(crate) fn write_thumb(device: DeviceId, id: &str, jpeg: &[u8]) -> Option<PathBuf> {if jpeg.is_empty() {return None;}diff --git a/desktop/app/src/state.rs b/desktop/app/src/state.rsindex c5ffdf3..9eb15ba 100644--- a/desktop/app/src/state.rs+++ b/desktop/app/src/state.rs@@ -779,6 +779,7 @@ mod tests {os_ver: "16".into(),model: None,accent: None,+ screen: None,},paired_at: at,link: LinkState::Offline { last_seen: None },@@ -805,7 +806,7 @@ mod tests {Changes::NONE,"no change, no refresh");- let battery = Battery { level: 50, charging: false, plugged: None };+ let battery = Battery { level: 50, charging: false, plugged: None, full_in: None };s.apply(&NodeEvent::Battery { device: id, battery: battery.clone() });assert_eq!(s.device(&id).unwrap().battery, Some(battery));diff --git a/docs/PLAN.md b/docs/PLAN.mdindex d2a5021..27e44b7 100644--- a/docs/PLAN.md+++ b/docs/PLAN.md@@ -223,7 +223,7 @@ current Android. Talking through the PC comes with the HFP item above.| **Your PC in your pocket**: from anywhere (Away mode), browse and grab PC files, see what the PC is doing (Ping-me tasks, downloads), wake it (relayed Wake-on-LAN through another Nectarlink device left at home), and later view/control the PC screen (reverse mirroring) | P2 (files/status in P1 if Away mode lands early) || **Proximity lock**: lock the PC when the phone walks away (BLE RSSI) | P2 || **Automations**: triggers (connected, battery low, call started) → actions | P2 |-| Find my phone (ring even on silent), battery & signal in tray, low-battery alerts | P0 |+| Find my phone (ring even on silent), battery & signal in tray, low-battery alerts, measured phone screen preview & Home summary ✅ | P0 |### 3.12 Platform & ecosystem| Feature | Tier |diff --git a/docs/protocol/v0.md b/docs/protocol/v0.mdindex 84f092f..299c2cc 100644--- a/docs/protocol/v0.md+++ b/docs/protocol/v0.md@@ -125,13 +125,24 @@ b = {}DeviceInfo = {- name: text, // user-visible name, e.g. "Pixel 9"- kind: text, // "phone" | "tablet" | "desktop" | "laptop"- os: text, // "android" | "windows" | "macos"- os_ver: text, // "16" / "10.0.26200"- model: text?, // e.g. "Google Pixel 9"- accent: uint?, // optional ARGB seed color (Material You sync)+ name: text, // user-visible name, e.g. "Pixel 9"+ kind: text, // "phone" | "tablet" | "desktop" | "laptop"+ os: text, // "android" | "windows" | "macos"+ os_ver: text, // "16" / "10.0.26200"+ model: text?, // e.g. "Google Pixel 9"+ accent: uint?, // optional ARGB seed color (Material You sync)+ screen: ScreenShape?, // optional measured front-screen geometry (phones/tablets)}++ScreenShape = {+ aspect: float, // upright display width / height (0.25..=2.5)+ corners: ScreenCorners?, // per-corner radii as fractions of upright screen width (0.0..=0.5)+ cutouts: [ScreenRect]?, // up to 4 front cutout bounding boxes in 0.0..=1.0 upright screen coords+ cutout_path: text?, // optional normalized SVG path (<= 512 chars, M/L/H/V/C/Q/Z in 0.0..=1.0)+}++ScreenCorners = { tl: float, tr: float, br: float, bl: float }+ScreenRect = { x: float, y: float, w: float, h: float }```**Version negotiation:** the session uses `min(proto_a, proto_b)`. If that is@@ -191,10 +202,15 @@ with `event.`.```t = "event.battery"-b = { level: uint (0–100), charging: bool, plugged: text? ("ac"|"usb"|"wireless") }+b = {+ level: uint (0–100),+ charging: bool,+ plugged: text? ("ac"|"usb"|"wireless"),+ full_in: uint? (estimated minutes until full, 1–1440, when charging and known),+}t = "event.device"-b = DeviceInfo // name or accent changed+b = DeviceInfo // name, accent or screen shape changed```### 7.3 Find my device