Skip to content

Commit 2ef2393

Browse files
committed
emulator download can be disabled
1 parent 0c980d0 commit 2ef2393

File tree

1 file changed

+47
-38
lines changed

1 file changed

+47
-38
lines changed

mode/src/processing/mode/android/SDKDownloader.java

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public class SDKDownloader extends JDialog implements PropertyChangeListener {
6565
private static final String HAXM_URL = "https://dl.google.com/android/repository/extras/intel/";
6666
private static final String REPOSITORY_LIST = "repository2-1.xml";
6767
private static final String ADDON_LIST = "addon2-1.xml";
68+
69+
private static final boolean DOWNLOAD_EMU = false;
6870

6971
private JProgressBar progressBar;
7072
private JLabel downloadedTextArea;
@@ -105,14 +107,17 @@ protected Object doInBackground() throws Exception {
105107
if (!platformsFolder.exists()) platformsFolder.mkdir();
106108
File buildToolsFolder = new File(sdkFolder, "build-tools");
107109
if (!buildToolsFolder.exists()) buildToolsFolder.mkdir();
108-
File emulatorFolder = new File(sdkFolder, "emulator");
109-
if (!emulatorFolder.exists()) emulatorFolder.mkdir();
110110
File extrasFolder = new File(sdkFolder, "extras");
111111
if (!extrasFolder.exists()) extrasFolder.mkdir();
112112
File googleRepoFolder = new File(extrasFolder, "google");
113113
if (!googleRepoFolder.exists()) googleRepoFolder.mkdir();
114114
File haxmFolder = new File(extrasFolder, "intel/HAXM");
115115
if (!haxmFolder.exists()) haxmFolder.mkdirs();
116+
117+
if (DOWNLOAD_EMU) {
118+
File emulatorFolder = new File(sdkFolder, "emulator");
119+
if (!emulatorFolder.exists()) emulatorFolder.mkdir();
120+
}
116121

117122
// creating temp folder for downloaded zip packages
118123
File tempFolder = new File(androidFolder, "temp");
@@ -143,10 +148,6 @@ protected Object doInBackground() throws Exception {
143148
// platform
144149
File downloadedPlatform = new File(tempFolder, downloadUrls.platformFilename);
145150
downloadAndUnpack(downloadUrls.platformUrl, downloadedPlatform, platformsFolder, false);
146-
147-
// emulator, unpacks directly to sdk folder
148-
File downloadedEmulator = new File(tempFolder, downloadUrls.emulatorFilename);
149-
downloadAndUnpack(downloadUrls.emulatorUrl, downloadedEmulator, sdkFolder, true);
150151

151152
// usb driver
152153
if (Platform.isWindows()) {
@@ -160,6 +161,12 @@ protected Object doInBackground() throws Exception {
160161
downloadAndUnpack(downloadUrls.haxmUrl, downloadedFolder, haxmFolder, true);
161162
}
162163

164+
if (DOWNLOAD_EMU) {
165+
// emulator, unpacks directly to sdk folder
166+
File downloadedEmulator = new File(tempFolder, downloadUrls.emulatorFilename);
167+
downloadAndUnpack(downloadUrls.emulatorUrl, downloadedEmulator, sdkFolder, true);
168+
}
169+
163170
if (Platform.isLinux() || Platform.isMacOS()) {
164171
Runtime.getRuntime().exec("chmod -R 755 " + sdkFolder.getAbsolutePath());
165172
}
@@ -367,41 +374,43 @@ private void getMainDownloadUrls(SDKUrlHolder urlHolder,
367374
if (!found) {
368375
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_tools"));
369376
}
370-
371-
// -----------------------------------------------------------------------
372-
// Emulator
373-
expr = xpath.compile("//remotePackage[@path=\"emulator\"]");
374-
remotePackages = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
375-
found = false;
376-
if (remotePackages != null) {
377-
for (int i = 0; i < remotePackages.getLength(); ++i) {
378-
NodeList childNodes = remotePackages.item(i).getChildNodes();
379-
380-
NodeList channel = ((Element) childNodes).getElementsByTagName("channelRef");
381-
if(!channel.item(0).getAttributes().item(0).getNodeValue().equals("channel-0"))
382-
continue; //Stable channel only, skip others
383-
384-
NodeList archives = ((Element) childNodes).getElementsByTagName("archive");
385-
386-
for (int j = 0; j < archives.getLength(); ++j) {
387-
NodeList archive = archives.item(j).getChildNodes();
388-
NodeList complete = ((Element) archive).getElementsByTagName("complete");
389-
390-
NodeList os = ((Element) archive).getElementsByTagName("host-os");
391-
NodeList url = ((Element) complete.item(0)).getElementsByTagName("url");
392-
NodeList size = ((Element) complete.item(0)).getElementsByTagName("size");
377+
378+
if (DOWNLOAD_EMU) {
379+
// -----------------------------------------------------------------------
380+
// Emulator
381+
expr = xpath.compile("//remotePackage[@path=\"emulator\"]");
382+
remotePackages = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
383+
found = false;
384+
if (remotePackages != null) {
385+
for (int i = 0; i < remotePackages.getLength(); ++i) {
386+
NodeList childNodes = remotePackages.item(i).getChildNodes();
393387

394-
if (os.item(0).getTextContent().equals(requiredHostOs)) {
395-
urlHolder.emulatorFilename = url.item(0).getTextContent();
396-
urlHolder.emulatorUrl = REPOSITORY_URL + urlHolder.emulatorFilename;
397-
urlHolder.totalSize += Integer.parseInt(size.item(0).getTextContent());
398-
found = true;
399-
break;
388+
NodeList channel = ((Element) childNodes).getElementsByTagName("channelRef");
389+
if(!channel.item(0).getAttributes().item(0).getNodeValue().equals("channel-0"))
390+
continue; //Stable channel only, skip others
391+
392+
NodeList archives = ((Element) childNodes).getElementsByTagName("archive");
393+
394+
for (int j = 0; j < archives.getLength(); ++j) {
395+
NodeList archive = archives.item(j).getChildNodes();
396+
NodeList complete = ((Element) archive).getElementsByTagName("complete");
397+
398+
NodeList os = ((Element) archive).getElementsByTagName("host-os");
399+
NodeList url = ((Element) complete.item(0)).getElementsByTagName("url");
400+
NodeList size = ((Element) complete.item(0)).getElementsByTagName("size");
401+
402+
if (os.item(0).getTextContent().equals(requiredHostOs)) {
403+
urlHolder.emulatorFilename = url.item(0).getTextContent();
404+
urlHolder.emulatorUrl = REPOSITORY_URL + urlHolder.emulatorFilename;
405+
urlHolder.totalSize += Integer.parseInt(size.item(0).getTextContent());
406+
found = true;
407+
break;
408+
}
400409
}
410+
if (found) break;
401411
}
402-
if (found) break;
403-
}
404-
}
412+
}
413+
}
405414
if (!found) {
406415
throw new IOException(AndroidMode.getTextString("sdk_downloader.error_cannot_find_emulator"));
407416
}

0 commit comments

Comments
 (0)