Skip to content

Commit 8af3d11

Browse files
committed
use correct target SDK for wear
1 parent c9163cb commit 8af3d11

File tree

4 files changed

+38
-34
lines changed

4 files changed

+38
-34
lines changed

mode/mode.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name = Android Mode for Processing 4
22
authorList = [The Processing Foundation](https://processingfoundation.org/)
3-
url = http://android.processing.org
3+
url = https://android.processing.org
44
sentence = This mode lets you use Processing to create Android apps
55
paragraph =
66
imports=processing.mode.java.JavaMode
7-
version = 409
8-
prettyVersion = 4.5.0b5
7+
version = 410
8+
prettyVersion = 4.5.0
99
minRevision = 1283
1010
maxRevision = 0
1111

mode/src/processing/mode/android/AVD.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public class AVD {
3939

4040
final static public String DEFAULT_ABI = "x86";
4141

42-
public static final String TARGET_SDK_ARM = "24";
42+
public static final String TARGET_SDK_ARM = "24";
43+
public static final String TARGET_SDK_WEAR = "30";
4344

4445
public final static String DEFAULT_PHONE_PORT = "5566";
4546
public final static String DEFAULT_WEAR_PORT = "5576";
@@ -95,23 +96,24 @@ static public String getName(boolean wear) {
9596
return AVD.phoneAVD.name;
9697
}
9798
}
98-
99-
100-
static public String getPreferredPlatform(boolean wear, String abi) {
101-
if (wear) {
102-
return AndroidBuild.TARGET_PLATFORM;
103-
} else if (abi.equals("arm")) {
99+
100+
static public String getTargetSDK(boolean wear, String abi) {
101+
if (abi.equals("arm")) {
104102
// The ARM images using Google APIs are too slow, so use the
105103
// older Android (AOSP) images.
106104
// TODO check if we can move to the regular ARM images...
107-
return "android-" + TARGET_SDK_ARM;
105+
return TARGET_SDK_ARM;
108106
} else if (abi.equals("arm64-v8a")) {
109-
return AndroidBuild.TARGET_PLATFORM;
110-
} else {
111-
return AndroidBuild.TARGET_PLATFORM;
107+
return wear ? TARGET_SDK_WEAR : AndroidBuild.TARGET_PLATFORM;
108+
} else { // x86
109+
return wear ? TARGET_SDK_WEAR : AndroidBuild.TARGET_PLATFORM;
112110
}
113111
}
114112

113+
static public String getPreferredPlatform(boolean wear, String abi) {
114+
return "android-" + getTargetSDK(wear, abi);
115+
}
116+
115117
static public String getPreferredPort(boolean wear) {
116118
String port = "";
117119
if (wear) {
@@ -322,7 +324,6 @@ protected void getImages(final ArrayList<String> images, final AndroidSDK sdk,
322324
line.contains(";" + imagePlatform) &&
323325
line.contains(";" + imageTag) &&
324326
line.contains(";" + imageAbi)) {
325-
// System.out.println(" added image!");
326327
images.add(line);
327328
}
328329
}

mode/src/processing/mode/android/AndroidSDK.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ class AndroidSDK {
7171
private final File sdkManager;
7272

7373
private File emulator;
74-
75-
private static final String SDK_DOWNLOAD_URL =
76-
"https://developer.android.com/studio/index.html#android-studio-downloads";
7774

7875
private static final String PROCESSING_FOR_ANDROID_URL =
7976
"https://android.processing.org/";
8077

8178
private static final String WHATS_NEW_URL =
82-
"https://developer.android.com/studio/index.html";
83-
79+
"https://android.processing.org/whatsnew";
80+
81+
private static final String SDK_DOWNLOAD_URL =
82+
"https://developer.android.com/studio/index.html#android-studio-downloads";
83+
8484
private static final String DRIVER_INSTALL_URL =
8585
"https://developer.android.com/studio/run/oem-usb.html#InstallingDriver";
8686

mode/src/processing/mode/android/SysImageDownloader.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,21 @@ protected Object doInBackground() throws Exception {
139139
firePropertyChange(AndroidMode.getTextString("download_property.change_event_total"), 0, downloadUrls.totalSize);
140140
totalSize = downloadUrls.totalSize;
141141

142+
String level = AVD.getTargetSDK(wear, abi);
143+
142144
if (wear) {
143145
// wear system images
144146
File downloadedSysImgWear = new File(tempFolder, downloadUrls.sysImgWearFilename);
145-
File tmp = new File(sysImgFolder, "android-" + AndroidBuild.TARGET_SDK);
147+
File tmp = new File(sysImgFolder, "android-" + level);
146148
if (!tmp.exists()) tmp.mkdir();
147149
File sysImgWearFinalFolder = new File(tmp, downloadUrls.sysImgWearTag);
148150
if (!sysImgWearFinalFolder.exists()) sysImgWearFinalFolder.mkdir();
149151
downloadAndUnpack(downloadUrls.sysImgWearUrl, downloadedSysImgWear, sysImgWearFinalFolder, false);
150152
fixSourceProperties(sysImgWearFinalFolder);
151153
} else {
152154
// mobile system images
153-
File downloadedSysImg = new File(tempFolder, downloadUrls.sysImgFilename);
154-
155-
String level = abi.equals("arm") ? AVD.TARGET_SDK_ARM : AndroidBuild.TARGET_SDK;
156-
File tmp = new File(sysImgFolder, "android-" + level);
157-
155+
File downloadedSysImg = new File(tempFolder, downloadUrls.sysImgFilename);
156+
File tmp = new File(sysImgFolder, "android-" + level);
158157
if (!tmp.exists()) tmp.mkdir();
159158
File sysImgFinalFolder = new File(tmp, downloadUrls.sysImgTag);
160159
if (!sysImgFinalFolder.exists()) sysImgFinalFolder.mkdir();
@@ -253,22 +252,23 @@ private void getDownloadUrls(UrlHolder urlHolder,
253252
XPathExpression expr;
254253
NodeList remotePackages;
255254

255+
String targetSDK = AVD.getTargetSDK(wear, abi);
256256
if (abi.equals("arm")) {
257-
expr = xpath.compile("//remotePackage[contains(@path, '" + AVD.TARGET_SDK_ARM + "')" +
258-
"and contains(@path, \"armeabi-v7a\")]");
259-
} else if (abi.equals("arm64-v8a")) {
260-
expr = xpath.compile("//remotePackage[contains(@path, '" + AndroidBuild.TARGET_SDK + "')" +
261-
"and contains(@path, \"arm64-v8a\")]");
257+
expr = xpath.compile("//remotePackage[contains(@path, '" + targetSDK + "')" +
258+
"and contains(@path, \"armeabi-v7a\")]");
259+
} if (abi.equals("arm64-v8a")) {
260+
expr = xpath.compile("//remotePackage[contains(@path, '" + targetSDK + "')" +
261+
"and contains(@path, \"arm64-v8a\")]");
262262
} else {
263-
expr = xpath.compile("//remotePackage[contains(@path, '" + AndroidBuild.TARGET_SDK + "')" +
264-
"and contains(@path, \"x86\")]");
263+
expr = xpath.compile("//remotePackage[contains(@path, '" + targetSDK + "')" +
264+
"and contains(@path, \"x86\")]");
265265
}
266266

267267
if (wear) {
268268
Document docSysImgWear = db.parse(new URL(repositoryUrl).openStream());
269+
269270
remotePackages = (NodeList) expr.evaluate(docSysImgWear, XPathConstants.NODESET);
270271
NodeList childNodes = remotePackages.item(0).getChildNodes();
271-
272272
NodeList typeDetails = ((Element) childNodes).getElementsByTagName("type-details");
273273
NodeList tag = ((Element) typeDetails.item(0)).getElementsByTagName("tag");
274274
NodeList id = ((Element) tag.item(0)).getElementsByTagName("id");
@@ -481,6 +481,9 @@ public void processLine(String line) {
481481
process.waitFor();
482482
} catch (final InterruptedException ie) {
483483
ie.printStackTrace();
484+
System.out.println("Processing was not able to install HAXM automatically, " +
485+
"but the installation package was downloaded into android/sdk/extras/intel/HAXM. " +
486+
"You can try install to install it manually from there.");
484487
} finally {
485488
process.destroy();
486489
}

0 commit comments

Comments
 (0)