diff options
Diffstat (limited to 'sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java')
-rw-r--r-- | sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java | 77 |
1 files changed, 59 insertions, 18 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java index 3e6e23e..d924d3d 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java @@ -18,11 +18,11 @@ package com.android.sdklib; import com.android.annotations.VisibleForTesting; import com.android.annotations.VisibleForTesting.Visibility; +import com.android.io.FileWrapper; import com.android.prefs.AndroidLocation; import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.sdklib.AndroidVersion.AndroidVersionException; import com.android.sdklib.internal.project.ProjectProperties; -import com.android.sdklib.io.FileWrapper; import com.android.util.Pair; import java.io.File; @@ -233,13 +233,17 @@ public class SdkManager { /** * Loads the Platforms from the SDK. + * Creates the "platforms" folder if necessary. + * * @param sdkOsPath Location of the SDK * @param list the list to fill with the platforms. * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null. + * @throws RuntimeException when the "platforms" folder is missing and cannot be created. */ private static void loadPlatforms(String sdkOsPath, ArrayList<IAndroidTarget> list, ISdkLog log) { File platformFolder = new File(sdkOsPath, SdkConstants.FD_PLATFORMS); + if (platformFolder.isDirectory()) { File[] platforms = platformFolder.listFiles(); @@ -257,15 +261,18 @@ public class SdkManager { return; } - String message = null; - if (platformFolder.exists() == false) { - message = "%s is missing."; + // Try to create it or complain if something else is in the way. + if (!platformFolder.exists()) { + if (!platformFolder.mkdir()) { + throw new RuntimeException( + String.format("Failed to create %1$s.", + platformFolder.getAbsolutePath())); + } } else { - message = "%s is not a folder."; + throw new RuntimeException( + String.format("%1$s is not a folder.", + platformFolder.getAbsolutePath())); } - - throw new IllegalArgumentException(String.format(message, - platformFolder.getAbsolutePath())); } /** @@ -355,15 +362,17 @@ public class SdkManager { return null; } + String[] abiList = getAbiList(platformFolder.getAbsolutePath()); // create the target. PlatformTarget target = new PlatformTarget( sdkOsPath, platformFolder.getAbsolutePath(), - map, apiNumber, apiCodename, apiName, - revision); + revision, + abiList, + map); // need to parse the skins. String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS)); @@ -380,15 +389,43 @@ public class SdkManager { return null; } + /** + * Get all the abi types supported for a given target + * @param path Path where the images folder for a target is located + * @return an array of strings containing all the abi names for the target + */ + private static String[] getAbiList(String path) { + ArrayList<String> list = new ArrayList<String>(); + + File imagesFolder = new File(path + File.separator + SdkConstants.OS_IMAGES_FOLDER); + File[] files = imagesFolder.listFiles(); + + if (files != null) { + // Loop through Images directory. If subdirectories exist, set multiprocessor mode + for (File file : files) { + if (file.isDirectory()) { + list.add(file.getName()); + } + } + } + String[] abis = new String[list.size()]; + list.toArray(abis); + + return abis; + } /** * Loads the Add-on from the SDK. + * Creates the "add-ons" folder if necessary. + * * @param osSdkPath Location of the SDK * @param list the list to fill with the add-ons. * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null. + * @throws RuntimeException when the "add-ons" folder is missing and cannot be created. */ private static void loadAddOns(String osSdkPath, ArrayList<IAndroidTarget> list, ISdkLog log) { File addonFolder = new File(osSdkPath, SdkConstants.FD_ADDONS); + if (addonFolder.isDirectory()) { File[] addons = addonFolder.listFiles(); @@ -407,15 +444,18 @@ public class SdkManager { return; } - String message = null; - if (addonFolder.exists() == false) { - message = "%s is missing."; + // Try to create it or complain if something else is in the way. + if (!addonFolder.exists()) { + if (!addonFolder.mkdir()) { + throw new RuntimeException( + String.format("Failed to create %1$s.", + addonFolder.getAbsolutePath())); + } } else { - message = "%s is not a folder."; + throw new RuntimeException( + String.format("%1$s is not a folder.", + addonFolder.getAbsolutePath())); } - - throw new IllegalArgumentException(String.format(message, - addonFolder.getAbsolutePath())); } /** @@ -514,8 +554,9 @@ public class SdkManager { } } + String[] abiList = getAbiList(addonDir.getAbsolutePath()); AddOnTarget target = new AddOnTarget(addonDir.getAbsolutePath(), name, vendor, - revisionValue, description, libMap, baseTarget); + revisionValue, description, abiList, libMap, baseTarget); // need to parse the skins. String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS)); |