|
7 | 7 |
|
8 | 8 | import java.io.IOException; |
9 | 9 | import java.util.ArrayList; |
| 10 | +import java.util.Arrays; |
10 | 11 |
|
11 | 12 |
|
12 | 13 | public class AVD { |
@@ -54,11 +55,21 @@ public class AVD { |
54 | 55 | static ArrayList<String> badList; |
55 | 56 | // static ArrayList<String> skinList; |
56 | 57 |
|
| 58 | + private String[] preferredAbi = new String[50]; |
| 59 | + private static ArrayList<String> abiList = new ArrayList<>(); |
57 | 60 |
|
58 | 61 | public AVD(final String name, final String target) { |
59 | 62 | this.name = name; |
60 | 63 | this.target = target; |
61 | 64 | } |
| 65 | + |
| 66 | + private void initializeAbiList() { |
| 67 | + if (abiList.size() == 0) { |
| 68 | + abiList.add("armeabi"); |
| 69 | + abiList.add("x86"); |
| 70 | + abiList.add("x86_64"); |
| 71 | + } |
| 72 | + } |
62 | 73 |
|
63 | 74 |
|
64 | 75 | static protected void list(final AndroidSDK sdk) throws IOException { |
@@ -131,20 +142,59 @@ protected boolean badness() { |
131 | 142 |
|
132 | 143 |
|
133 | 144 | protected boolean create(final AndroidSDK sdk) throws IOException { |
| 145 | + |
| 146 | + final String[] list_abi = { |
| 147 | + sdk.getAndroidToolPath(), |
| 148 | + "list", "targets" |
| 149 | + }; |
| 150 | + |
| 151 | + ProcessHelper p = new ProcessHelper(list_abi); |
| 152 | + try { |
| 153 | + final ProcessResult abiListResult = p.execute(); |
| 154 | + String api = null; |
| 155 | + String abi = null; |
| 156 | + for (String line : abiListResult) { |
| 157 | + String[] m = PApplet.match(line, "API\\slevel:\\s(\\S+)"); |
| 158 | + if (m != null) { |
| 159 | + api = m[1]; |
| 160 | + } |
| 161 | + |
| 162 | + m = PApplet.match(line, "Tag\\/ABIs\\s:\\sdefault\\/(\\S+)"); |
| 163 | + if (m != null) { |
| 164 | + abi = m[1]; |
| 165 | + |
| 166 | + if (api != null && abi != null) { |
| 167 | + int index = Integer.parseInt(api); |
| 168 | + if (preferredAbi[index] == null) { |
| 169 | + preferredAbi[index] = abi; |
| 170 | + } else if (abiList.indexOf(preferredAbi[index]) < abiList.indexOf(abi)) { |
| 171 | + preferredAbi[index] = abi; |
| 172 | + } |
| 173 | + api = null; |
| 174 | + abi = null; |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + } catch (InterruptedException e) {} |
| 179 | + |
| 180 | + if (preferredAbi[Integer.parseInt(AndroidBuild.sdkVersion)] == null) { |
| 181 | + return false; |
| 182 | + } |
| 183 | + |
134 | 184 | final String[] params = { |
135 | 185 | sdk.getAndroidToolPath(), |
136 | 186 | "create", "avd", |
137 | 187 | "-n", name, |
138 | 188 | "-t", target, |
139 | 189 | "-c", DEFAULT_SDCARD_SIZE, |
140 | 190 | "-s", DEFAULT_SKIN, |
141 | | - "--abi", "armeabi" |
| 191 | + "--abi", preferredAbi[Integer.parseInt(AndroidBuild.sdkVersion)] |
142 | 192 | }; |
143 | 193 |
|
144 | 194 | // Set the list to null so that exists() will check again |
145 | 195 | avdList = null; |
146 | 196 |
|
147 | | - final ProcessHelper p = new ProcessHelper(params); |
| 197 | + p = new ProcessHelper(params); |
148 | 198 | try { |
149 | 199 | // Passes 'no' to "Do you wish to create a custom hardware profile [no]" |
150 | 200 | // System.out.println("CREATE AVD STARTING"); |
@@ -191,7 +241,6 @@ static public boolean ensureProperAVD(final AndroidSDK sdk) { |
191 | 241 | // Base.showWarning("Android Error", AVD_CREATE_ERROR, e); |
192 | 242 | Base.showWarningTiered("Android Error", AVD_CREATE_PRIMARY, AVD_CREATE_SECONDARY, null); |
193 | 243 | } |
194 | | - System.out.println("at bottom of ensure proper"); |
195 | 244 | return false; |
196 | 245 | } |
197 | 246 | } |
0 commit comments