mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-15 02:36:12 -04:00
Determine case charging state more accurately
The previous logic for determining if the case was charging relied on the `batteryCasePercent` being non-null. This commit refines the logic to check if the `batteryCasePercent` falls within the valid range of 0.0 to 1.0, providing a more accurate assessment of the case's charging status.
This commit is contained in:
@@ -148,8 +148,9 @@ interface DualApplePods : ApplePods, HasChargeDetectionDual, DualPodDevice, HasE
|
||||
override val isCaseCharging: Boolean
|
||||
get() {
|
||||
payload.private?.data?.get(3)?.let { raw ->
|
||||
val level = (raw and 0x7Fu).toInt() / 100f
|
||||
val isCharging = (raw and 0x80u).toInt() != 0
|
||||
if (batteryCasePercent != null) return isCharging
|
||||
if (0f <= level && level <= 1.0f) return isCharging
|
||||
}
|
||||
|
||||
return pubFlags.isBitSet(2)
|
||||
|
||||
Reference in New Issue
Block a user