MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / create_emulator

Method create_emulator

packages/server/src/android.rs:208–248  ·  view source on GitHub ↗
(&self, spec: AndroidEmulatorSpec)

Source from the content-addressed store, hash-verified

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)?;

Callers 1

create_simulatorFunction · 0.80

Calls 4

validate_avd_nameFunction · 0.85
is_emptyMethod · 0.80
run_emulatorMethod · 0.80

Tested by

no test coverage detected