only:refactoring: extract painting status panel into `executeDfuAndPaintStatusPanel` method #7395
This commit is contained in:
parent
95a3675779
commit
5ca5fe3e36
|
@ -61,7 +61,7 @@ public class DfuFlasher {
|
||||||
JobHelper.doJob(
|
JobHelper.doJob(
|
||||||
() -> {
|
() -> {
|
||||||
timeForDfuSwitch(callbacks);
|
timeForDfuSwitch(callbacks);
|
||||||
executeDFU(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
executeDfuAndPaintStatusPanel(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
||||||
},
|
},
|
||||||
onJobFinished
|
onJobFinished
|
||||||
);
|
);
|
||||||
|
@ -154,25 +154,38 @@ public class DfuFlasher {
|
||||||
|
|
||||||
public static void runDfuProgramming(UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
public static void runDfuProgramming(UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
||||||
submitAction(() -> {
|
submitAction(() -> {
|
||||||
JobHelper.doJob(() -> executeDFU(callbacks, FindFileHelper.FIRMWARE_BIN_FILE), onJobFinished);
|
JobHelper.doJob(
|
||||||
|
() -> executeDfuAndPaintStatusPanel(callbacks, FindFileHelper.FIRMWARE_BIN_FILE),
|
||||||
|
onJobFinished
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runOpenBltInitialProgramming(UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
public static void runOpenBltInitialProgramming(UpdateOperationCallbacks callbacks, final Runnable onJobFinished) {
|
||||||
submitAction(() -> {
|
submitAction(() -> {
|
||||||
JobHelper.doJob(
|
JobHelper.doJob(
|
||||||
() -> executeDFU(callbacks, DfuFlasher.BOOTLOADER_BIN_FILE),
|
() -> executeDfuAndPaintStatusPanel(callbacks, DfuFlasher.BOOTLOADER_BIN_FILE),
|
||||||
onJobFinished
|
onJobFinished
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void executeDFU(UpdateOperationCallbacks callbacks, String firmwareBinFile) {
|
private static void executeDfuAndPaintStatusPanel(
|
||||||
|
final UpdateOperationCallbacks callbacks,
|
||||||
|
final String firmwareBinFile
|
||||||
|
) {
|
||||||
|
if (executeDFU(callbacks, firmwareBinFile)) {
|
||||||
|
callbacks.done();
|
||||||
|
} else {
|
||||||
|
callbacks.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean executeDFU(UpdateOperationCallbacks callbacks, String firmwareBinFile) {
|
||||||
boolean driverIsHappy = detectSTM32BootloaderDriverState(callbacks);
|
boolean driverIsHappy = detectSTM32BootloaderDriverState(callbacks);
|
||||||
if (!driverIsHappy) {
|
if (!driverIsHappy) {
|
||||||
callbacks.logLine("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?");
|
callbacks.logLine("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?");
|
||||||
callbacks.error();
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer stdout = new StringBuffer();
|
StringBuffer stdout = new StringBuffer();
|
||||||
|
@ -183,27 +196,26 @@ public class DfuFlasher {
|
||||||
DFU_CMD_TOOL, callbacks, stdout);
|
DFU_CMD_TOOL, callbacks, stdout);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
callbacks.logLine("ERROR: " + e);
|
callbacks.logLine("ERROR: " + e);
|
||||||
callbacks.error();
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stdout.toString().contains("Download verified successfully")) {
|
if (stdout.toString().contains("Download verified successfully")) {
|
||||||
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
||||||
callbacks.logLine("SUCCESS!");
|
callbacks.logLine("SUCCESS!");
|
||||||
callbacks.logLine("Please power cycle device to exit DFU mode");
|
callbacks.logLine("Please power cycle device to exit DFU mode");
|
||||||
callbacks.done();
|
return true;
|
||||||
} else if (stdout.toString().contains("Target device not found")) {
|
} else if (stdout.toString().contains("Target device not found")) {
|
||||||
callbacks.logLine("ERROR: Device not connected or STM32 Bootloader driver not installed?");
|
callbacks.logLine("ERROR: Device not connected or STM32 Bootloader driver not installed?");
|
||||||
appendWindowsVersion(callbacks);
|
appendWindowsVersion(callbacks);
|
||||||
callbacks.logLine("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
|
callbacks.logLine("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
|
||||||
callbacks.logLine("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
|
callbacks.logLine("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
|
||||||
appendDeviceReport(callbacks);
|
appendDeviceReport(callbacks);
|
||||||
callbacks.error();
|
return false;
|
||||||
} else {
|
} else {
|
||||||
appendWindowsVersion(callbacks);
|
appendWindowsVersion(callbacks);
|
||||||
appendDeviceReport(callbacks);
|
appendDeviceReport(callbacks);
|
||||||
callbacks.logLine(stdout.length() + " / " + errorResponse.length());
|
callbacks.logLine(stdout.length() + " / " + errorResponse.length());
|
||||||
callbacks.error();
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue