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();
|
||||
}
|
||||
|
||||
public static void doAutoDfu(JComponent parent, String port, UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
||||
try {
|
||||
if (port == null) {
|
||||
JOptionPane.showMessageDialog(parent, "Failed to locate serial ports");
|
||||
public static void doAutoDfu(JComponent parent, String port, UpdateOperationCallbacks callbacks) {
|
||||
if (port == null) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
timeForDfuSwitch(callbacks);
|
||||
executeDfuAndPaintStatusPanel(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
||||
} else {
|
||||
callbacks.logLine("Please use manual DFU to change bundle type.");
|
||||
}
|
||||
} finally {
|
||||
onJobFinished.run();
|
||||
timeForDfuSwitch(callbacks);
|
||||
executeDfuAndPaintStatusPanel(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
||||
} else {
|
||||
callbacks.logLine("Please use manual DFU to change bundle type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ public class DfuAutoJob extends AsyncJobWithContext<SerialPortWithParentComponen
|
|||
|
||||
@Override
|
||||
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