only:refactoring: now we reuse `JobHelper.doJob` method #7395
This commit is contained in:
parent
08625e8aa2
commit
6a0f551184
|
@ -39,30 +39,26 @@ public class DfuFlasher {
|
||||||
return new File(BOOTLOADER_BIN_FILE).exists();
|
return new File(BOOTLOADER_BIN_FILE).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doAutoDfu(JComponent parent, String port, UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
public static void doAutoDfu(JComponent parent, String port, UpdateOperationCallbacks callbacks) {
|
||||||
try {
|
if (port == null) {
|
||||||
if (port == null) {
|
JOptionPane.showMessageDialog(parent, "Failed to locate serial ports");
|
||||||
JOptionPane.showMessageDialog(parent, "Failed to locate serial ports");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AtomicBoolean isSignatureValidated = rebootToDfu(parent, port, callbacks, Integration.CMD_REBOOT_DFU);
|
||||||
|
if (isSignatureValidated == null)
|
||||||
|
return;
|
||||||
|
if (isSignatureValidated.get()) {
|
||||||
|
if (!FileLog.isWindows()) {
|
||||||
|
callbacks.logLine("Switched to DFU mode!");
|
||||||
|
callbacks.logLine("rusEFI console can only program on Windows");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomicBoolean isSignatureValidated = rebootToDfu(parent, port, callbacks, Integration.CMD_REBOOT_DFU);
|
timeForDfuSwitch(callbacks);
|
||||||
if (isSignatureValidated == null)
|
executeDfuAndPaintStatusPanel(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
||||||
return;
|
} else {
|
||||||
if (isSignatureValidated.get()) {
|
callbacks.logLine("Please use manual DFU to change bundle type.");
|
||||||
if (!FileLog.isWindows()) {
|
|
||||||
callbacks.logLine("Switched to DFU mode!");
|
|
||||||
callbacks.logLine("rusEFI console can only program on Windows");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeForDfuSwitch(callbacks);
|
|
||||||
executeDfuAndPaintStatusPanel(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
|
||||||
} else {
|
|
||||||
callbacks.logLine("Please use manual DFU to change bundle type.");
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
onJobFinished.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ public class DfuAutoJob extends AsyncJobWithContext<SerialPortWithParentComponen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doJob(final UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
public void doJob(final UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
||||||
DfuFlasher.doAutoDfu(context.getParent(), context.getPort().port, callbacks, onJobFinished);
|
JobHelper.doJob(
|
||||||
|
() -> DfuFlasher.doAutoDfu(context.getParent(), context.getPort().port, callbacks),
|
||||||
|
onJobFinished
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue