(&self)
| 148 | |
| 149 | impl AndroidBridge { |
| 150 | pub fn list_devices(&self) -> Result<Vec<AndroidDevice>, AppError> { |
| 151 | if !self.emulator_path().exists() { |
| 152 | return Ok(Vec::new()); |
| 153 | } |
| 154 | |
| 155 | let avds = self |
| 156 | .run_emulator(["-list-avds"])? |
| 157 | .lines() |
| 158 | .map(str::trim) |
| 159 | .filter(|line| !line.is_empty()) |
| 160 | .map(ToOwned::to_owned) |
| 161 | .collect::<Vec<_>>(); |
| 162 | if avds.is_empty() { |
| 163 | return Ok(Vec::new()); |
| 164 | } |
| 165 | |
| 166 | let running = self.running_emulators().unwrap_or_default(); |
| 167 | avds.into_iter() |
| 168 | .enumerate() |
| 169 | .map(|(index, avd_name)| { |
| 170 | let console_port = console_port_for_avd_index(index)?; |
| 171 | Ok(AndroidDevice { |
| 172 | serial: running.get(&avd_name).cloned(), |
| 173 | is_booted: running.contains_key(&avd_name), |
| 174 | console_port, |
| 175 | avd_name, |
| 176 | }) |
| 177 | }) |
| 178 | .collect() |
| 179 | } |
| 180 | |
| 181 | pub fn enrich_devices(&self, devices: Vec<AndroidDevice>) -> Vec<Value> { |
| 182 | devices |
no test coverage detected