mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-15 02:36:12 -04:00
refactor: Remove meta from PodDevice public API and delete unused PodMonitorExtensions
All external consumers now use top-level PodDevice properties. BlePodMonitor extensions were dead code — all callers use DeviceMonitor equivalents.
This commit is contained in:
@@ -32,8 +32,8 @@ class DeviceMonitor @Inject constructor(
|
||||
) { pods, aapStates, cachedStates, profiles ->
|
||||
// Live devices — BLE + AAP + cached fallback for missing fields
|
||||
val liveDevices = pods.map { pod ->
|
||||
val bondedAddress = pod.meta?.profile?.address
|
||||
val profile = pod.meta?.profile
|
||||
val bondedAddress = pod.meta.profile?.address
|
||||
val profile = pod.meta.profile
|
||||
PodDevice(
|
||||
profileId = profile?.id,
|
||||
label = profile?.label,
|
||||
|
||||
@@ -40,7 +40,6 @@ data class PodDevice(
|
||||
/** BLE scan address (RPA, rotates). */
|
||||
val bleAddress: BluetoothAddress? get() = ble?.address
|
||||
val identifier: BlePodSnapshot.Id? get() = ble?.identifier
|
||||
val meta: BlePodSnapshot.Meta? get() = ble?.meta
|
||||
|
||||
/** True when at least one live data source (BLE or AAP) is present. */
|
||||
val isLive: Boolean get() = ble != null || aap != null
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package eu.darken.capod.monitor.core
|
||||
|
||||
import eu.darken.capod.pods.core.apple.ble.BlePodSnapshot
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
fun BlePodMonitor.devicesWithProfiles(): Flow<List<BlePodSnapshot>> = devices
|
||||
.map { devices -> devices.filter { it.meta.profile != null } }
|
||||
|
||||
fun BlePodMonitor.primaryDevice(): Flow<BlePodSnapshot?> = devicesWithProfiles().map { it.firstOrNull() }
|
||||
@@ -98,25 +98,21 @@ class PodDeviceTest : BaseTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `identity properties delegate to BLE`() {
|
||||
fun `identifier delegates to BLE`() {
|
||||
val id = BlePodSnapshot.Id()
|
||||
val meta = mockk<BlePodSnapshot.Meta>(relaxed = true)
|
||||
val device = PodDevice(
|
||||
profileId = null, ble = mockk(relaxed = true) {
|
||||
every { identifier } returns id
|
||||
every { this@mockk.meta } returns meta
|
||||
},
|
||||
aap = null,
|
||||
)
|
||||
device.identifier shouldBe id
|
||||
device.meta shouldBe meta
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `identity properties null when BLE null`() {
|
||||
fun `identifier null when BLE null`() {
|
||||
val device = PodDevice(profileId = null, ble = null, aap = null)
|
||||
device.identifier.shouldBeNull()
|
||||
device.meta.shouldBeNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user