@@ -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
0 commit comments