From 114a15b57af5131d41c6b1214d88f2f4d9c43985 Mon Sep 17 00:00:00 2001 From: CoocooFroggy Date: Fri, 23 Jul 2021 22:28:25 -0400 Subject: [PATCH 1/5] - Add v prefix to tags for checking FRGUI version --- src/main/java/FRUtils.java | 7 +------ src/main/java/Main.java | 10 +++++----- src/main/java/MainMenu.java | 14 ++++---------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/main/java/FRUtils.java b/src/main/java/FRUtils.java index 59a7d05..a73e9a6 100644 --- a/src/main/java/FRUtils.java +++ b/src/main/java/FRUtils.java @@ -302,13 +302,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/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.java b/src/main/java/MainMenu.java index b7e84ce..48ffb13 100644 --- a/src/main/java/MainMenu.java +++ b/src/main/java/MainMenu.java @@ -395,7 +395,6 @@ public MainMenu() { downloadFutureRestoreButton.addActionListener(event -> { String osName = System.getProperty("os.name").toLowerCase(); String urlString = null; - String downloadName = null; if (osName.contains("mac")) { try { @@ -406,7 +405,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 +419,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 +434,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 +460,7 @@ public MainMenu() { }); // Actually download the file - downloadFutureRestore(urlString, downloadName, osName); + downloadFutureRestore(urlString, osName); }); settingsButton.addActionListener(e -> { @@ -610,8 +606,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 +745,6 @@ void runCommand(ArrayList allArgs, boolean fullFR) { return; } - /* // Good idea at first but got kinda annoying every time @@ -906,7 +899,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 +1202,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."); From 5fd06c08edbde2c5630977e819f1511aa9e25fe5 Mon Sep 17 00:00:00 2001 From: CoocooFroggy Date: Sun, 25 Jul 2021 10:46:42 -0400 Subject: [PATCH 2/5] - No SEP --- src/main/java/MainMenu.form | 1 + src/main/java/MainMenu.java | 38 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/MainMenu.form b/src/main/java/MainMenu.form index 655d2fe..0bf061c 100644 --- a/src/main/java/MainMenu.form +++ b/src/main/java/MainMenu.form @@ -251,6 +251,7 @@ + diff --git a/src/main/java/MainMenu.java b/src/main/java/MainMenu.java index 48ffb13..4a67b90 100644 --- a/src/main/java/MainMenu.java +++ b/src/main/java/MainMenu.java @@ -277,15 +277,20 @@ public MainMenu() { } 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 +325,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 +341,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,6 +381,14 @@ 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 -> { @@ -1560,6 +1577,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; From f067d3917a303d52c5fabeff9d63791bf00d3350 Mon Sep 17 00:00:00 2001 From: CoocooFroggy Date: Wed, 28 Jul 2021 21:51:58 -0400 Subject: [PATCH 3/5] - Fix just-boot arg --- src/main/java/MainMenu.form | 2 +- src/main/java/MainMenu.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/MainMenu.form b/src/main/java/MainMenu.form index 0bf061c..4d77458 100644 --- a/src/main/java/MainMenu.form +++ b/src/main/java/MainMenu.form @@ -416,7 +416,7 @@ - + diff --git a/src/main/java/MainMenu.java b/src/main/java/MainMenu.java index 4a67b90..205d4e3 100644 --- a/src/main/java/MainMenu.java +++ b/src/main/java/MainMenu.java @@ -272,8 +272,7 @@ public MainMenu() { if (optionNoIbssState) allArgs.add("--no-ibss"); if (optionJustBootState) { - allArgs.add("--just-boot"); - allArgs.add("'-v'"); + allArgs.add("--just-boot=\"-v\""); } switch (sepState) { @@ -1738,7 +1737,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; From 6879111befd3fbf598c70cac6bf4414877c46241 Mon Sep 17 00:00:00 2001 From: CoocooFroggy Date: Wed, 28 Jul 2021 22:10:59 -0400 Subject: [PATCH 4/5] - Fix pwndfu sub-checkboxes not becoming unchecked - Fix stop FutureRestore cancel on the popup enabling the button to start it again - Add more checks to prevent two FutureRestore processes from running at the same time - Code cleanup - Fix GUI acting as if FutureRestore was killed when Stop button pressed, even if stop was cancelled --- src/main/java/FRUtils.java | 2 +- src/main/java/FutureRestoreWorker.java | 2 +- src/main/java/MainMenu.java | 43 +++++++++++++++++++------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/main/java/FRUtils.java b/src/main/java/FRUtils.java index a73e9a6..eb272a4 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; } 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/MainMenu.java b/src/main/java/MainMenu.java index 205d4e3..6640040 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; @@ -393,19 +406,25 @@ public MainMenu() { 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 -> { From 58429a40d6791e2768526ccc622f85eb1d45cc5f Mon Sep 17 00:00:00 2001 From: CoocooFroggy Date: Wed, 28 Jul 2021 22:56:18 -0400 Subject: [PATCH 5/5] Better update experience --- src/main/java/FRUtils.java | 5 +++++ src/main/java/MainMenu.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/FRUtils.java b/src/main/java/FRUtils.java index eb272a4..ce25903 100644 --- a/src/main/java/FRUtils.java +++ b/src/main/java/FRUtils.java @@ -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); diff --git a/src/main/java/MainMenu.java b/src/main/java/MainMenu.java index 6640040..bf918df 100644 --- a/src/main/java/MainMenu.java +++ b/src/main/java/MainMenu.java @@ -1351,6 +1351,10 @@ public JButton getNextButtonOptions() { return nextButtonOptions; } + public JTabbedPane getTabbedPane() { + return tabbedPane; + } + /** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<<