Skip to content

Commit 274403e

Browse files
committed
Allow optionally specifying a generator
1 parent b9c7fd2 commit 274403e

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/main/java/airsquared/blobsaver/app/Controller.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class Controller {
5555

5656
@FXML private ChoiceBox<String> deviceTypeChoiceBox, deviceModelChoiceBox;
5757

58-
@FXML private TextField ecidField, boardConfigField, apnonceField, versionField, identifierField,
58+
@FXML private TextField ecidField, boardConfigField, apnonceField, generatorField, versionField, identifierField,
5959
pathField, ipswField;
6060

6161
@FXML private CheckBox apnonceCheckBox, allSignedVersionsCheckBox, identifierCheckBox, betaCheckBox;
@@ -123,6 +123,7 @@ public void apnonceCheckBoxHandler() {
123123
} else {
124124
apnonceField.setEffect(null);
125125
apnonceField.setText("");
126+
generatorField.setText("");
126127
}
127128
}
128129

@@ -592,6 +593,9 @@ private TSS createTSS(String runningAlertTitle) {
592593
}
593594
if (!apnonceField.isDisabled()) {
594595
builder.setApnonce(apnonceField.getText());
596+
if (!Utils.isEmptyOrNull(generatorField.getText())) {
597+
builder.setGenerator(generatorField.getText());
598+
}
595599
}
596600

597601
TSS tss = builder.build();

src/main/java/airsquared/blobsaver/app/TSS.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,20 @@ public class TSS extends Task<String> {
5353
private final String manualVersion;
5454
private final String manualIpswURL;
5555

56-
private final String apnonce;
56+
private final String apnonce, generator;
5757

5858
/**
5959
* Private constructor; use {@link TSS.Builder} instead
6060
*/
61-
private TSS(String deviceIdentifier, String ecid, String savePath, String boardConfig, String manualVersion, String manualIpswURL, String apnonce) {
61+
private TSS(String deviceIdentifier, String ecid, String savePath, String boardConfig, String manualVersion, String manualIpswURL, String apnonce, String generator) {
6262
this.deviceIdentifier = deviceIdentifier;
6363
this.ecid = ecid;
6464
this.savePath = savePath;
6565
this.boardConfig = boardConfig;
6666
this.manualVersion = manualVersion;
6767
this.manualIpswURL = manualIpswURL;
6868
this.apnonce = apnonce;
69+
this.generator = generator;
6970
}
7071

7172
/**
@@ -79,6 +80,7 @@ protected String call() throws TSSException {
7980
List<Utils.IOSVersion> iosVersions = getIOSVersions();
8081
System.out.println("iosVersions = " + iosVersions);
8182
ArrayList<String> args = constructArgs();
83+
final int urlIndex = args.size() - 1;
8284

8385
StringBuilder sb = new StringBuilder("Successfully saved blobs in\n").append(savePath);
8486
if (manualIpswURL == null) {
@@ -88,7 +90,7 @@ protected String call() throws TSSException {
8890
// can't use forEach() because exception won't be caught
8991
for (Utils.IOSVersion iosVersion : iosVersions) {
9092
try {
91-
args.set(args.size() - 1, extractBuildManifest(iosVersion.ipswURL()).toString());
93+
args.set(urlIndex, extractBuildManifest(iosVersion.ipswURL()).toString());
9294
} catch (IOException e) {
9395
throw new TSSException("Unable to extract BuildManifest.", true, e);
9496
}
@@ -156,26 +158,24 @@ private List<Utils.IOSVersion> getIOSVersions() throws TSSException {
156158
}
157159

158160
private ArrayList<String> constructArgs() {
159-
ArrayList<String> args = new ArrayList<>(15);
161+
ArrayList<String> args = new ArrayList<>(17);
160162
String tsscheckerPath = Utils.getTsschecker().getAbsolutePath();
161163
//noinspection ResultOfMethodCallIgnored
162164
new File(savePath).mkdirs();
163165
Collections.addAll(args, tsscheckerPath, "--nocache", "--save", "--device", deviceIdentifier, "--ecid", ecid, "--save-path", savePath);
164-
if (boardConfig == null) {
165-
Collections.addAll(args, "--boardconfig", Devices.getBoardConfig(deviceIdentifier));
166-
} else {
167-
Collections.addAll(args, "--boardconfig", boardConfig);
168-
}
166+
Collections.addAll(args, "--boardconfig",
167+
Objects.requireNonNullElse(boardConfig, Devices.getBoardConfig(deviceIdentifier)));
169168
if (apnonce != null) {
170169
Collections.addAll(args, "--apnonce", apnonce);
171-
} else {
172-
Collections.addAll(args, "--generator", "0x1111111111111111");
173170
}
174-
Collections.addAll(args, "--build-manifest", "");
171+
Collections.addAll(args, "--generator",
172+
Objects.requireNonNullElse(generator, "0x1111111111111111"));
173+
Collections.addAll(args, "--build-manifest", "will be replaced in loop");
175174

176175
return args;
177176
}
178177

178+
@SuppressWarnings("TextBlockMigration")
179179
private void parseTSSLog(String tsscheckerLog) throws TSSException {
180180
if (containsIgnoreCase(tsscheckerLog, "Saved shsh blobs")) {
181181
return; // success
@@ -215,7 +215,7 @@ && containsIgnoreCase(tsscheckerLog, "checking tss status failed")) {
215215

216216
@SuppressWarnings("UnusedReturnValue")
217217
public static class Builder {
218-
private String device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce;
218+
private String device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
219219

220220
public Builder setDevice(String device) {
221221
this.device = device;
@@ -254,11 +254,16 @@ public Builder setApnonce(String apnonce) {
254254
return this;
255255
}
256256

257+
public Builder setGenerator(String generator) {
258+
this.generator = generator;
259+
return this;
260+
}
261+
257262
public TSS build() {
258263
return new TSS(Objects.requireNonNull(device, "Device"),
259264
Objects.requireNonNull(ecid, "ECID"),
260265
Objects.requireNonNull(savePath, "Save Path"),
261-
boardConfig, manualVersion, manualIpswURL, apnonce);
266+
boardConfig, manualVersion, manualIpswURL, apnonce, generator);
262267
}
263268
}
264269

src/main/resources/airsquared/blobsaver/app/blobsaver.fxml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
</VBox.margin>
191191
</TextField>
192192
<CheckBox fx:id="apnonceCheckBox" mnemonicParsing="false" onAction="#apnonceCheckBoxHandler"
193-
text="Specify Apnonce:">
193+
text="Specify ApNonce:">
194194
<VBox.margin>
195195
<Insets bottom="5.0" left="10.0" top="5.0"/>
196196
</VBox.margin>
@@ -210,6 +210,11 @@
210210
<Insets bottom="5.0" left="10.0" right="10.0"/>
211211
</VBox.margin>
212212
</AnchorPane>
213+
<TextField fx:id="generatorField" disable="${!apnonceCheckBox.selected}" promptText="Generator (Optional)">
214+
<VBox.margin>
215+
<Insets top="5.0" bottom="5.0" left="10.0" right="10.0"/>
216+
</VBox.margin>
217+
</TextField>
213218
<Label text="Location">
214219
<VBox.margin>
215220
<Insets bottom="5.0" left="10.0" top="5.0"/>

0 commit comments

Comments
 (0)