mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-15 02:36:12 -04:00
Move model identifier out of top level factory and into specific device classes.
This commit is contained in:
@@ -23,7 +23,7 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class AppleFactory @Inject constructor(
|
||||
private val continuityProtocolDecoder: ContinuityProtocol.Decoder,
|
||||
private val proximityPairingDecoder: ProximityPairing.Decoder
|
||||
private val proximityPairingDecoder: ProximityPairing.Decoder,
|
||||
) {
|
||||
|
||||
data class KnownDevice(
|
||||
@@ -153,62 +153,62 @@ class AppleFactory @Inject constructor(
|
||||
val dmDirty = pm.data[1]
|
||||
|
||||
val specificDevice = when {
|
||||
dm == 0x0220.toUShort() -> AirPodsGen1(
|
||||
dm == AirPodsGen1.DEVICE_CODE -> AirPodsGen1(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
cachedBatteryPercentage = cachedCaseBattery,
|
||||
)
|
||||
dm == 0x0F20.toUShort() -> AirPodsGen2(
|
||||
dm == AirPodsGen2.DEVICE_CODE -> AirPodsGen2(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
cachedBatteryPercentage = cachedCaseBattery,
|
||||
)
|
||||
dm == 0x1320.toUShort() -> AirPodsGen3(
|
||||
dm == AirPodsGen3.DEVICE_CODE -> AirPodsGen3(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
cachedBatteryPercentage = cachedCaseBattery,
|
||||
)
|
||||
dm == 0x0e20.toUShort() -> AirPodsPro(
|
||||
dm == AirPodsPro.DEVICE_CODE -> AirPodsPro(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
cachedBatteryPercentage = cachedCaseBattery,
|
||||
)
|
||||
dmDirty == 11.toUByte() -> PowerBeatsPro(
|
||||
dmDirty == PowerBeatsPro.DEVICE_CODE_DIRTY -> PowerBeatsPro(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
cachedBatteryPercentage = cachedCaseBattery,
|
||||
)
|
||||
dmDirty == 10.toUByte() -> AirPodsMax(
|
||||
dmDirty == AirPodsMax.DEVICE_CODE_DIRTY -> AirPodsMax(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm,
|
||||
)
|
||||
dm == 0x0320.toUShort() -> PowerBeats3(
|
||||
dm == PowerBeats3.DEVICE_CODE -> PowerBeats3(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm
|
||||
)
|
||||
dm == 0x0620.toUShort() -> BeatsSolo3(
|
||||
dm == BeatsSolo3.DEVICE_CODE -> BeatsSolo3(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm
|
||||
)
|
||||
dmDirty == 9.toUByte() -> BeatsStudio3(
|
||||
dmDirty == BeatsStudio3.DEVICE_CODE_DIRTY -> BeatsStudio3(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm
|
||||
)
|
||||
dm == 0x0520.toUShort() -> BeatsX(
|
||||
dm == BeatsX.DEVICE_CODE -> BeatsX(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm
|
||||
)
|
||||
dm == 0x1020.toUShort() -> BeatsFlex(
|
||||
dm == BeatsFlex.DEVICE_CODE -> BeatsFlex(
|
||||
identifier = identifier,
|
||||
scanResult = scanResult,
|
||||
proximityMessage = pm
|
||||
|
||||
@@ -23,4 +23,8 @@ data class AirPodsGen1 constructor(
|
||||
|
||||
override val batteryCasePercent: Float?
|
||||
get() = super.batteryCasePercent ?: cachedBatteryPercentage
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x0220.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,8 @@ data class AirPodsGen2 constructor(
|
||||
|
||||
override val batteryCasePercent: Float?
|
||||
get() = super.batteryCasePercent ?: cachedBatteryPercentage
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x0F20.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,8 @@ data class AirPodsGen3 constructor(
|
||||
|
||||
override val batteryCasePercent: Float?
|
||||
get() = super.batteryCasePercent ?: cachedBatteryPercentage
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x1320.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ data class AirPodsMax(
|
||||
override val iconRes: Int
|
||||
get() = R.drawable.ic_device_generic_headphones
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE_DIRTY = 10.toUByte()
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,8 @@ data class AirPodsPro(
|
||||
|
||||
override val batteryCasePercent: Float?
|
||||
get() = super.batteryCasePercent ?: cachedBatteryPercentage
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x0e20.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ data class BeatsFlex(
|
||||
override val iconRes: Int
|
||||
get() = R.drawable.ic_device_generic_earbuds
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x1020.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ data class BeatsSolo3(
|
||||
override val iconRes: Int
|
||||
get() = R.drawable.ic_device_generic_earbuds
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x0620.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ data class BeatsStudio3(
|
||||
override val iconRes: Int
|
||||
get() = R.drawable.ic_device_generic_earbuds
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE_DIRTY = 9.toUByte()
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ data class BeatsX(
|
||||
override val iconRes: Int
|
||||
get() = R.drawable.ic_device_generic_earbuds
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x0520.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,7 @@ data class PowerBeats3(
|
||||
override val iconRes: Int
|
||||
get() = R.drawable.ic_device_generic_earbuds
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE = 0x0320.toUShort()
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,8 @@ data class PowerBeatsPro(
|
||||
|
||||
override val batteryCasePercent: Float?
|
||||
get() = super.batteryCasePercent ?: cachedBatteryPercentage
|
||||
|
||||
companion object {
|
||||
val DEVICE_CODE_DIRTY = 11.toUByte()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user