@@ -54,7 +54,7 @@ public class AVD {
54
54
"This could mean that the Android tools need to be updated,<br>" +
55
55
"or that the Processing AVD should be deleted (it will<br>" +
56
56
"automatically re-created the next time you run Processing).<br><br>" +
57
- "You can use the avdmanager command line tool to create AVDs manually and list<br> " +
57
+ "You can use the avdmanager command line tool to create AVDs manually and list " +
58
58
"the current AVDs, check <a href=\" " + COMMAND_LINE_TUT_URL + "\" >this online tutorial</a> for more info." ;
59
59
60
60
private static final String GETTING_START_TUT_URL =
@@ -67,26 +67,27 @@ public class AVD {
67
67
"found in <a href=\" " + GETTING_START_TUT_URL + "\" >this online tutorial</a>." ;
68
68
69
69
static final String DEFAULT_SDCARD_SIZE = "64M" ;
70
- static final String DEVICE_DEFINITION = "Nexus 5" ;
71
- static final String DEVICE_SKIN = "1080x1920" ;
70
+
71
+ static final String DEVICE_DEFINITION = "Nexus One" ;
72
+ static final String DEVICE_SKIN = "480x800" ;
72
73
73
74
static final String DEVICE_WEAR_DEFINITION = "wear_square_280_280dpi" ;
74
75
static final String DEVICE_WEAR_SKIN = "280x280" ;
75
76
76
77
/** Name of this avd. */
77
78
protected String name ;
78
79
79
- /** "system-images;android-25;google_apis;x86" */
80
- protected ArrayList <String > watchImages ;
81
- protected ArrayList <String > phoneImages ;
82
-
83
80
protected String device ;
84
81
protected String skin ;
85
82
86
83
static ArrayList <String > avdList ;
87
84
static ArrayList <String > badList ;
88
85
// static ArrayList<String> skinList;
89
-
86
+
87
+ /** "system-images;android-25;google_apis;x86" */
88
+ static ArrayList <String > wearImages ;
89
+ static ArrayList <String > phoneImages ;
90
+
90
91
private static Process process ;
91
92
92
93
/** Default virtual device used by Processing. */
@@ -104,11 +105,6 @@ public AVD(final String name, final String device, final String skin) {
104
105
this .name = name ;
105
106
this .device = device ;
106
107
this .skin = skin ;
107
-
108
- if (name .contains ("phone" ))
109
- phoneImages = new ArrayList <>();
110
- else
111
- watchImages = new ArrayList <>();
112
108
}
113
109
114
110
@@ -196,7 +192,39 @@ protected boolean badness() {
196
192
return false ;
197
193
}
198
194
199
- protected void getImages (AndroidSDK sdk ) throws IOException {
195
+
196
+ protected boolean hasImages (final AndroidSDK sdk ) throws IOException {
197
+ if (phoneImages == null ) {
198
+ phoneImages = new ArrayList <String >();
199
+ getImages (phoneImages , sdk , SysImageDownloader .SYSTEM_IMAGE_TAG );
200
+ }
201
+ return !phoneImages .isEmpty ();
202
+ }
203
+
204
+
205
+ protected void refreshImages (final AndroidSDK sdk ) throws IOException {
206
+ phoneImages = new ArrayList <String >();
207
+ getImages (phoneImages , sdk , SysImageDownloader .SYSTEM_IMAGE_TAG );
208
+ }
209
+
210
+
211
+ protected boolean hasWearImages (final AndroidSDK sdk ) throws IOException {
212
+ if (wearImages == null ) {
213
+ wearImages = new ArrayList <String >();
214
+ getImages (wearImages , sdk , SysImageDownloader .SYSTEM_IMAGE_WEAR_TAG );
215
+ }
216
+ return !wearImages .isEmpty ();
217
+ }
218
+
219
+
220
+ protected void refreshWearImages (final AndroidSDK sdk ) throws IOException {
221
+ wearImages = new ArrayList <String >();
222
+ getImages (wearImages , sdk , SysImageDownloader .SYSTEM_IMAGE_WEAR_TAG );
223
+ }
224
+
225
+
226
+ protected void getImages (final ArrayList <String > images , final AndroidSDK sdk ,
227
+ final String imageTag ) throws IOException {
200
228
// Dummy avdmanager creation command to get the list of installed images
201
229
// TODO : Find a better way to get the list of installed images
202
230
ProcessBuilder pb = new ProcessBuilder (
@@ -218,12 +246,10 @@ protected void getImages(AndroidSDK sdk) throws IOException {
218
246
output .addTarget (new LineProcessor () {
219
247
@ Override
220
248
public void processLine (String line ) {
221
- if (phoneImages != null && line .contains (AndroidBuild .TARGET_PLATFORM ) &&
222
- line .contains (SysImageDownloader .SYSTEM_IMAGE_TAG ))
223
- phoneImages .add (line );
224
- else if (watchImages != null && line .contains (AndroidBuild .TARGET_PLATFORM ) &&
225
- line .contains (SysImageDownloader .SYSTEM_IMAGE_WEAR_TAG ))
226
- watchImages .add (line );
249
+ if (images != null && line .contains (AndroidBuild .TARGET_PLATFORM ) &&
250
+ line .contains (imageTag ))
251
+ System .out .println ("IMAGE ---> " + line );
252
+ images .add (line );
227
253
}
228
254
}).start ();
229
255
@@ -235,6 +261,7 @@ else if (watchImages != null && line.contains(AndroidBuild.TARGET_PLATFORM) &&
235
261
}
236
262
}
237
263
264
+
238
265
protected String getSdkId () throws IOException {
239
266
if (Preferences .get ("android.system.image.type" ) == null )
240
267
Preferences .set ("android.system.image.type" , "x86" ); // Prefer x86
@@ -245,7 +272,7 @@ protected String getSdkId() throws IOException {
245
272
return image ;
246
273
}
247
274
} else {
248
- for (String image : watchImages ) {
275
+ for (String image : wearImages ) {
249
276
if (image .contains (Preferences .get ("android.system.image.type" )))
250
277
return image ;
251
278
}
@@ -353,14 +380,12 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
353
380
AndroidUtil .showMessage (AVD_LOAD_TITLE , AVD_LOAD_MESSAGE );
354
381
return false ;
355
382
}
356
- wearAVD .getImages (sdk );
357
- if (wearAVD .watchImages .isEmpty ()) {
383
+ if (wearAVD .hasWearImages (sdk )) {
358
384
boolean res = AndroidSDK .locateSysImage (window , mode , true );
359
385
if (!res ) {
360
386
return false ;
361
387
} else {
362
- // Refresh images list
363
- wearAVD .getImages (sdk );
388
+ wearAVD .refreshWearImages (sdk );
364
389
}
365
390
}
366
391
if (wearAVD .create (sdk )) {
@@ -374,14 +399,12 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
374
399
AndroidUtil .showMessage (AVD_LOAD_TITLE , AVD_LOAD_MESSAGE );
375
400
return false ;
376
401
}
377
- mobileAVD .getImages (sdk );
378
- if (mobileAVD .phoneImages .isEmpty ()) {
402
+ if (mobileAVD .hasImages (sdk )) {
379
403
boolean res = AndroidSDK .locateSysImage (window , mode , false );
380
404
if (!res ) {
381
405
return false ;
382
406
} else {
383
- // Refresh images list
384
- mobileAVD .getImages (sdk );
407
+ mobileAVD .refreshImages (sdk );
385
408
}
386
409
}
387
410
if (mobileAVD .create (sdk )) {
0 commit comments