mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-07-20 06:38:10 -07:00
Fix battery warnings on unsupported devices
Fix #644, break early if battery is unsupported.
This commit is contained in:
committed by
Will Greenberg
parent
262f583355
commit
7e2df91702
@@ -1,6 +1,6 @@
|
|||||||
use std::{path::Path, time::Duration};
|
use std::{path::Path, time::Duration};
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{info, warn};
|
||||||
use rayhunter::Device;
|
use rayhunter::Device;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio::select;
|
use tokio::select;
|
||||||
@@ -66,11 +66,11 @@ pub fn run_battery_notification_worker(
|
|||||||
// Don't send a notification initially if the device starts at a low battery level.
|
// Don't send a notification initially if the device starts at a low battery level.
|
||||||
let mut triggered = match get_battery_status(&device).await {
|
let mut triggered = match get_battery_status(&device).await {
|
||||||
Err(RayhunterError::FunctionNotSupportedForDeviceError) => {
|
Err(RayhunterError::FunctionNotSupportedForDeviceError) => {
|
||||||
info!("Battery level function not supported for device");
|
info!("Battery status not supported for this device, disabling battery notifications");
|
||||||
false
|
return;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to get battery status: {e}");
|
warn!("Failed to get battery status: {e}");
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Ok(status) => status.level <= LOW_BATTERY_LEVEL,
|
Ok(status) => status.level <= LOW_BATTERY_LEVEL,
|
||||||
@@ -83,8 +83,12 @@ pub fn run_battery_notification_worker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let status = match get_battery_status(&device).await {
|
let status = match get_battery_status(&device).await {
|
||||||
|
Err(RayhunterError::FunctionNotSupportedForDeviceError) => {
|
||||||
|
info!("Battery status not supported for this device, disabling battery notifications");
|
||||||
|
break;
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to get battery status: {e}");
|
warn!("Failed to get battery status: {e}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Ok(status) => status,
|
Ok(status) => status,
|
||||||
|
|||||||
Reference in New Issue
Block a user