aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2011-08-31 23:20:58 -0700
committerRaphael <raphael@google.com>2011-09-06 11:44:23 -0700
commit82b6dad4d4c2c2551b57c5a57b2cb76862acd704 (patch)
treedd76b5764fe227d2fbcc11ef7a64c684191f3799 /sdkmanager
parentcb8228592503170f3e3136146f893d4d06d54ee9 (diff)
downloadsdk-82b6dad4d4c2c2551b57c5a57b2cb76862acd704.zip
sdk-82b6dad4d4c2c2551b57c5a57b2cb76862acd704.tar.gz
sdk-82b6dad4d4c2c2551b57c5a57b2cb76862acd704.tar.bz2
SdkManager: support <included-abi> in platform packages.
This is part of a series of CL to add support for system-image packages separated from platform packages. In this small CL we just add the <included-abi> element to platform packages, load/save it and test by loading a sample XML. Change-Id: Icbf554ea398bbcfe5cf760f9d25aec3de088937a
Diffstat (limited to 'sdkmanager')
-rw-r--r--sdkmanager/app/tests/com/android/sdkmanager/MainTest.java1
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java9
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java30
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-5.xsd2
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java8
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java1
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java10
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MinToolsPackageTest.java16
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformPackage.java139
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java159
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java10
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PlatformPackageTest.java100
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java10
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml2
14 files changed, 317 insertions, 180 deletions
diff --git a/sdkmanager/app/tests/com/android/sdkmanager/MainTest.java b/sdkmanager/app/tests/com/android/sdkmanager/MainTest.java
index ef5a715..a1f8853 100644
--- a/sdkmanager/app/tests/com/android/sdkmanager/MainTest.java
+++ b/sdkmanager/app/tests/com/android/sdkmanager/MainTest.java
@@ -119,6 +119,7 @@ public class MainTest extends SdkManagerTestCase {
// These are the values we expect checkFilterValues() to match.
String[] expectedValues = {
"platform",
+ "system-image",
"tool",
"platform-tool",
"doc",
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java
index 33b8fd2..9109fe2 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java
@@ -16,6 +16,9 @@
package com.android.sdklib;
+import com.android.annotations.VisibleForTesting;
+import com.android.annotations.VisibleForTesting.Visibility;
+
import java.util.Properties;
/**
@@ -39,8 +42,10 @@ import java.util.Properties;
*/
public final class AndroidVersion implements Comparable<AndroidVersion> {
- private static final String PROP_API_LEVEL = "AndroidVersion.ApiLevel"; //$NON-NLS-1$
- private static final String PROP_CODENAME = "AndroidVersion.CodeName"; //$NON-NLS-1$
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ public static final String PROP_API_LEVEL = "AndroidVersion.ApiLevel"; //$NON-NLS-1$
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ public static final String PROP_CODENAME = "AndroidVersion.CodeName"; //$NON-NLS-1$
private final int mApiLevel;
private final String mCodename;
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
index 6035ef5..954e04f 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
@@ -38,7 +38,8 @@ import java.util.Properties;
*/
public class PlatformPackage extends MinToolsPackage implements IPackageVersion, ILayoutlibVersion {
- public static final String PROP_VERSION = "Platform.Version";
+ public static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
+ public static final String PROP_INCLUDED_ABI = "Platform.Included.Abi"; //$NON-NLS-1$
/** The package version, for platform, add-on and doc packages. */
private final AndroidVersion mVersion;
@@ -46,9 +47,10 @@ public class PlatformPackage extends MinToolsPackage implements IPackageVersion,
/** The version, a string, for platform packages. */
private final String mVersionName;
- /**
- * The helper handling the layoutlib version.
- */
+ /** The ABI of the system-image included in this platform. Can be null but not empty. */
+ private final String mIncludedAbi;
+
+ /** The helper handling the layoutlib version. */
private final LayoutlibVersionMixin mLayoutlibVersion;
/**
@@ -65,14 +67,17 @@ public class PlatformPackage extends MinToolsPackage implements IPackageVersion,
super(source, packageNode, nsUri, licenses);
mVersionName = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_VERSION);
+
int apiLevel = XmlParserUtils.getXmlInt (packageNode, SdkRepoConstants.NODE_API_LEVEL, 0);
String codeName = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_CODENAME);
if (codeName.length() == 0) {
codeName = null;
}
-
mVersion = new AndroidVersion(apiLevel, codeName);
+ mIncludedAbi = XmlParserUtils.getOptionalXmlString(
+ packageNode, SdkRepoConstants.NODE_ABI_INCLUDED);
+
mLayoutlibVersion = new LayoutlibVersionMixin(packageNode);
}
@@ -109,6 +114,7 @@ public class PlatformPackage extends MinToolsPackage implements IPackageVersion,
mVersion = target.getVersion();
mVersionName = target.getVersionName();
mLayoutlibVersion = new LayoutlibVersionMixin(props);
+ mIncludedAbi = props == null ? null : props.getProperty(PROP_INCLUDED_ABI);
}
/**
@@ -126,6 +132,10 @@ public class PlatformPackage extends MinToolsPackage implements IPackageVersion,
props.setProperty(PROP_VERSION, mVersionName);
}
+ if (mIncludedAbi != null) {
+ props.setProperty(PROP_INCLUDED_ABI, mIncludedAbi);
+ }
+
}
/** Returns the version, a string, for platform packages. */
@@ -139,6 +149,16 @@ public class PlatformPackage extends MinToolsPackage implements IPackageVersion,
}
/**
+ * Returns the ABI of the system-image included in this platform.
+ *
+ * @return Null if the platform does not include any system-image.
+ * Otherwise should be a valid non-empty ABI string (e.g. "x86" or "armeabi-v7a").
+ */
+ public String getIncludedAbi() {
+ return mIncludedAbi;
+ }
+
+ /**
* Returns the layoutlib version. Mandatory starting with repository XSD rev 4.
* <p/>
* The first integer is the API of layoublib, which should be > 0.
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-5.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-5.xsd
index b0c4389..f473ce5 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-5.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-5.xsd
@@ -126,7 +126,7 @@
When the field is present, it means the platform already embeds one
system image. A platform can also have any number of external
&lt;system-image&gt; associated with it. -->
- <xsd:element name="abi-included" type="sdk:abiType" minOccurs="0" />
+ <xsd:element name="included-abi" type="sdk:abiType" minOccurs="0" />
<!-- An optional element indicating the package is obsolete.
The string content is however currently not defined and ignored. -->
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
index ba2bc41..015c53a 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
@@ -64,6 +64,13 @@ public class SdkRepoConstants extends RepoConstants {
public static final String NODE_DOC = "doc"; //$NON-NLS-1$
/** A sample package. */
public static final String NODE_SAMPLE = "sample"; //$NON-NLS-1$
+ /** A system-image package. */
+ public static final String NODE_SYSTEM_IMAGE = "system-image"; //$NON-NLS-1$
+
+ /* An included-ABI element for a system-image package. */
+ public static final String NODE_ABI_INCLUDED = "included-abi"; //$NON-NLS-1$
+ /* An ABI element for a system-image package. */
+ public static final String NODE_ABI = "abi"; //$NON-NLS-1$
/**
@@ -72,6 +79,7 @@ public class SdkRepoConstants extends RepoConstants {
*/
public static final String[] NODES = {
NODE_PLATFORM,
+ NODE_SYSTEM_IMAGE,
NODE_TOOL,
NODE_PLATFORM_TOOL,
NODE_DOC,
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java
index bf8600c..ebdb918 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java
@@ -31,6 +31,7 @@ public class SdkManagerTest extends SdkManagerTestCase {
super.tearDown();
}
+ @SuppressWarnings("deprecation")
public void testSdkManager_LayoutlibVersion() {
SdkManager sdkman = getSdkManager();
IAndroidTarget t = sdkman.getTargets()[0];
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java
index 1f98557..a8ac9f9 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java
@@ -27,16 +27,6 @@ public class ExtraPackageTest extends MinToolsPackageTest {
private static final char PS = File.pathSeparatorChar;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
private ExtraPackage createExtraPackage(Properties props) {
ExtraPackage p = (ExtraPackage) ExtraPackage.create(
null, //source
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MinToolsPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MinToolsPackageTest.java
index cea3bc4..c7a0482 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MinToolsPackageTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MinToolsPackageTest.java
@@ -25,6 +25,8 @@ import java.util.Properties;
public class MinToolsPackageTest extends PackageTest {
+ protected static final String LOCAL_ARCHIVE_PATH = "/local/archive/path";
+
/** Local class used to test the abstract MinToolsPackage class */
protected static class MockMinToolsPackage extends MinToolsPackage {
public MockMinToolsPackage(
@@ -70,16 +72,6 @@ public class MinToolsPackageTest extends PackageTest {
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- @Override
public void testCreate() {
Properties props = createProps();
@@ -92,7 +84,7 @@ public class MinToolsPackageTest extends PackageTest {
null, //descUrl
Os.ANY, //archiveOs
Arch.ANY, //archiveArch
- "/local/archive/path" //archiveOsPath
+ LOCAL_ARCHIVE_PATH
);
testCreatedPackage(p);
@@ -111,7 +103,7 @@ public class MinToolsPackageTest extends PackageTest {
null, //descUrl
Os.ANY, //archiveOs
Arch.ANY, //archiveArch
- "/local/archive/path" //archiveOsPath
+ LOCAL_ARCHIVE_PATH
);
Properties props2 = new Properties();
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformPackage.java
index 975108c..d358dd4 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformPackage.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformPackage.java
@@ -16,11 +16,8 @@
package com.android.sdklib.internal.repository;
-import com.android.sdklib.AndroidVersion;
import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.SdkConstants;
-import java.util.Map;
import java.util.Properties;
/**
@@ -75,140 +72,4 @@ public class MockPlatformPackage extends PlatformPackage {
public IAndroidTarget getTarget() {
return mTarget;
}
-
- /**
- * A mock PlatformTarget.
- * This reimplements the minimum needed from the interface for our limited testing needs.
- */
- static class MockPlatformTarget implements IAndroidTarget {
-
- private final int mApiLevel;
- private final int mRevision;
-
- public MockPlatformTarget(int apiLevel, int revision) {
- mApiLevel = apiLevel;
- mRevision = revision;
- }
-
- public String getClasspathName() {
- return getName();
- }
-
- public String getShortClasspathName() {
- return getName();
- }
-
- public String getDefaultSkin() {
- return null;
- }
-
- public String getDescription() {
- return getName();
- }
-
- public String getFullName() {
- return getName();
- }
-
- public String[] getAbiList() {
- return new String[] { SdkConstants.ABI_ARMEABI };
- }
-
- public String getImagePath(String abiType) {
- return SdkConstants.OS_IMAGES_FOLDER;
- }
-
- public String getLocation() {
- return "";
- }
-
- public IOptionalLibrary[] getOptionalLibraries() {
- return null;
- }
-
- public IAndroidTarget getParent() {
- return null;
- }
-
- public String getPath(int pathId) {
- return null;
- }
-
- public String[] getPlatformLibraries() {
- return null;
- }
-
- public String getProperty(String name) {
- return null;
- }
-
- public Integer getProperty(String name, Integer defaultValue) {
- return defaultValue;
- }
-
- public Boolean getProperty(String name, Boolean defaultValue) {
- return defaultValue;
- }
-
- public Map<String, String> getProperties() {
- return null;
- }
-
- public int getRevision() {
- return mRevision;
- }
-
- public String[] getSkins() {
- return null;
- }
-
- public int getUsbVendorId() {
- return 0;
- }
-
- /**
- * Returns a vendor that depends on the parent *platform* API.
- * This works well in Unit Tests where we'll typically have different
- * platforms as unique identifiers.
- */
- public String getVendor() {
- return "vendor " + Integer.toString(mApiLevel);
- }
-
- /**
- * Create a synthetic name using the target API level.
- */
- public String getName() {
- return "platform r" + Integer.toString(mApiLevel);
- }
-
- public AndroidVersion getVersion() {
- return new AndroidVersion(mApiLevel, null /*codename*/);
- }
-
- public String getVersionName() {
- return String.format("android-%1$d", mApiLevel);
- }
-
- public String hashString() {
- return getVersionName();
- }
-
- /** Returns true for a platform. */
- public boolean isPlatform() {
- return true;
- }
-
- public boolean canRunOn(IAndroidTarget target) {
- throw new UnsupportedOperationException("Implement this as needed for tests");
- }
-
- public int compareTo(IAndroidTarget o) {
- throw new UnsupportedOperationException("Implement this as needed for tests");
- }
-
- public boolean hasRenderingLibrary() {
- return false;
- }
- }
}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java
new file mode 100755
index 0000000..9b48e20
--- /dev/null
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sdklib.internal.repository;
+
+import com.android.sdklib.AndroidVersion;
+import com.android.sdklib.IAndroidTarget;
+import com.android.sdklib.SdkConstants;
+
+import java.util.Map;
+
+/**
+ * A mock PlatformTarget.
+ * This reimplements the minimum needed from the interface for our limited testing needs.
+ */
+class MockPlatformTarget implements IAndroidTarget {
+
+ private final int mApiLevel;
+ private final int mRevision;
+
+ public MockPlatformTarget(int apiLevel, int revision) {
+ mApiLevel = apiLevel;
+ mRevision = revision;
+ }
+
+ public String getClasspathName() {
+ return getName();
+ }
+
+ public String getShortClasspathName() {
+ return getName();
+ }
+
+ public String getDefaultSkin() {
+ return null;
+ }
+
+ public String getDescription() {
+ return getName();
+ }
+
+ public String getFullName() {
+ return getName();
+ }
+
+ public String[] getAbiList() {
+ return new String[] { SdkConstants.ABI_ARMEABI };
+ }
+
+ public String getImagePath(String abiType) {
+ return SdkConstants.OS_IMAGES_FOLDER;
+ }
+
+ public String getLocation() {
+ return "";
+ }
+
+ public IOptionalLibrary[] getOptionalLibraries() {
+ return null;
+ }
+
+ public IAndroidTarget getParent() {
+ return null;
+ }
+
+ public String getPath(int pathId) {
+ return null;
+ }
+
+ public String[] getPlatformLibraries() {
+ return null;
+ }
+
+ public String getProperty(String name) {
+ return null;
+ }
+
+ public Integer getProperty(String name, Integer defaultValue) {
+ return defaultValue;
+ }
+
+ public Boolean getProperty(String name, Boolean defaultValue) {
+ return defaultValue;
+ }
+
+ public Map<String, String> getProperties() {
+ return null;
+ }
+
+ public int getRevision() {
+ return mRevision;
+ }
+
+ public String[] getSkins() {
+ return null;
+ }
+
+ public int getUsbVendorId() {
+ return 0;
+ }
+
+ /**
+ * Returns a vendor that depends on the parent *platform* API.
+ * This works well in Unit Tests where we'll typically have different
+ * platforms as unique identifiers.
+ */
+ public String getVendor() {
+ return "vendor " + Integer.toString(mApiLevel);
+ }
+
+ /**
+ * Create a synthetic name using the target API level.
+ */
+ public String getName() {
+ return "platform r" + Integer.toString(mApiLevel);
+ }
+
+ public AndroidVersion getVersion() {
+ return new AndroidVersion(mApiLevel, null /*codename*/);
+ }
+
+ public String getVersionName() {
+ return String.format("android-%1$d", mApiLevel);
+ }
+
+ public String hashString() {
+ return getVersionName();
+ }
+
+ /** Returns true for a platform. */
+ public boolean isPlatform() {
+ return true;
+ }
+
+ public boolean canRunOn(IAndroidTarget target) {
+ throw new UnsupportedOperationException("Implement this as needed for tests");
+ }
+
+ public int compareTo(IAndroidTarget o) {
+ throw new UnsupportedOperationException("Implement this as needed for tests");
+ }
+
+ public boolean hasRenderingLibrary() {
+ return false;
+ }
+}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java
index 7e95c98..affcd58 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java
@@ -71,16 +71,6 @@ public class PackageTest extends TestCase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
public void testCreate() {
Properties props = createProps();
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PlatformPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PlatformPackageTest.java
new file mode 100755
index 0000000..da42d0c
--- /dev/null
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PlatformPackageTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sdklib.internal.repository;
+
+import com.android.sdklib.AndroidVersion;
+import com.android.sdklib.IAndroidTarget;
+import com.android.sdklib.internal.repository.Archive.Arch;
+import com.android.sdklib.internal.repository.Archive.Os;
+
+import java.util.Properties;
+
+public class PlatformPackageTest extends MinToolsPackageTest {
+
+ /**
+ * PlatformPackage implicitly generates a local archive wrapper
+ * that matches the current platform OS and architecture. Since this
+ * is not convenient for testing, this class overrides it to always
+ * create archives for any OS and any architecture.
+ */
+ private static class PlatformPackageWithFakeArchive extends PlatformPackage {
+ protected PlatformPackageWithFakeArchive(IAndroidTarget target, Properties props) {
+ super(target, props);
+ }
+
+ @Override
+ protected Archive[] initializeArchives(
+ Properties props,
+ Os archiveOs,
+ Arch archiveArch,
+ String archiveOsPath) {
+ assert archiveOs == Os.getCurrentOs();
+ assert archiveArch == Arch.getCurrentArch();
+ return super.initializeArchives(props, Os.ANY, Arch.ANY, LOCAL_ARCHIVE_PATH);
+ }
+ }
+
+ private PlatformPackage createPlatformPackage(Properties props) {
+ PlatformPackage p = new PlatformPackageWithFakeArchive(
+ new MockPlatformTarget(5 /*apiLevel*/, 1 /*revision*/),
+ props);
+
+ return p;
+ }
+
+ @Override
+ protected Properties createProps() {
+ Properties props = super.createProps();
+
+ // PlatformPackage properties
+ props.setProperty(AndroidVersion.PROP_API_LEVEL, "5");
+ props.setProperty(PlatformPackage.PROP_VERSION, "android-5");
+ props.setProperty(PlatformPackage.PROP_INCLUDED_ABI, "armeabi");
+
+ return props;
+ }
+
+ protected void testCreatedPlatformPackage(PlatformPackage p) {
+ super.testCreatedPackage(p);
+
+ // Package properties
+ assertEquals("API 5", p.getVersion().toString());
+ assertEquals("armeabi", p.getIncludedAbi());
+ }
+
+ // ----
+
+ @Override
+ public final void testCreate() {
+ Properties props = createProps();
+ PlatformPackage p = createPlatformPackage(props);
+
+ testCreatedPlatformPackage(p);
+ }
+
+ @Override
+ public void testSaveProperties() {
+ Properties props = createProps();
+ PlatformPackage p = createPlatformPackage(props);
+
+ Properties props2 = new Properties();
+ p.saveProperties(props2);
+
+ assertEquals(props2.toString(), props.toString());
+ assertEquals(props2, props);
+ }
+}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
index e3a6400..9cd2466 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
@@ -587,11 +587,14 @@ public class SdkRepoSourceTest extends TestCase {
assertTrue(p.getArchives().length >= 1);
}
- // Check the layoutlib of the platform packages.
+ // Check the layoutlib & included-abi of the platform packages.
ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>();
+ ArrayList<String> includedAbi = new ArrayList<String>();
for (Package p : pkgs) {
if (p instanceof PlatformPackage) {
layoutlibVers.add(((PlatformPackage) p).getLayoutlibVersion());
+ String abi = ((PlatformPackage) p).getIncludedAbi();
+ includedAbi.add(abi == null ? "(null)" : abi);
}
}
assertEquals(
@@ -599,6 +602,11 @@ public class SdkRepoSourceTest extends TestCase {
"Pair [first=5, second=31415], " + // platform API 2
"Pair [first=5, second=0]]", // platform API 1
Arrays.toString(layoutlibVers.toArray()));
+ assertEquals(
+ "[(null), " + // platform API 5 preview
+ "x86, " + // platform API 2
+ "armeabi]", // platform API 1
+ Arrays.toString(includedAbi.toArray()));
// Check the extra packages path, vendor, install folder, project-files, old-paths
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml
index 5040c1e..e90f654 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml
@@ -55,6 +55,7 @@
<sdk:api>5</sdk:api>
<sdk:revision>0</sdk:revision>
</sdk:layoutlib>
+ <sdk:included-abi>armeabi</sdk:included-abi>
</sdk:platform>
<sdk:doc>
@@ -110,6 +111,7 @@
<sdk:api>5</sdk:api>
<sdk:revision>31415</sdk:revision>
</sdk:layoutlib>
+ <sdk:included-abi>x86</sdk:included-abi>
</sdk:platform>
<sdk:platform>