From 4f3e4d71af9282a2a5d054a49324909df3884a7a Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 6 Jun 2023 15:40:53 +0300 Subject: [PATCH] fix: fallback to model for device name (#172) --- .changes/android-no-bt.md | 5 +++++ src/android/adb/device_list.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changes/android-no-bt.md diff --git a/.changes/android-no-bt.md b/.changes/android-no-bt.md new file mode 100644 index 00000000..c3b133f2 --- /dev/null +++ b/.changes/android-no-bt.md @@ -0,0 +1,5 @@ +--- +"tauri-mobile": "patch" +--- + +Fix `cargo android run` crashing because it can't detect device name using bluetooth_manager for devices without bluetooth like geneymotion. diff --git a/src/android/adb/device_list.rs b/src/android/adb/device_list.rs index c1aebea0..e96734e8 100644 --- a/src/android/adb/device_list.rs +++ b/src/android/adb/device_list.rs @@ -45,16 +45,16 @@ pub fn device_list(env: &Env) -> Result>, Error> { .vars(env.explicit_env()) .stdout_capture(); - super::check_authorized(cmd.start()?.wait()?) + super::check_authorized(&cmd.run()?) .map(|raw_list| { regex_multi_line!(ADB_DEVICE_REGEX) .captures_iter(&raw_list) .map(|caps| { assert_eq!(caps.len(), 2); let serial_no = caps.get(1).unwrap().as_str().to_owned(); - let name = device_name(env, &serial_no).map_err(Error::NameFailed)?; let model = get_prop(env, &serial_no, "ro.product.model") .map_err(Error::ModelFailed)?; + let name = device_name(env, &serial_no).unwrap_or_else(|_| model.clone()); let abi = get_prop(env, &serial_no, "ro.product.cpu.abi") .map_err(Error::AbiFailed)?; let target =