// Start dumping logcat to temporary file
final File artifactsDir = build.getArtifactsDir();
final FilePath logcatFile = build.getWorkspace().createTextTempFile("logcat_", ".log", "", false);
final OutputStream logcatStream = logcatFile.write();
final String logcatArgs = String.format("-s %s logcat -v time", emu.serial());
final Proc logWriter = emu.getToolProcStarter(Tool.ADB, logcatArgs).stdout(logcatStream).stderr(new NullStream()).start();
// Unlock emulator by pressing the Menu key once, if required.
// Upon first boot (and when the data is wiped) the emulator is already unlocked
final long bootDuration = System.currentTimeMillis() - bootTime;
if (emulatorAlreadyExists && !wipeData && snapshotState != SnapshotState.BOOT) {