Thread.sleep(bootDuration / 4);
log(logger, Messages.UNLOCKING_SCREEN());
final String keyEventArgs = String.format("-s %s shell input keyevent %%d", emu.serial());
final String menuArgs = String.format(keyEventArgs, 82);
ArgumentListBuilder menuCmd = emu.getToolCommand(Tool.ADB, menuArgs);
emu.getProcStarter(menuCmd).join();
// If a named emulator already existed, it may not have been booted yet, so the screen
// wouldn't be locked. Similarly, an non-named emulator may have already booted the
// first time without us knowing. In both cases, we press Back after Menu to compensate
final String backArgs = String.format(keyEventArgs, 4);
ArgumentListBuilder backCmd = emu.getToolCommand(Tool.ADB, backArgs);
emu.getProcStarter(backCmd).join();
}
// Initialise snapshot image, if required
if (snapshotState == SnapshotState.INITIALISE) {
// In order to create a clean initial snapshot, give the system some more time to settle
log(logger, Messages.WAITING_INITIAL_SNAPSHOT());
Thread.sleep((long) (bootDuration * 0.8));
// Clear main log before creating snapshot
final String clearArgs = String.format("-s %s logcat -c", emu.serial());
ArgumentListBuilder adbCmd = emu.getToolCommand(Tool.ADB, clearArgs);
emu.getProcStarter(adbCmd).join();
final String msg = Messages.LOG_CREATING_SNAPSHOT();
final String logArgs = String.format("-s %s shell log -p v -t Jenkins '%s'", emu.serial(), msg);
adbCmd = emu.getToolCommand(Tool.ADB, logArgs);
emu.getProcStarter(adbCmd).join();