mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
Fix lid detection tests
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package eu.darken.capod.pods.core.apple
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Range
|
||||
import androidx.annotation.StringRes
|
||||
import eu.darken.capod.R
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
@@ -98,7 +97,7 @@ interface DualApplePods : ApplePods, HasDualPods, HasEarDetection, HasCase {
|
||||
|
||||
val caseLidState: LidState
|
||||
get() {
|
||||
return LidState.values().firstOrNull { it.rawRange.contains(rawCaseLidState) } ?: LidState.UNKNOWN
|
||||
return LidState.values().firstOrNull { it.rawRange.contains(rawCaseLidState.toInt()) } ?: LidState.UNKNOWN
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,13 +108,11 @@ interface DualApplePods : ApplePods, HasDualPods, HasEarDetection, HasCase {
|
||||
* They reset after some time to their start values.
|
||||
* The upper limits are not the maximums but are only reached if playing with the case.
|
||||
*/
|
||||
enum class LidState(val rawRange: Range<UByte>) {
|
||||
OPEN(0x30, 0x37),
|
||||
CLOSED(0x38, 0x3F),
|
||||
NOT_IN_CASE(0x00, 0x03),
|
||||
UNKNOWN(0xFF, 0xFF);
|
||||
|
||||
constructor(vararg raw: Int) : this(Range(raw[0].toUByte(), (raw[1].toUByte())))
|
||||
enum class LidState(val rawRange: IntRange) {
|
||||
OPEN(0x30..0x37),
|
||||
CLOSED(0x38..0x3F),
|
||||
NOT_IN_CASE(0x00..0x03),
|
||||
UNKNOWN(0xFF..0xFF);
|
||||
}
|
||||
|
||||
val deviceColor: DeviceColor
|
||||
|
||||
@@ -188,7 +188,7 @@ class DualApplePodsTest : BaseAirPodsTest() {
|
||||
// Lid just closed
|
||||
create<DualApplePods>("07 19 01 0E 20 55 AA B4 >39< 00 00 08 A6 DB 99 E0 5E 14 85 E5 C2 0B 68 D7 FF C3 A1") {
|
||||
// 39 0011 1001
|
||||
caseLidState shouldBe DualApplePods.LidState.UNKNOWN
|
||||
caseLidState shouldBe DualApplePods.LidState.CLOSED
|
||||
}
|
||||
// Lid closed
|
||||
create<DualApplePods>("07 19 01 0E 20 55 AA B4 38 00 00 F3 F7 08 3B 98 09 C0 DD E4 BD BD 84 55 56 8B 81") {
|
||||
|
||||
Reference in New Issue
Block a user