Modern Apps git

← Modern-Apps.git

watch/phone: map direct daily totals to Health Connect, drop derivations

Commit
81401fa725ed837462b27cdc4483f69de02cfcad
Author
Vayun Mathur <[email protected]>
When
2026-07-06 16:15 UTC (5 months ago)
Parents
ecec474
Insert the watch's directly-measured distance/floors/elevation/calories daily
totals into Health Connect day-keyed (calories -> TotalCaloriesBurnedRecord) so
growing totals upsert instead of duplicating. Removes the now-redundant
distance/elevation/floors/active-calorie derivations and the body weight/height
machinery they required: the weight-prompt UI, weight/height Health Connect
reads, and the weight/height permissions. Resting HR and sleep stay as
phone-side heuristics.

Diff

watch/phone/src/main/AndroidManifest.xml
diff --git a/watch/phone/src/main/AndroidManifest.xml b/watch/phone/src/main/AndroidManifest.xmlindex 3cf6eb127f..3b73e46f3f 100644--- a/watch/phone/src/main/AndroidManifest.xml+++ b/watch/phone/src/main/AndroidManifest.xml@@ -18,12 +18,9 @@     <uses-permission android:name="android.permission.health.WRITE_DISTANCE" />     <uses-permission android:name="android.permission.health.WRITE_FLOORS_CLIMBED" />     <uses-permission android:name="android.permission.health.WRITE_ELEVATION_GAINED" />-    <uses-permission android:name="android.permission.health.WRITE_ACTIVE_CALORIES_BURNED" />+    <uses-permission android:name="android.permission.health.WRITE_TOTAL_CALORIES_BURNED" />     <uses-permission android:name="android.permission.health.WRITE_RESTING_HEART_RATE" />     <uses-permission android:name="android.permission.health.WRITE_SLEEP" />-    <uses-permission android:name="android.permission.health.READ_WEIGHT" />-    <uses-permission android:name="android.permission.health.WRITE_WEIGHT" />-    <uses-permission android:name="android.permission.health.READ_HEIGHT" />      <queries>         <package android:name="com.google.android.apps.healthdata" />
watch/phone/src/main/java/com/vayunmathur/watch/phone/MainActivity.kt
diff --git a/watch/phone/src/main/java/com/vayunmathur/watch/phone/MainActivity.kt b/watch/phone/src/main/java/com/vayunmathur/watch/phone/MainActivity.ktindex 953afdd157..49a22f979a 100644--- a/watch/phone/src/main/java/com/vayunmathur/watch/phone/MainActivity.kt+++ b/watch/phone/src/main/java/com/vayunmathur/watch/phone/MainActivity.kt@@ -13,20 +13,16 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding-import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme-import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text-import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember-import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier@@ -36,7 +32,6 @@ import androidx.health.connect.client.PermissionController import com.vayunmathur.watch.phone.ble.ConnectionState import com.vayunmathur.watch.phone.health.HealthConnectManager import com.vayunmathur.watch.phone.sync.SyncForegroundService-import kotlinx.coroutines.launch  class MainActivity : ComponentActivity() { @@ -55,7 +50,6 @@ class MainActivity : ComponentActivity() {     private fun SyncScreen(modifier: Modifier) {         val context = this         val health = remember { HealthConnectManager(context) }-        val coroutineScope = rememberCoroutineScope()          val connection by SyncForegroundService.connectionStateFlow.collectAsState()         val synced by SyncForegroundService.syncedCountFlow.collectAsState()@@ -63,7 +57,6 @@ class MainActivity : ComponentActivity() {         var hasBlePerms by remember { mutableStateOf(false) }         var hasHcPerms by remember { mutableStateOf(false) }         var hcAvailable by remember { mutableStateOf(true) }-        var needsWeight by remember { mutableStateOf(false) }          val blePermsLauncher = rememberLauncherForActivityResult(             contract = ActivityResultContracts.RequestMultiplePermissions(),@@ -83,24 +76,6 @@ class MainActivity : ComponentActivity() {             if (hcAvailable) hasHcPerms = health.hasAllPermissions()         } -        // Once HC permissions are granted, prompt for weight if none is recorded.-        LaunchedEffect(hasHcPerms) {-            if (hasHcPerms) {-                needsWeight = health.latestWeightKg() == null-            }-        }--        if (needsWeight) {-            WeightPromptDialog(-                onSubmit = { kg ->-                    coroutineScope.launch {-                        health.writeWeight(kg)-                        needsWeight = false-                    }-                },-            )-        }-         Column(             modifier = modifier.fillMaxSize().padding(24.dp),             horizontalAlignment = Alignment.CenterHorizontally,@@ -131,35 +106,6 @@ class MainActivity : ComponentActivity() {         }     } -    @Composable-    private fun WeightPromptDialog(onSubmit: (Double) -> Unit) {-        var text by remember { mutableStateOf("") }-        val kg = text.toDoubleOrNull()-        AlertDialog(-            onDismissRequest = {},-            title = { Text(stringResource(R.string.weight_prompt_title)) },-            text = {-                Column {-                    Text(stringResource(R.string.weight_prompt_body))-                    OutlinedTextField(-                        value = text,-                        onValueChange = { text = it },-                        label = { Text(stringResource(R.string.weight_prompt_hint)) },-                        singleLine = true,-                    )-                }-            },-            confirmButton = {-                TextButton(-                    onClick = { kg?.let(onSubmit) },-                    enabled = kg != null && kg > 0.0,-                ) {-                    Text(stringResource(R.string.weight_prompt_save))-                }-            },-        )-    }-     @Composable     private fun ConnectionState.label(): String = when (this) {         ConnectionState.Disconnected -> stringResource(R.string.state_disconnected)
watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthConnectManager.kt
diff --git a/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthConnectManager.kt b/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthConnectManager.ktindex acd950c827..728b1fa3d0 100644--- a/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthConnectManager.kt+++ b/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthConnectManager.kt@@ -4,28 +4,28 @@ import android.content.Context import android.util.Log import androidx.health.connect.client.HealthConnectClient import androidx.health.connect.client.permission.HealthPermission-import androidx.health.connect.client.records.ActiveCaloriesBurnedRecord import androidx.health.connect.client.records.DistanceRecord import androidx.health.connect.client.records.ElevationGainedRecord import androidx.health.connect.client.records.FloorsClimbedRecord import androidx.health.connect.client.records.HeartRateRecord-import androidx.health.connect.client.records.HeightRecord import androidx.health.connect.client.records.Record import androidx.health.connect.client.records.RestingHeartRateRecord import androidx.health.connect.client.records.SleepSessionRecord import androidx.health.connect.client.records.StepsRecord-import androidx.health.connect.client.records.WeightRecord+import androidx.health.connect.client.records.TotalCaloriesBurnedRecord import androidx.health.connect.client.records.metadata.Metadata-import androidx.health.connect.client.request.ReadRecordsRequest-import androidx.health.connect.client.time.TimeRangeFilter-import androidx.health.connect.client.units.Mass+import androidx.health.connect.client.units.Energy+import androidx.health.connect.client.units.Length import com.vayunmathur.watch.phone.data.WatchRecord import java.time.Instant+import java.time.LocalDate import java.time.ZoneId  /**  * Wraps Health Connect onboarding, permissions, and inserting the watch's- * heart-rate and step records.+ * records. Heart rate and steps are written per-sample; the directly-measured+ * daily totals (distance, floors, elevation, calories) are written day-keyed so+ * growing totals upsert instead of duplicating.  */ class HealthConnectManager(private val context: Context) { @@ -35,12 +35,9 @@ class HealthConnectManager(private val context: Context) {         HealthPermission.getWritePermission(DistanceRecord::class),         HealthPermission.getWritePermission(FloorsClimbedRecord::class),         HealthPermission.getWritePermission(ElevationGainedRecord::class),-        HealthPermission.getWritePermission(ActiveCaloriesBurnedRecord::class),+        HealthPermission.getWritePermission(TotalCaloriesBurnedRecord::class),         HealthPermission.getWritePermission(RestingHeartRateRecord::class),         HealthPermission.getWritePermission(SleepSessionRecord::class),-        HealthPermission.getReadPermission(WeightRecord::class),-        HealthPermission.getWritePermission(WeightRecord::class),-        HealthPermission.getReadPermission(HeightRecord::class),     )      fun sdkStatus(): Int = HealthConnectClient.getSdkStatus(context)@@ -85,6 +82,46 @@ class HealthConnectManager(private val context: Context) {                         metadata = Metadata.manualEntry(clientRecordId = "steps-${record.id}"),                     )                 }+                "Distance" -> dailyRecord(record, time, zone) { start, day ->+                    DistanceRecord(+                        startTime = start,+                        startZoneOffset = zone.rules.getOffset(start),+                        endTime = time,+                        endZoneOffset = offset,+                        distance = Length.meters(record.value),+                        metadata = Metadata.manualEntry(clientRecordId = "distance-$day"),+                    )+                }+                "Floors" -> dailyRecord(record, time, zone) { start, day ->+                    FloorsClimbedRecord(+                        startTime = start,+                        startZoneOffset = zone.rules.getOffset(start),+                        endTime = time,+                        endZoneOffset = offset,+                        floors = record.value,+                        metadata = Metadata.manualEntry(clientRecordId = "floors-$day"),+                    )+                }+                "Elevation" -> dailyRecord(record, time, zone) { start, day ->+                    ElevationGainedRecord(+                        startTime = start,+                        startZoneOffset = zone.rules.getOffset(start),+                        endTime = time,+                        endZoneOffset = offset,+                        elevation = Length.meters(record.value),+                        metadata = Metadata.manualEntry(clientRecordId = "elevation-$day"),+                    )+                }+                "Calories" -> dailyRecord(record, time, zone) { start, day ->+                    TotalCaloriesBurnedRecord(+                        startTime = start,+                        startZoneOffset = zone.rules.getOffset(start),+                        endTime = time,+                        endZoneOffset = offset,+                        energy = Energy.kilocalories(record.value),+                        metadata = Metadata.manualEntry(clientRecordId = "calories-$day"),+                    )+                }                 else -> null             }         }@@ -96,6 +133,21 @@ class HealthConnectManager(private val context: Context) {         }     } +    // Daily totals span start-of-day -> record time; the day-keyed clientRecordId+    // makes a growing total upsert rather than duplicate. Skip non-positive totals.+    private inline fun dailyRecord(+        record: WatchRecord,+        time: Instant,+        zone: ZoneId,+        build: (start: Instant, day: LocalDate) -> Record,+    ): Record? {+        if (record.value <= 0.0) return null+        val day = time.atZone(zone).toLocalDate()+        var start = day.atStartOfDay(zone).toInstant()+        if (!time.isAfter(start)) start = time.minusSeconds(1)+        return build(start, day)+    }+     /** Batch-inserts derivation output; clientRecordIds make this idempotent. */     suspend fun insertDerived(records: List<Record>) {         if (records.isEmpty()) return@@ -106,56 +158,6 @@ class HealthConnectManager(private val context: Context) {         }     } -    /** Most recent body weight in kilograms, or null if none recorded. */-    suspend fun latestWeightKg(): Double? = try {-        client().readRecords(-            ReadRecordsRequest(-                recordType = WeightRecord::class,-                timeRangeFilter = TimeRangeFilter.before(Instant.now()),-                ascendingOrder = false,-                pageSize = 1,-            ),-        ).records.firstOrNull()?.weight?.inKilograms-    } catch (e: Exception) {-        Log.e(TAG, "latestWeightKg failed", e)-        null-    }--    /** Most recent body height in meters, or null if none recorded. */-    suspend fun latestHeightMeters(): Double? = try {-        client().readRecords(-            ReadRecordsRequest(-                recordType = HeightRecord::class,-                timeRangeFilter = TimeRangeFilter.before(Instant.now()),-                ascendingOrder = false,-                pageSize = 1,-            ),-        ).records.firstOrNull()?.height?.inMeters-    } catch (e: Exception) {-        Log.e(TAG, "latestHeightMeters failed", e)-        null-    }--    suspend fun writeWeight(kg: Double) {-        if (kg <= 0.0) return-        val time = Instant.now()-        val offset = ZoneId.systemDefault().rules.getOffset(time)-        try {-            client().insertRecords(-                listOf(-                    WeightRecord(-                        time = time,-                        zoneOffset = offset,-                        weight = Mass.kilograms(kg),-                        metadata = Metadata.manualEntry(),-                    ),-                ),-            )-        } catch (e: Exception) {-            Log.e(TAG, "writeWeight failed", e)-        }-    }-     companion object {         private const val TAG = "HealthConnectManager"         private const val STEP_WINDOW_SECONDS = 60L
watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthDerivations.kt
diff --git a/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthDerivations.kt b/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthDerivations.ktindex f949638856..23d8c4fe67 100644--- a/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthDerivations.kt+++ b/watch/phone/src/main/java/com/vayunmathur/watch/phone/health/HealthDerivations.kt@@ -1,117 +1,40 @@ package com.vayunmathur.watch.phone.health -import androidx.health.connect.client.records.ActiveCaloriesBurnedRecord-import androidx.health.connect.client.records.DistanceRecord-import androidx.health.connect.client.records.ElevationGainedRecord-import androidx.health.connect.client.records.FloorsClimbedRecord import androidx.health.connect.client.records.Record import androidx.health.connect.client.records.RestingHeartRateRecord import androidx.health.connect.client.records.SleepSessionRecord import androidx.health.connect.client.records.metadata.Metadata-import androidx.health.connect.client.units.Energy-import androidx.health.connect.client.units.Length import com.vayunmathur.watch.phone.data.ReceivedRecord import java.time.Instant import java.time.LocalDate import java.time.LocalTime import java.time.ZoneId-import kotlin.math.pow  /**  * Pure, side-effect-free derivations run over the phone-side record buffer.  *- * Everything here is heuristic/approximate by design: the watch only streams raw- * HR, steps, barometric pressure and coarse motion state, so resting HR, active- * calories, floors/elevation and sleep are all estimates. All outputs carry a- * day-keyed clientRecordId so recomputing on later syncs upserts instead of+ * These remain heuristic by design: resting HR and sleep have no direct+ * watch-side measurement API, so they are estimated from raw HR + motion. All+ * other metrics (distance, floors, elevation, calories) are now measured+ * directly on the watch via Health Services and inserted verbatim. Outputs carry+ * a day-keyed clientRecordId so recomputing on later syncs upserts instead of  * duplicating in Health Connect.  */ class HealthDerivations(     private val zone: ZoneId = ZoneId.systemDefault(), ) { -    /**-     * @param records the full buffered window of received raw records.-     * @param weightKg body weight for the calorie estimate, or null if unknown.-     * @param heightMeters body height for the stride estimate, or null.-     */-    fun derive(-        records: List<ReceivedRecord>,-        weightKg: Double?,-        heightMeters: Double?,-    ): List<Record> {+    /** @param records the full buffered window of received raw records. */+    fun derive(records: List<ReceivedRecord>): List<Record> {         if (records.isEmpty()) return emptyList()-        val out = mutableListOf<Record>()--        val byType = records.groupBy { it.type }-        val hr = byType["HeartRate"].orEmpty().sortedBy { it.timestamp }-        val steps = byType["Steps"].orEmpty().sortedBy { it.timestamp }-        val pressure = byType["Pressure"].orEmpty().sortedBy { it.timestamp }+        val hr = records.filter { it.type == "HeartRate" }.sortedBy { it.timestamp } -        out += distanceRecords(steps, heightMeters)-        out += elevationAndFloors(pressure)+        val out = mutableListOf<Record>()         out += restingHeartRate(hr)-        out += activeCalories(hr, weightKg)         out += sleepSessions(hr)         return out     } -    // Distance = Σ step deltas × stride, summed per calendar day.-    private fun distanceRecords(steps: List<ReceivedRecord>, heightMeters: Double?): List<Record> {-        val stride = heightMeters?.let { it * STRIDE_HEIGHT_FACTOR } ?: DEFAULT_STRIDE_METERS-        return steps.groupBy { dateOf(it.timestamp) }.mapNotNull { (day, rows) ->-            val meters = rows.sumOf { it.delta } * stride-            if (meters <= 0.0) return@mapNotNull null-            val (start, end) = dayBounds(day, rows)-            DistanceRecord(-                startTime = start,-                startZoneOffset = offset(start),-                endTime = end,-                endZoneOffset = offset(end),-                distance = Length.meters(meters),-                metadata = Metadata.manualEntry(clientRecordId = "distance-$day"),-            )-        }-    }--    // Consecutive pressure readings -> altitude deltas; net positive gain per day.-    private fun elevationAndFloors(pressure: List<ReceivedRecord>): List<Record> {-        if (pressure.size < 2) return emptyList()-        val gainByDay = mutableMapOf<LocalDate, Double>()-        for (i in 1 until pressure.size) {-            val prev = pressure[i - 1]-            val cur = pressure[i]-            val delta = altitudeMeters(cur.value) - altitudeMeters(prev.value)-            if (delta > ELEVATION_NOISE_METERS) {-                val day = dateOf(cur.timestamp)-                gainByDay[day] = (gainByDay[day] ?: 0.0) + delta-            }-        }-        val out = mutableListOf<Record>()-        for ((day, gain) in gainByDay) {-            if (gain <= 0.0) continue-            val rows = pressure.filter { dateOf(it.timestamp) == day }-            val (start, end) = dayBounds(day, rows)-            out += ElevationGainedRecord(-                startTime = start,-                startZoneOffset = offset(start),-                endTime = end,-                endZoneOffset = offset(end),-                elevation = Length.meters(gain),-                metadata = Metadata.manualEntry(clientRecordId = "elevation-$day"),-            )-            out += FloorsClimbedRecord(-                startTime = start,-                startZoneOffset = offset(start),-                endTime = end,-                endZoneOffset = offset(end),-                floors = gain / METERS_PER_FLOOR,-                metadata = Metadata.manualEntry(clientRecordId = "floors-$day"),-            )-        }-        return out-    }-     // Resting HR = low-quantile of stationary HR readings per day.     private fun restingHeartRate(hr: List<ReceivedRecord>): List<Record> {         return hr.filter { it.stationary && it.value > 0.0 }@@ -132,35 +55,6 @@ class HealthDerivations(             }     } -    // Active calories via a Keytel-style HR estimate, summed per day.-    private fun activeCalories(hr: List<ReceivedRecord>, weightKg: Double?): List<Record> {-        if (weightKg == null || weightKg <= 0.0) return emptyList()-        val kcalByDay = mutableMapOf<LocalDate, Double>()-        for (i in 1 until hr.size) {-            val prev = hr[i - 1]-            val cur = hr[i]-            val minutes = (cur.timestamp - prev.timestamp) / 60_000.0-            if (minutes <= 0.0 || minutes > MAX_SAMPLE_GAP_MIN) continue-            val perMin = keytelKcalPerMin(cur.value, weightKg)-            if (perMin <= 0.0) continue-            val day = dateOf(cur.timestamp)-            kcalByDay[day] = (kcalByDay[day] ?: 0.0) + perMin * minutes-        }-        return kcalByDay.mapNotNull { (day, kcal) ->-            if (kcal <= 0.0) return@mapNotNull null-            val rows = hr.filter { dateOf(it.timestamp) == day }-            val (start, end) = dayBounds(day, rows)-            ActiveCaloriesBurnedRecord(-                startTime = start,-                startZoneOffset = offset(start),-                endTime = end,-                endZoneOffset = offset(end),-                energy = Energy.kilocalories(kcal),-                metadata = Metadata.manualEntry(clientRecordId = "calories-$day"),-            )-        }-    }-     // Sleep = contiguous night-time spans of stationary + low HR, >= min duration.     private fun sleepSessions(hr: List<ReceivedRecord>): List<Record> {         val nightly = hr.filter {@@ -207,29 +101,11 @@ class HealthDerivations(      // --- helpers --- -    private fun keytelKcalPerMin(bpm: Double, weightKg: Double): Double {-        // Keytel et al. (2005), sex/age-agnostic simplification with default age.-        val kcal = (-55.0969 + 0.6309 * bpm + 0.1988 * weightKg + 0.2017 * DEFAULT_AGE) / 4.184-        return kcal.coerceAtLeast(0.0)-    }--    // Standard barometric (hypsometric) altitude from station pressure in hPa.-    private fun altitudeMeters(hpa: Double): Double =-        44_330.0 * (1.0 - (hpa / SEA_LEVEL_HPA).pow(0.190_294))-     private fun dateOf(ms: Long): LocalDate =         Instant.ofEpochMilli(ms).atZone(zone).toLocalDate()      private fun offset(instant: Instant) = zone.rules.getOffset(instant) -    // Span the actual first..last row of the day (clamped so end > start).-    private fun dayBounds(day: LocalDate, rows: List<ReceivedRecord>): Pair<Instant, Instant> {-        val start = Instant.ofEpochMilli(rows.minOf { it.timestamp })-        var end = Instant.ofEpochMilli(rows.maxOf { it.timestamp })-        if (!end.isAfter(start)) end = start.plusSeconds(1)-        return start to end-    }-     private fun isNightTime(ms: Long): Boolean {         val t = Instant.ofEpochMilli(ms).atZone(zone).toLocalTime()         // Overnight window wraps midnight: [20:00, 24:00) ∪ [00:00, 10:00).@@ -237,15 +113,8 @@ class HealthDerivations(     }      companion object {-        private const val STRIDE_HEIGHT_FACTOR = 0.415-        private const val DEFAULT_STRIDE_METERS = 0.762-        private const val SEA_LEVEL_HPA = 1_013.25-        private const val METERS_PER_FLOOR = 3.0-        private const val ELEVATION_NOISE_METERS = 0.5         private const val RESTING_QUANTILE = 0.05         private const val MIN_RESTING_SAMPLES = 3-        private const val DEFAULT_AGE = 30.0-        private const val MAX_SAMPLE_GAP_MIN = 5.0         private const val SLEEP_HR_THRESHOLD = 60.0         private const val MIN_SLEEP_DURATION_MS = 3 * 60 * 60 * 1000L         private const val SLEEP_GAP_MS = 30 * 60 * 1000L
watch/phone/src/main/java/com/vayunmathur/watch/phone/sync/SyncForegroundService.kt
diff --git a/watch/phone/src/main/java/com/vayunmathur/watch/phone/sync/SyncForegroundService.kt b/watch/phone/src/main/java/com/vayunmathur/watch/phone/sync/SyncForegroundService.ktindex 928bb04484..5a1b269671 100644--- a/watch/phone/src/main/java/com/vayunmathur/watch/phone/sync/SyncForegroundService.kt+++ b/watch/phone/src/main/java/com/vayunmathur/watch/phone/sync/SyncForegroundService.kt@@ -37,10 +37,6 @@ class SyncForegroundService : Service() {     private lateinit var buffer: ReceivedDatabase     private val derivations = HealthDerivations() -    // Cached body metrics from Health Connect, refreshed on each batch.-    @Volatile private var weightKg: Double? = null-    @Volatile private var heightMeters: Double? = null-     override fun onCreate() {         super.onCreate()         client = GattClientManager(this)@@ -66,7 +62,7 @@ class SyncForegroundService : Service() {     }      private suspend fun processBatch(records: List<WatchRecord>) {-        // 1. Write raw HR/Steps directly (existing behavior).+        // 1. Write raw HR/Steps and the direct daily totals to Health Connect.         health.insert(records)          // 2. Persist the batch into the rolling phone-side buffer.@@ -83,17 +79,13 @@ class SyncForegroundService : Service() {             },         ) -        // 3. Refresh cached body metrics for the estimators.-        weightKg = health.latestWeightKg() ?: weightKg-        heightMeters = health.latestHeightMeters() ?: heightMeters--        // 4. Run derivations over the buffered window and upsert into HC.+        // 3. Run resting-HR + sleep derivations over the buffered window.         val cutoff = System.currentTimeMillis() - BUFFER_WINDOW_MS         val buffered = buffer.receivedDao().getInRange(cutoff, Long.MAX_VALUE)-        val derived = derivations.derive(buffered, weightKg, heightMeters)+        val derived = derivations.derive(buffered)         health.insertDerived(derived) -        // 5. Prune buffer rows outside the rolling window.+        // 4. Prune buffer rows outside the rolling window.         buffer.receivedDao().deleteOlderThan(cutoff)     } 
watch/phone/src/main/res/values/strings.xml
diff --git a/watch/phone/src/main/res/values/strings.xml b/watch/phone/src/main/res/values/strings.xmlindex 51cec476d7..7cee3744a4 100644--- a/watch/phone/src/main/res/values/strings.xml+++ b/watch/phone/src/main/res/values/strings.xml@@ -13,10 +13,6 @@     <string name="state_connected">Connected</string>     <string name="rationale_title">Health Connect Permissions</string>     <string name="rationale_body">This app writes heart rate and step data collected from your watch into Health Connect.</string>-    <string name="weight_prompt_title">Enter your weight</string>-    <string name="weight_prompt_body">Your weight is used to estimate active calories from your watch data. It is saved to Health Connect.</string>-    <string name="weight_prompt_hint">Weight (kg)</string>-    <string name="weight_prompt_save">Save</string>     <string name="notification_channel_name">Watch Sync</string>     <string name="notification_title">Syncing watch health data</string>     <string name="notification_text">Maintaining BLE link and writing to Health Connect</string>