From: Raphael Moll Date: Fri, 8 Jul 2011 21:48:17 +0000 (-0400) Subject: Add "android create avd --abi" parameter. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f71a877edd18ab1bd604648c2ea4391cab65ee3d;p=android-x86%2Fsdk.git Add "android create avd --abi" parameter. SDK bug 4965341 (cherry picked from commit 65aa2161c1ad294ef141b479b6f49dabb2edb23b) Change-Id: Ic401e4ca56e19e416b0331baadbf742229bf60a0 --- diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java index 461a508cb..ebb203753 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/Main.java +++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java @@ -904,6 +904,28 @@ public class Main { } /** + * Displays the ABIs valid for the given target. + */ + private void displayAbiList(IAndroidTarget target, String message) { + String[] abis = target.getAbiList(); + mSdkLog.printf(message); + if (abis != null) { + boolean first = true; + for (String skin : abis) { + if (first == false) { + mSdkLog.printf(", "); + } else { + first = false; + } + mSdkLog.printf(skin); + } + mSdkLog.printf("\n"); + } else { + mSdkLog.printf("no ABIs.\n"); + } + } + + /** * Displays the list of available AVDs for the given AvdManager. * * @param avdManager @@ -1106,14 +1128,26 @@ public class Main { oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/); } - // NOTE: need to update with command line processor selectivity + String abiType = mSdkCommandLine.getParamAbi(); + if (target != null && (abiType == null || abiType.length() == 0)) { + String[] abis = target.getAbiList(); + if (abis != null && abis.length == 1) { + // Auto-select the single ABI available + abiType = abis[0]; + mSdkLog.printf("Auto-selecting single ABI %1$s", abiType); + } else { + displayAbiList(target, "Valid ABIs: "); + errorAndExit("This platform has more than one ABI. Please specify one using --%1$s.", + SdkCommandLine.KEY_ABI); + + } + } - String preferredAbi = SdkConstants.ABI_ARMEABI; @SuppressWarnings("unused") // newAvdInfo is never read, yet useful for debugging AvdInfo newAvdInfo = avdManager.createAvd(avdFolder, avdName, target, - preferredAbi, + abiType, skin, mSdkCommandLine.getParamSdCard(), hardwareConfig, diff --git a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java index 7b73f65e1..9323beedf 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java +++ b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java @@ -82,6 +82,7 @@ class SdkCommandLine extends CommandLineProcessor { public static final String KEY_SNAPSHOT = "snapshot"; //$NON-NLS-1$ public static final String KEY_COMPACT = "compact"; //$NON-NLS-1$ public static final String KEY_EOL_NULL = "null"; //$NON-NLS-1$ + public static final String KEY_ABI = "abi"; //$NON-NLS-1$ /** * Action definitions for SdkManager command line. @@ -203,6 +204,10 @@ class SdkCommandLine extends CommandLineProcessor { define(Mode.BOOLEAN, false, VERB_CREATE, OBJECT_AVD, "a", KEY_SNAPSHOT, //$NON-NLS-1$ "Place a snapshots file in the AVD, to enable persistence.", false); + define(Mode.STRING, false, + VERB_CREATE, OBJECT_AVD, "b", KEY_ABI, //$NON-NLS-1$ + "The ABI to use for the AVD. The default is to auto-select the ABI if the platform has only one ABI for its system images.", + null); // --- delete avd --- @@ -535,6 +540,11 @@ class SdkCommandLine extends CommandLineProcessor { return ((String) getValue(null, null, KEY_FILTER)); } + /** Helper to retrieve the --abi value. */ + public String getParamAbi() { + return ((String) getValue(null, null, KEY_ABI)); + } + /** Helper to retrieve the --proxy-host value. */ public String getParamProxyHost() { return ((String) getValue(null, null, KEY_PROXY_HOST)); diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java index 7a3b23c07..1ca7c0766 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java @@ -527,8 +527,7 @@ public class AvdManager { File userdataSrc = new File(imagePath, USERDATA_IMG); if (userdataSrc.exists() == false && target.isPlatform() == false) { - imagePath = - target.getParent().getImagePath(abiType); + imagePath = target.getParent().getImagePath(abiType); userdataSrc = new File(imagePath, USERDATA_IMG); } @@ -836,9 +835,8 @@ public class AvdManager { return null; } - /** Copy the nominated file to the given destination. - * @param source - * @param destination + /** + * Copy the nominated file to the given destination. * * @throws FileNotFoundException * @throws IOException