52
52
public class SDKDownloader extends JDialog implements PropertyChangeListener {
53
53
// Version 25.3.1 of the SDK tools break the mode, since the android tool
54
54
// no longer works:
55
+ private static final int SDK_TOOLS_MAX_MAJOR = 25 ;
56
+ private static final int SDK_TOOLS_MAX_MINOR = 2 ;
57
+
58
+ private static final int PLATFORM_TOOLS_MAX_MAJOR = 25 ;
59
+ private static final int PLATFORM_TOOLS_MAX_MINOR = 0 ;
60
+
61
+ private static final int BUILD_TOOLS_MAX_MAJOR = 25 ;
62
+ private static final int BUILD_TOOLS_MAX_MINOR = 0 ;
63
+
55
64
// https://code.google.com/p/android/issues/detail?id=235455
56
65
// as well as removing the ant scripts.
57
66
// https://code.google.com/p/android/issues/detail?id=235410
@@ -250,7 +259,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
250
259
251
260
// -----------------------------------------------------------------------
252
261
// platform-tools
253
- Node platformToolsItem = getLatestToolItem (doc .getElementsByTagName ("sdk:platform-tool" ));
262
+ Node platformToolsItem = getLatestToolItem (doc .getElementsByTagName ("sdk:platform-tool" ), PLATFORM_TOOLS_MAX_MAJOR , PLATFORM_TOOLS_MAX_MINOR );
254
263
if (platformToolsItem != null ) {
255
264
archiveListItem = ((Element ) platformToolsItem ).getElementsByTagName ("sdk:archives" ).item (0 );
256
265
archiveList = ((Element ) archiveListItem ).getElementsByTagName ("sdk:archive" );
@@ -268,12 +277,12 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
268
277
269
278
// -----------------------------------------------------------------------
270
279
// build-tools
271
- Node buildToolsItem = getLatestToolItem (doc .getElementsByTagName ("sdk:build-tool" ));
280
+ Node buildToolsItem = getLatestToolItem (doc .getElementsByTagName ("sdk:build-tool" ), BUILD_TOOLS_MAX_MAJOR , BUILD_TOOLS_MAX_MINOR );
272
281
if (buildToolsItem != null ) {
273
282
Node revisionListItem = ((Element ) buildToolsItem ).getElementsByTagName ("sdk:revision" ).item (0 );
274
283
String major = ((Element ) revisionListItem ).getElementsByTagName ("sdk:major" ).item (0 ).getTextContent ();
275
284
String minor = ((Element ) revisionListItem ).getElementsByTagName ("sdk:minor" ).item (0 ).getTextContent ();
276
- String micro = ((Element ) revisionListItem ).getElementsByTagName ("sdk:micro" ).item (0 ).getTextContent ();
285
+ String micro = ((Element ) revisionListItem ).getElementsByTagName ("sdk:micro" ).item (0 ).getTextContent ();
277
286
urlHolder .buildToolsVersion = major + "." + minor + "." + micro ;
278
287
archiveListItem = ((Element ) buildToolsItem ).getElementsByTagName ("sdk:archives" ).item (0 );
279
288
archiveList = ((Element ) archiveListItem ).getElementsByTagName ("sdk:archive" );
@@ -291,7 +300,7 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
291
300
292
301
// -----------------------------------------------------------------------
293
302
// tools
294
- Node toolsItem = getLatestToolItem (doc .getElementsByTagName ("sdk:tool" )) ;
303
+ Node toolsItem = getLatestToolItem (doc .getElementsByTagName ("sdk:tool" ), SDK_TOOLS_MAX_MAJOR , SDK_TOOLS_MAX_MINOR ); ;
295
304
if (toolsItem != null ) {
296
305
archiveListItem = ((Element ) toolsItem ).getElementsByTagName ("sdk:archives" ).item (0 );
297
306
archiveList = ((Element ) archiveListItem ).getElementsByTagName ("sdk:archive" );
@@ -384,7 +393,7 @@ private Node getLatestPlatform(NodeList platformList) {
384
393
return latest ;
385
394
}
386
395
387
- private Node getLatestToolItem (NodeList list ) {
396
+ private Node getLatestToolItem (NodeList list , int max_major , int max_minor ) {
388
397
Node latest = null ;
389
398
int maxMajor = -1 ;
390
399
int maxMinor = -1 ;
@@ -397,7 +406,8 @@ private Node getLatestToolItem(NodeList list) {
397
406
NodeList micro = ((Element )revision ).getElementsByTagName ("sdk:micro" );
398
407
int intMajor = PApplet .parseInt (major .item (0 ).getTextContent ());
399
408
int intMinor = PApplet .parseInt (minor .item (0 ).getTextContent ());
400
- int intMicro = PApplet .parseInt (micro .item (0 ).getTextContent ());
409
+ int intMicro = PApplet .parseInt (micro .item (0 ).getTextContent ());
410
+ if (max_major < intMajor || (max_major == intMajor && max_minor < intMinor )) continue ;
401
411
if (maxMajor <= intMajor && maxMinor <= intMinor && maxMicro <= intMicro ) {
402
412
latest = item ;
403
413
maxMajor = intMajor ;
0 commit comments