Skip to content

Commit

Permalink
Adjust trigger conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Sep 12, 2024
1 parent 2d6a3b3 commit 95f3ca2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class PowerAlertManager @Inject constructor(

when (rule) {
is BatteryLowAlertRule -> {
val isTriggered =
!powerState.data.isCharging && powerState.data.battery.percent < rule.threshold
val isRecovered =
powerState.data.battery.percent > (rule.threshold + 0.05f).coerceAtMost(0.95f)
val isTriggered = !powerState.data.isCharging &&
powerState.data.battery.percent < rule.threshold
val isRecovered = powerState.data.isCharging ||
powerState.data.battery.percent > (rule.threshold + 0.05f).coerceAtMost(0.95f)
when {
event == null && isTriggered && !isRecovered -> {
log(TAG, INFO) { "Rule has triggered" }
Expand Down

0 comments on commit 95f3ca2

Please sign in to comment.