From b76d78b4fa5c02af9b1a96ae826268a4439157dc Mon Sep 17 00:00:00 2001 From: huyua9 Date: Thu, 13 Aug 2026 07:20:00 +0800 Subject: [PATCH] fix(firetv): unify not-awake error guidance --- crates/core/src/firetv/mod.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/core/src/firetv/mod.rs b/crates/core/src/firetv/mod.rs index a6aedab..56f016e 100644 --- a/crates/core/src/firetv/mod.rs +++ b/crates/core/src/firetv/mod.rs @@ -160,7 +160,7 @@ pub fn perform_action(ip: &str, action: FireTvAction) -> Result { if awake { Ok(format!("Fire TV at {target} is awake")) } else { - bail!("Fire TV at {target} did not wake after retries. Confirm the TV is powered on and still accepts ADB commands.") + bail!(fire_tv_not_awake_message(&target)) } } FireTvAction::LaunchSpotify => { @@ -190,7 +190,7 @@ pub fn prepare_spotify_session(ip: &str) -> Result { let awake = ensure_awake(&target, 4)?; if !awake { - bail!("Fire TV at {target} did not wake after retries"); + bail!(fire_tv_not_awake_message(&target)); } open_spotify(&target)?; @@ -288,7 +288,7 @@ pub fn launch_app(ip: &str, package_name: &str) -> Result { let awake = ensure_awake(&target, 4)?; if !awake { - bail!("Fire TV at {target} did not wake after retries"); + bail!(fire_tv_not_awake_message(&target)); } run_adb(&["-s", &target, "shell", "monkey", "-p", package_name, "1"])?; @@ -311,6 +311,12 @@ fn fire_tv_unreachable_message(target: &str) -> String { ) } +fn fire_tv_not_awake_message(target: &str) -> String { + format!( + "Fire TV at {target} did not wake after retries. Confirm the TV is powered on and still accepts ADB commands." + ) +} + fn ensure_adb_available() -> Result<()> { run_adb_with_timeout(&["version"], ADB_STATUS_TIMEOUT) .map(|_| ()) @@ -592,6 +598,16 @@ mod tests { assert!(message.contains("ADB debugging")); assert!(message.contains("debugging prompt")); } + + #[test] + fn fire_tv_not_awake_message_lists_power_and_adb_steps() { + let message = fire_tv_not_awake_message("192.168.1.50:5555"); + + assert!(message.contains("192.168.1.50:5555")); + assert!(message.contains("powered on")); + assert!(message.contains("ADB commands")); + assert!(message.contains("retries")); + } } fn current_epoch_ms() -> Result {