Skip to content

Commit 2b1314f

Browse files
committed
fixed folder name in sdk download, delete tmp files
1 parent f1a9ae0 commit 2b1314f

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

core/src/processing/core/PApplet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import android.view.SurfaceView;
4949
import android.view.View;
5050
import android.view.ViewGroup;
51-
import android.view.ViewTreeObserver;
5251
import android.view.inputmethod.InputMethodManager;
5352
import processing.a2d.PGraphicsAndroid2D;
5453
import processing.android.AppComponent;

src/processing/mode/android/SDKDownloader.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class SDKDownloader extends JDialog implements PropertyChangeListener {
7070
private int totalSize = 0;
7171

7272
class SDKUrlHolder {
73-
public String platformVersion;
73+
public String platformVersion, buildToolsVersion;
7474
public String platformToolsUrl, buildToolsUrl, platformUrl, toolsUrl;
7575
public String platformToolsFilename, buildToolsFilename, platformFilename, toolsFilename;
7676
public int totalSize = 0;
@@ -83,7 +83,6 @@ class SDKDownloadTask extends SwingWorker<Object, Object> {
8383

8484
@Override
8585
protected Object doInBackground() throws Exception {
86-
8786
File modeFolder = mode.getFolder();
8887

8988
// creating sdk folders
@@ -132,18 +131,16 @@ protected Object doInBackground() throws Exception {
132131
Runtime.getRuntime().exec("chmod -R 755 " + sdkFolder.getAbsolutePath());
133132
}
134133

135-
tempFolder.delete();
136-
137-
// Normalize platform folder to android-<API LEVEL>
138-
File expectedPath = new File(platformsFolder, "android-" + AndroidBuild.target_sdk);
139-
File actualPath = new File(platformsFolder, "android-" + downloadUrls.platformVersion);
140-
if (!expectedPath.exists()) {
141-
if (actualPath.exists()) {
142-
actualPath.renameTo(expectedPath);
143-
} else {
144-
throw new IOException("Error unpacking platform to " + actualPath.getAbsolutePath());
145-
}
134+
for (File f: tempFolder.listFiles()) {
135+
f.delete();
136+
PApplet.println("Deleting", f.getAbsolutePath());
146137
}
138+
tempFolder.delete();
139+
140+
// Normalize built-tools and platform folders to android-<API LEVEL>
141+
String actualName = "android-" + downloadUrls.platformVersion;
142+
renameFolder(platformsFolder, "android-" + AndroidBuild.target_sdk, actualName);
143+
renameFolder(buildToolsFolder, downloadUrls.buildToolsVersion, actualName);
147144

148145
// Done, let's set the environment and load the new SDK!
149146
Platform.setenv("ANDROID_SDK", sdkFolder.getAbsolutePath());
@@ -254,6 +251,11 @@ private SDKUrlHolder getDownloadUrls(String repositoryUrl, String requiredHostOs
254251
// build-tools
255252
Node buildToolsItem = getLatestToolItem(doc.getElementsByTagName("sdk:build-tool"));
256253
if (buildToolsItem != null) {
254+
Node revisionListItem = ((Element) buildToolsItem).getElementsByTagName("sdk:revision").item(0);
255+
String major = ((Element) revisionListItem).getElementsByTagName("sdk:major").item(0).getTextContent();
256+
String minor = ((Element) revisionListItem).getElementsByTagName("sdk:minor").item(0).getTextContent();
257+
String micro = ((Element) revisionListItem).getElementsByTagName("sdk:micro").item(0).getTextContent();
258+
urlHolder.buildToolsVersion = major + "." + minor + "." + micro;
257259
archiveListItem = ((Element) buildToolsItem).getElementsByTagName("sdk:archives").item(0);
258260
archiveList = ((Element) archiveListItem).getElementsByTagName("sdk:archive");
259261
for (int i = 0; i < archiveList.getLength(); i++) {
@@ -339,6 +341,20 @@ private Node getLatestToolItem(NodeList list) {
339341
return latest;
340342
}
341343

344+
private void renameFolder(File baseFolder, String expected, String actual)
345+
throws IOException {
346+
File expectedPath = new File(baseFolder, expected);
347+
File actualPath = new File(baseFolder, actual);
348+
if (!expectedPath.exists()) {
349+
if (actualPath.exists()) {
350+
actualPath.renameTo(expectedPath);
351+
} else {
352+
throw new IOException("Error unpacking platform to " +
353+
actualPath.getAbsolutePath());
354+
}
355+
}
356+
}
357+
342358
@Override
343359
public void propertyChange(PropertyChangeEvent evt) {
344360
if (evt.getPropertyName().equals(PROPERTY_CHANGE_EVENT_TOTAL)) {

0 commit comments

Comments
 (0)