Skip to content

Commit

Permalink
FutureRestore GUI — v1.91
Browse files Browse the repository at this point in the history
### What's new:
- No SEP option for devices without SEP

### Bug fixes:
- GitHub version can be prefixed with v for consistency
- `--just-boot="v"` arg actually works now
- Fixed GUI not representing what was actually selected for pwndfu sub arguments
- Fixed GUI acting as if FutureRestore was killed when the "Stop FutureRestore" button was pressed, even if the stop was cancelled

### Miscellaneous improvements:
- Added more checks to prevent two FutureRestore processes from running at the same time
- Log a bit more when updating FutureRestore GUI
- Switch to "Controls" tab automatically when updating FutureRestore GUI
  • Loading branch information
CoocooFroggy authored Jul 29, 2021
2 parents e19295e + 58429a4 commit 19c7c80
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 49 deletions.
14 changes: 7 additions & 7 deletions src/main/java/FRUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ 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;
}

// 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")) {
Expand All @@ -84,13 +87,15 @@ public static boolean updateFRGUI(MainMenu mainMenuInstance) throws IOException,
}
return false;
} else {
mainMenuInstance.messageToLog("Downloading FutureRestore GUI...");
File downloadedFrgui = downloadFRGUI(mainMenuInstance, frguiDownloadIdentifier);

if (downloadedFrgui == null) {
// We already notify the user of error in downloadFRGUI()
return false;
}

mainMenuInstance.messageToLog("Installing FutureRestore GUI...");
if (installFrgui(downloadedFrgui, frguiDownloadIdentifier, mainMenuInstance)) {
System.out.println("All done updating FRGUI. Closing now...");
System.exit(0);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/FutureRestoreWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> 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(() -> {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -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?"
*/
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/MainMenu.form
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<model>
<item value="Latest SEP"/>
<item value="Manual SEP"/>
<item value="No SEP"/>
</model>
</properties>
</component>
Expand Down Expand Up @@ -415,7 +416,7 @@
<properties>
<enabled value="false"/>
<font name="Menlo" size="10"/>
<text value="(--just-boot &quot;-v&quot;)"/>
<text value="(--just-boot=&quot;-v&quot;)"/>
</properties>
</component>
<component id="816a9" class="javax.swing.JLabel">
Expand Down
104 changes: 69 additions & 35 deletions src/main/java/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand All @@ -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()) {
Expand All @@ -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 {
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -464,7 +495,7 @@ public MainMenu() {
});

// Actually download the file
downloadFutureRestore(urlString, downloadName, osName);
downloadFutureRestore(urlString, osName);
});

settingsButton.addActionListener(e -> {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -751,7 +780,6 @@ void runCommand(ArrayList<String> allArgs, boolean fullFR) {
return;
}


/*
// Good idea at first but got kinda annoying every time
Expand Down Expand Up @@ -906,7 +934,7 @@ private Map<String, Object> 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");
Expand Down Expand Up @@ -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.");

Expand Down Expand Up @@ -1322,6 +1351,10 @@ public JButton getNextButtonOptions() {
return nextButtonOptions;
}

public JTabbedPane getTabbedPane() {
return tabbedPane;
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 19c7c80

Please sign in to comment.