diff --git a/src/main/java/FRUtils.java b/src/main/java/FRUtils.java index 59a7d05..ce25903 100644 --- a/src/main/java/FRUtils.java +++ b/src/main/java/FRUtils.java @@ -52,7 +52,7 @@ public static boolean updateFRGUI(MainMenu mainMenuInstance) throws IOException, JPanel mainMenuView = mainMenuInstance.getMainMenuView(); // If FutureRestore process is running, cancel early - if (!(FutureRestoreWorker.futureRestoreProcess == null || !FutureRestoreWorker.futureRestoreProcess.isAlive())) { + if (FutureRestoreWorker.futureRestoreProcess != null && FutureRestoreWorker.futureRestoreProcess.isAlive()) { failUpdate("Can't update when FutureRestore is running!", mainMenuInstance, false); return false; } @@ -60,6 +60,9 @@ public static boolean updateFRGUI(MainMenu mainMenuInstance) throws IOException, // Disable the whole menu setEnabled(mainMenuView, false, true); + // Switch to "Controls" tab + mainMenuInstance.getTabbedPane().setSelectedIndex(2); + String osName = System.getProperty("os.name").toLowerCase(); String frguiDownloadIdentifier = null; if (osName.contains("mac")) { @@ -84,6 +87,7 @@ public static boolean updateFRGUI(MainMenu mainMenuInstance) throws IOException, } return false; } else { + mainMenuInstance.messageToLog("Downloading FutureRestore GUI..."); File downloadedFrgui = downloadFRGUI(mainMenuInstance, frguiDownloadIdentifier); if (downloadedFrgui == null) { @@ -91,6 +95,7 @@ public static boolean updateFRGUI(MainMenu mainMenuInstance) throws IOException, return false; } + mainMenuInstance.messageToLog("Installing FutureRestore GUI..."); if (installFrgui(downloadedFrgui, frguiDownloadIdentifier, mainMenuInstance)) { System.out.println("All done updating FRGUI. Closing now..."); System.exit(0); @@ -302,13 +307,8 @@ else if (disabledComponents.contains(component)) { if (component instanceof Container) { for (Component child : ((Container) component).getComponents()) { - // If disabling, add the previously disabled to this list - /*if (!toSet) { - if (!child.isEnabled()) - disabledComponents.add(child); - }*/ // Else if enabling, if the component was in the list, don't enable it - if (disabledComponents.contains(child)) { + if (toSet && disabledComponents.contains(child)) { continue; } setEnabled(child, toSet, false); diff --git a/src/main/java/FutureRestoreWorker.java b/src/main/java/FutureRestoreWorker.java index 6373007..8627ded 100644 --- a/src/main/java/FutureRestoreWorker.java +++ b/src/main/java/FutureRestoreWorker.java @@ -117,7 +117,7 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList all if (!hasRecoveryRestarted) { hasRecoveryRestarted = true; //Ensure current process is killed - if (futureRestoreProcess.isAlive()) + if (FutureRestoreWorker.futureRestoreProcess != null && FutureRestoreWorker.futureRestoreProcess.isAlive()) futureRestoreProcess.destroy(); //Restart new Thread(() -> { diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 9a3c99e..c475f1f 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,14 +1,14 @@ public class Main { public static void main(String[] args) { - MainMenu.futureRestoreGUIVersion = "1.90"; + MainMenu.futureRestoreGUIVersion = "1.91"; MainMenu.main(); /* - ⟍ ⟋ - × - ⟋ ⟍ - "I can do a cartwheel." + | + — + — + | + "Are you confined like me?" */ diff --git a/src/main/java/MainMenu.form b/src/main/java/MainMenu.form index 655d2fe..4d77458 100644 --- a/src/main/java/MainMenu.form +++ b/src/main/java/MainMenu.form @@ -251,6 +251,7 @@ + @@ -415,7 +416,7 @@ - + diff --git a/src/main/java/MainMenu.java b/src/main/java/MainMenu.java index b7e84ce..bf918df 100644 --- a/src/main/java/MainMenu.java +++ b/src/main/java/MainMenu.java @@ -198,6 +198,10 @@ public MainMenu() { justBootCheckBox.setSelected(false); justBootCheckBox.setEnabled(false); justBootLabel.setEnabled(false); + + // Since we turn off the switches for pwndfu required items, also turn them off internally + optionNoIbssState = false; + optionJustBootState = false; } }; debugDCheckBox.addActionListener(optionsListener); @@ -209,13 +213,22 @@ public MainMenu() { justBootCheckBox.addActionListener(optionsListener); startFutureRestoreButton.addActionListener(e -> { - //Ensure they have FutureRestore selected + // If FutureRestore is already running, just disable ourselves + if (FutureRestoreWorker.futureRestoreProcess != null && FutureRestoreWorker.futureRestoreProcess.isAlive()) { + SwingUtilities.invokeLater(() -> { + startFutureRestoreButton.setEnabled(false); + // Potentially make the button say unsafe again + }); + return; + } + + // Ensure they have FutureRestore selected if (futureRestoreFilePath == null) { JOptionPane.showMessageDialog(mainMenuView, "Please select a FutureRestore executable.", "No FutureRestore Selected", JOptionPane.ERROR_MESSAGE); return; } - //Ensure they actually selected a blob, IPSW, and buildmanifest if needed + // Ensure they actually selected a blob, IPSW, and buildmanifest if needed if (blobFilePath == null) { JOptionPane.showMessageDialog(mainMenuView, "Select a blob file.", "Error", JOptionPane.ERROR_MESSAGE); return; @@ -272,20 +285,24 @@ public MainMenu() { if (optionNoIbssState) allArgs.add("--no-ibss"); if (optionJustBootState) { - allArgs.add("--just-boot"); - allArgs.add("'-v'"); + allArgs.add("--just-boot=\"-v\""); } switch (sepState) { - case "latest": + case "latest": { allArgs.add("--latest-sep"); break; - case "manual": + } + case "manual": { allArgs.add("--sep"); allArgs.add(sepFilePath); allArgs.add("--sep-manifest"); allArgs.add(buildManifestPath); break; + } +// // No SEP is just no arg +// case "none": +// break; } switch (bbState) { @@ -320,13 +337,14 @@ public MainMenu() { basebandComboBox.addActionListener(e -> { switch (basebandComboBox.getSelectedItem().toString()) { - case "Latest Baseband": + case "Latest Baseband": { bbState = "latest"; basebandTextField.setText("✓ (No file)"); - if (sepState.equals("latest")) + if (sepState.equals("latest") || sepState.equals("none")) selectBuildManifestButton.setEnabled(false); break; - case "Manual Baseband": + } + case "Manual Baseband": { Platform.runLater(() -> { FRUtils.setEnabled(mainMenuView, false, true); if (chooseBbfw()) { @@ -335,29 +353,32 @@ public MainMenu() { } else { bbState = "latest"; basebandComboBox.setSelectedItem("Latest Baseband"); - if (sepState.equals("latest")) + if (sepState.equals("latest") || sepState.equals("none")) selectBuildManifestButton.setEnabled(false); } FRUtils.setEnabled(mainMenuView, true, true); }); break; - case "No Baseband": + } + case "No Baseband": { bbState = "none"; basebandTextField.setText("✓ (No file)"); - if (sepState.equals("latest")) + if (sepState.equals("latest") || sepState.equals("none")) selectBuildManifestButton.setEnabled(false); break; + } } }); sepComboBox.addActionListener(e -> { switch (sepComboBox.getSelectedItem().toString()) { - case "Latest SEP": + case "Latest SEP": { sepState = "latest"; sepTextField.setText("✓ (No file)"); if (bbState.equals("latest") || bbState.equals("none")) selectBuildManifestButton.setEnabled(false); break; - case "Manual SEP": + } + case "Manual SEP": { Platform.runLater(() -> { FRUtils.setEnabled(mainMenuView, false, true); if (chooseSep()) { @@ -372,30 +393,43 @@ public MainMenu() { FRUtils.setEnabled(mainMenuView, true, true); }); break; + } + case "No SEP": { + sepState = "none"; + sepTextField.setText("✓ (No file)"); + if (bbState.equals("latest") || bbState.equals("none")) + selectBuildManifestButton.setEnabled(false); + break; + } } }); stopFutureRestoreUnsafeButton.addActionListener(e -> { Process futureRestoreProcess = FutureRestoreWorker.futureRestoreProcess; - if (futureRestoreProcess != null) { - if (futureRestoreProcess.isAlive()) { - int response = JOptionPane.showConfirmDialog(mainMenuView, "Are you sure you want to stop FutureRestore? This is considered unsafe if the device is currently restoring.", "Stop FutureRestore?", JOptionPane.YES_NO_OPTION); - if (response == JOptionPane.YES_OPTION) { - futureRestoreProcess.destroy(); - messageToLog("FutureRestore process killed."); - } + boolean killed = false; + if (FutureRestoreWorker.futureRestoreProcess != null && FutureRestoreWorker.futureRestoreProcess.isAlive()) { + int response = JOptionPane.showConfirmDialog(mainMenuView, "Are you sure you want to stop FutureRestore? This is considered unsafe if the device is currently restoring.", "Stop FutureRestore?", JOptionPane.YES_NO_OPTION); + if (response == JOptionPane.YES_OPTION) { + futureRestoreProcess.destroy(); + messageToLog("FutureRestore process killed."); + killed = true; } + } else { + killed = true; } - startFutureRestoreButton.setEnabled(true); - stopFutureRestoreUnsafeButton.setText("Stop FutureRestore"); - currentTaskTextField.setText(""); + if (killed) { + SwingUtilities.invokeLater(() -> { + startFutureRestoreButton.setEnabled(true); + stopFutureRestoreUnsafeButton.setText("Stop FutureRestore"); + currentTaskTextField.setText(""); + }); + } }); downloadFutureRestoreButton.addActionListener(event -> { String osName = System.getProperty("os.name").toLowerCase(); String urlString = null; - String downloadName = null; if (osName.contains("mac")) { try { @@ -406,7 +440,6 @@ public MainMenu() { result = getLatestFrBetaDownload("mac"); } urlString = result.get("link"); - downloadName = result.get("name"); } catch (IOException e) { JOptionPane.showMessageDialog(mainMenuView, "Unable to download FutureRestore.", "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); @@ -421,7 +454,6 @@ public MainMenu() { result = getLatestFrBetaDownload("win"); } urlString = result.get("link"); - downloadName = result.get("name"); } catch (IOException e) { JOptionPane.showMessageDialog(mainMenuView, "Unable to download FutureRestore.", "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); @@ -437,7 +469,6 @@ public MainMenu() { result = getLatestFrBetaDownload("ubuntu"); } urlString = result.get("link"); - downloadName = result.get("name"); } catch (IOException e) { JOptionPane.showMessageDialog(mainMenuView, "Unable to download FutureRestore.", "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); @@ -464,7 +495,7 @@ public MainMenu() { }); // Actually download the file - downloadFutureRestore(urlString, downloadName, osName); + downloadFutureRestore(urlString, osName); }); settingsButton.addActionListener(e -> { @@ -610,8 +641,6 @@ static void turnDark(MainMenu mainMenuInstance) { JPanel mainMenuView = mainMenuInstance.mainMenuView; JTextArea logTextArea = mainMenuInstance.logTextArea; JScrollPane logScrollPane = mainMenuInstance.logScrollPane; - JButton startFutureRestoreButton = mainMenuInstance.startFutureRestoreButton; - mainMenuView.setBackground(new Color(40, 40, 40)); logTextArea.setBackground(new Color(20, 20, 20)); @@ -751,7 +780,6 @@ void runCommand(ArrayList allArgs, boolean fullFR) { return; } - /* // Good idea at first but got kinda annoying every time @@ -906,7 +934,7 @@ private Map getLatestFrGithub() throws IOException { return newestRelease; } - void downloadFutureRestore(String urlString, String downloadName, String operatingSystem) { + void downloadFutureRestore(String urlString, String operatingSystem) { //Download asynchronously new Thread(() -> { String homeDirectory = System.getProperty("user.home"); @@ -1209,7 +1237,8 @@ static void alertIfNewerFRGUIAvailable(MainMenu mainMenuInstance, String current System.out.println("Newest FRGUI version: " + newestTag); //If user is not on latest version - if (!newestTag.equals(currentFRGUIVersion)) { + String currentFRGUITag = "v" + currentFRGUIVersion; + if (!newestTag.equals(currentFRGUITag)) { System.out.println("A newer version of FutureRestore GUI is available."); mainMenuInstance.messageToLog("A newer version of FutureRestore GUI is available."); @@ -1322,6 +1351,10 @@ public JButton getNextButtonOptions() { return nextButtonOptions; } + public JTabbedPane getTabbedPane() { + return tabbedPane; + } + /** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< @@ -1566,6 +1599,7 @@ public JButton getNextButtonOptions() { final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); defaultComboBoxModel2.addElement("Latest SEP"); defaultComboBoxModel2.addElement("Manual SEP"); + defaultComboBoxModel2.addElement("No SEP"); sepComboBox.setModel(defaultComboBoxModel2); gbc = new GridBagConstraints(); gbc.gridx = 1; @@ -1726,7 +1760,7 @@ public JButton getNextButtonOptions() { justBootLabel.setEnabled(false); Font justBootLabelFont = this.$$$getFont$$$("Menlo", -1, 10, justBootLabel.getFont()); if (justBootLabelFont != null) justBootLabel.setFont(justBootLabelFont); - justBootLabel.setText("(--just-boot \"-v\")"); + justBootLabel.setText("(--just-boot=\"-v\")"); gbc = new GridBagConstraints(); gbc.gridx = 3; gbc.gridy = 3;