(&self, spec: AndroidEmulatorSpec)
| 206 | } |
| 207 | |
| 208 | pub fn create_emulator(&self, spec: AndroidEmulatorSpec) -> Result<Value, AppError> { |
| 209 | validate_avd_name(&spec.name)?; |
| 210 | if spec.device_profile_identifier.trim().is_empty() { |
| 211 | return Err(AppError::bad_request( |
| 212 | "Android emulator creation requires `deviceTypeIdentifier`.", |
| 213 | )); |
| 214 | } |
| 215 | if spec.system_image_identifier.trim().is_empty() { |
| 216 | return Err(AppError::bad_request( |
| 217 | "Android emulator creation requires `runtimeIdentifier`.", |
| 218 | )); |
| 219 | } |
| 220 | if self |
| 221 | .run_emulator(["-list-avds"])? |
| 222 | .lines() |
| 223 | .map(str::trim) |
| 224 | .any(|avd_name| avd_name == spec.name) |
| 225 | { |
| 226 | return Err(AppError::bad_request(format!( |
| 227 | "Android emulator `{}` already exists.", |
| 228 | spec.name |
| 229 | ))); |
| 230 | } |
| 231 | |
| 232 | self.run_avdmanager_with_stdin( |
| 233 | [ |
| 234 | "create", |
| 235 | "avd", |
| 236 | "--name", |
| 237 | &spec.name, |
| 238 | "--package", |
| 239 | &spec.system_image_identifier, |
| 240 | "--device", |
| 241 | &spec.device_profile_identifier, |
| 242 | ], |
| 243 | "no\n", |
| 244 | )?; |
| 245 | Ok(json!({ |
| 246 | "udid": id_for_avd(&spec.name), |
| 247 | })) |
| 248 | } |
| 249 | |
| 250 | pub fn boot(&self, id: &str) -> Result<bool, AppError> { |
| 251 | let avd_name = avd_from_id(id)?; |
no test coverage detected