aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--anttasks/src/com/android/ant/MultiApkExportTask.java18
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/ApkData.java195
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/MultiApkExportHelper.java38
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java70
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java15
-rw-r--r--sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/AndroidManifest-testapp2.xml8
-rw-r--r--sdkmanager/libs/sdklib/tests/com/android/sdklib/xml/SupportsScreensTest.java60
7 files changed, 257 insertions, 147 deletions
diff --git a/anttasks/src/com/android/ant/MultiApkExportTask.java b/anttasks/src/com/android/ant/MultiApkExportTask.java
index 3d1131b..151b81b 100644
--- a/anttasks/src/com/android/ant/MultiApkExportTask.java
+++ b/anttasks/src/com/android/ant/MultiApkExportTask.java
@@ -165,8 +165,8 @@ public class MultiApkExportTask extends Task {
}
// set the version code, and filtering
- String compositeVersionCode = getVersionCodeString(versionCode, apk);
- addProp(subAnt, "version.code", compositeVersionCode);
+ int compositeVersionCode = apk.getCompositeVersionCode(versionCode);
+ addProp(subAnt, "version.code", Integer.toString(compositeVersionCode));
System.out.println("Composite versionCode: " + compositeVersionCode);
String abi = apk.getAbi();
if (abi != null) {
@@ -279,20 +279,6 @@ public class MultiApkExportTask extends Task {
}
/**
- * Computes and returns the composite version code
- * @param versionCode the major version code.
- * @param apkData the apk data.
- * @return the composite versionCode to be used in the manifest.
- */
- private String getVersionCodeString(int versionCode, ApkData apkData) {
- int trueVersionCode = versionCode * MultiApkExportHelper.OFFSET_VERSION_CODE;
- trueVersionCode += apkData.getBuildInfo() * MultiApkExportHelper.OFFSET_BUILD_INFO;
- trueVersionCode += apkData.getMinor();
-
- return Integer.toString(trueVersionCode);
- }
-
- /**
* Returns the {@link File} for the build log.
* @param appPackage
* @param versionCode
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/ApkData.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/ApkData.java
index 9c3a8c5..f880079 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/ApkData.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/ApkData.java
@@ -16,10 +16,11 @@
package com.android.sdklib.internal.export;
+import com.android.sdklib.xml.ManifestData.SupportsScreens;
+
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Map;
/**
* Class representing one apk that needs to be generated. This contains
@@ -30,16 +31,14 @@ import java.io.OutputStreamWriter;
*/
public class ApkData implements Comparable<ApkData> {
- private final static int INDEX_OUTPUTNAME = 0;
- private final static int INDEX_PROJECT = 1;
- private final static int INDEX_MINOR = 2;
- private final static int INDEX_MINSDK = 3;
- private final static int INDEX_ABI = 4;
- private final static int INDEX_OPENGL = 5;
- private final static int INDEX_SCREENSIZE = 6;
- private final static int INDEX_LOCALES = 7;
- private final static int INDEX_DENSITY = 8;
- private final static int INDEX_MAX = 9;
+ private static final String PROP_SCREENS = "screens";
+ private static final String PROP_ABI = "abi";
+ private static final String PROP_GL = "gl";
+ private static final String PROP_API = "api";
+ private static final String PROP_PROJECT = "project";
+ private static final String PROP_MINOR = "minor";
+ private static final String PROP_BUILDINFO = "buildinfo";
+ private static final String PROP_OUTPUTNAME = "outputname";
private String mOutputName;
private String mRelativePath;
@@ -50,13 +49,19 @@ public class ApkData implements Comparable<ApkData> {
// the following are used to sort the export data and generate buildInfo
private int mMinSdkVersion;
private String mAbi;
- private int mGlVersion;
- // screen size?
+ private int mGlVersion = -1;
+ private SupportsScreens mSupportsScreens;
- public ApkData() {
+ ApkData() {
// do nothing.
}
+ public ApkData(int minSdkVersion, SupportsScreens supportsScreens, int glEsVersion) {
+ mMinSdkVersion = minSdkVersion;
+ mSupportsScreens = supportsScreens;
+ mGlVersion = glEsVersion;
+ }
+
public ApkData(ApkData data) {
mRelativePath = data.mRelativePath;
mProject = data.mProject;
@@ -65,6 +70,7 @@ public class ApkData implements Comparable<ApkData> {
mMinSdkVersion = data.mMinSdkVersion;
mAbi = data.mAbi;
mGlVersion = data.mGlVersion;
+ mSupportsScreens = data.mSupportsScreens;
}
public String getOutputName() {
@@ -111,10 +117,6 @@ public class ApkData implements Comparable<ApkData> {
return mMinSdkVersion;
}
- public void setMinSdkVersion(int minSdkVersion) {
- mMinSdkVersion = minSdkVersion;
- }
-
public String getAbi() {
return mAbi;
}
@@ -127,18 +129,49 @@ public class ApkData implements Comparable<ApkData> {
return mGlVersion;
}
- public void setGlVersion(int glVersion) {
- mGlVersion = glVersion;
+ public SupportsScreens getSupportsScreens() {
+ return mSupportsScreens;
+ }
+
+ /**
+ * Computes and returns the composite version code
+ * @param versionCode the major version code.
+ * @return the composite versionCode to be used in the manifest.
+ */
+ public int getCompositeVersionCode(int versionCode) {
+ int trueVersionCode = versionCode * MultiApkExportHelper.OFFSET_VERSION_CODE;
+ trueVersionCode += getBuildInfo() * MultiApkExportHelper.OFFSET_BUILD_INFO;
+ trueVersionCode += getMinor();
+
+ return trueVersionCode;
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder(mOutputName);
- sb.append(" / ").append(mRelativePath);
- sb.append(" / ").append(mBuildInfo);
- sb.append(" / ").append(mMinor);
- sb.append(" / ").append(mMinSdkVersion);
- sb.append(" / ").append(mAbi);
+ StringBuilder sb = new StringBuilder();
+ write(sb, PROP_OUTPUTNAME, mOutputName);
+ write(sb, PROP_BUILDINFO, mBuildInfo);
+ sb.append(getLogLine());
+
+ return sb.toString();
+ }
+
+ public String getLogLine() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(mBuildInfo).append(':');
+ write(sb, PROP_MINOR, mMinor);
+ write(sb, PROP_PROJECT, mRelativePath);
+ write(sb, PROP_API, mMinSdkVersion);
+
+ if (mGlVersion != -1) {
+ write(sb, PROP_GL, mGlVersion);
+ }
+
+ if (mAbi != null) {
+ write(sb, PROP_ABI, mAbi);
+ }
+
+ write(sb, PROP_SCREENS, mSupportsScreens);
return sb.toString();
}
@@ -149,9 +182,11 @@ public class ApkData implements Comparable<ApkData> {
return minSdkDiff;
}
+ int comp;
if (mAbi != null) {
if (o.mAbi != null) {
- return mAbi.compareTo(o.mAbi);
+ comp = mAbi.compareTo(o.mAbi);
+ if (comp != 0) return comp;
} else {
return -1;
}
@@ -159,13 +194,17 @@ public class ApkData implements Comparable<ApkData> {
return 1;
}
- if (mGlVersion != 0) {
- if (o.mGlVersion != 0) {
- return mGlVersion - o.mGlVersion;
+ comp = mSupportsScreens.compareTo(o.mSupportsScreens);
+ if (comp != 0) return comp;
+
+ if (mGlVersion != -1) {
+ if (o.mGlVersion != -1) {
+ comp = mGlVersion - o.mGlVersion;
+ if (comp != 0) return comp;
} else {
return -1;
}
- } else if (o.mGlVersion != 0) {
+ } else if (o.mGlVersion != -1) {
return 1;
}
@@ -173,79 +212,49 @@ public class ApkData implements Comparable<ApkData> {
}
/**
- * Writes the apk description in the given writer. a single line is used to write
- * everything.
- * @param writer The {@link OutputStreamWriter} to write to.
- * @throws IOException
- *
- * @see {@link #read(String)}
- */
- public void write(OutputStreamWriter writer) throws IOException {
- for (int i = 0 ; i < ApkData.INDEX_MAX ; i++) {
- write(i, writer);
- }
- }
-
- /**
* reads the apk description from a log line.
* @param line The fields to read, comma-separated.
*
- * @see #write(FileWriter)
+ * @see #getLogLine()
*/
- public void read(String line) {
- String[] dataStrs = line.split(",");
- for (int i = 0 ; i < ApkData.INDEX_MAX ; i++) {
- read(i, dataStrs);
+ public void initFromLogLine(String line) {
+ int colon = line.indexOf(':');
+ mBuildInfo = Integer.parseInt(line.substring(0, colon));
+ String[] properties = line.substring(colon+1).split(";");
+ HashMap<String, String> map = new HashMap<String, String>();
+ for (String prop : properties) {
+ colon = prop.indexOf('=');
+ map.put(prop.substring(0, colon), prop.substring(colon+1));
}
+ setValues(map);
}
- private void write(int index, OutputStreamWriter writer) throws IOException {
- switch (index) {
- case INDEX_OUTPUTNAME:
- writeValue(writer, mOutputName);
- break;
- case INDEX_PROJECT:
- writeValue(writer, mRelativePath);
- break;
- case INDEX_MINOR:
- writeValue(writer, mMinor);
- break;
- case INDEX_MINSDK:
- writeValue(writer, mMinSdkVersion);
- break;
- case INDEX_ABI:
- writeValue(writer, mAbi != null ? mAbi : "");
- break;
+ private void setValues(Map<String, String> values) {
+ mMinor = Integer.parseInt(values.get(PROP_MINOR));
+ mRelativePath = values.get(PROP_PROJECT);
+ mMinSdkVersion = Integer.parseInt(values.get(PROP_API));
+
+ String tmp = values.get(PROP_GL);
+ if (tmp != null) {
+ mGlVersion = Integer.parseInt(tmp);
+ }
+
+ tmp = values.get(PROP_ABI);
+ if (tmp != null) {
+ mAbi = tmp;
}
- }
- private void read(int index, String[] data) {
- switch (index) {
- case INDEX_OUTPUTNAME:
- mOutputName = data[index];
- break;
- case INDEX_PROJECT:
- mRelativePath = data[index];
- break;
- case INDEX_MINOR:
- mMinor = Integer.parseInt(data[index]);
- break;
- case INDEX_MINSDK:
- mMinSdkVersion = Integer.parseInt(data[index]);
- break;
- case INDEX_ABI:
- if (index < data.length && data[index].length() > 0) {
- mAbi = data[index];
- }
- break;
+ tmp = values.get(PROP_SCREENS);
+ if (tmp != null) {
+ mSupportsScreens = new SupportsScreens(tmp);
}
}
- private static void writeValue(OutputStreamWriter writer, String value) throws IOException {
- writer.append(value).append(',');
+ private void write(StringBuilder sb, String name, Object value) {
+ sb.append(name + "=").append(value).append(';');
}
- private static void writeValue(OutputStreamWriter writer, int value) throws IOException {
- writeValue(writer, Integer.toString(value));
+ private void write(StringBuilder sb, String name, int value) {
+ sb.append(name + "=").append(value).append(';');
}
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/MultiApkExportHelper.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/MultiApkExportHelper.java
index 235e436..55dfbf0 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/MultiApkExportHelper.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/MultiApkExportHelper.java
@@ -51,10 +51,10 @@ public class MultiApkExportHelper {
private final int mVersionCode;
private final Target mTarget;
- public final static int MAX_MINOR = 100;
- public final static int MAX_BUILDINFO = 100;
- public final static int OFFSET_BUILD_INFO = MAX_MINOR;
- public final static int OFFSET_VERSION_CODE = OFFSET_BUILD_INFO * MAX_BUILDINFO;
+ final static int MAX_MINOR = 100;
+ final static int MAX_BUILDINFO = 100;
+ final static int OFFSET_BUILD_INFO = MAX_MINOR;
+ final static int OFFSET_VERSION_CODE = OFFSET_BUILD_INFO * MAX_BUILDINFO;
public static final class ExportException extends Exception {
private static final long serialVersionUID = 1L;
@@ -157,18 +157,25 @@ public class MultiApkExportHelper {
try {
writer = new OutputStreamWriter(buildLog.getOutputStream());
- writer.append("# Multi-APK BUILD log.\n");
- writer.append("# Only edit manually to change minor versions.\n");
+ writer.append(
+ "# Multi-APK BUILD LOG.\n" +
+ "# This file serves two purpose:\n" +
+ "# - A log of what was built, showing what went in each APK and their properties.\n" +
+ "# You can refer to this if you get a bug report for a specific versionCode." +
+ "# - A way to update builds through minor revisions for specific APKs.\n" +
+ "# Only edit manually to change the minor properties for build you wish to respin.\n" +
+ "# Note that all APKs will be regenerated all the time.\n");
writeValue(writer, "package", mAppPackage);
writeValue(writer, "versionCode", mVersionCode);
- writer.append("# what follows is one line per generated apk with its description.\n");
- writer.append("# the format is CSV in the following order:\n");
- writer.append("# apkname,project,minor, minsdkversion, abi filter,\n");
+ writer.append(
+ "# The format of the following lines is:\n" +
+ "# <build number>:<property1>;<property2>;<property3>;...\n" +
+ "# Properties are written as <name>=<value>\n");
for (ApkData apk : apks) {
- apk.write(writer);
+ writer.append(apk.getLogLine());
writer.append('\n');
}
@@ -199,7 +206,8 @@ public class MultiApkExportHelper {
* gets the projects to export from the property, checks they exist, validates them,
* loads their export info and return it.
* If a project does not exist or is not valid, this will throw a {@link BuildException}.
- * @param projects the Ant project.
+ * @param projects the string containing all the relative paths to the projects. This is
+ * usually read from export.properties.
* @throws ExportException
*/
private ApkData[] getProjects(String projects) throws ExportException {
@@ -321,9 +329,9 @@ public class MultiApkExportHelper {
manifests.add(new Manifest(androidManifest, manifestData));
ArrayList<ApkData> dataList = new ArrayList<ApkData>();
- ApkData data = new ApkData();
+ ApkData data = new ApkData(minSdkVersion, manifestData.getSupportsScreensValues(),
+ manifestData.getGlEsVersion());
dataList.add(data);
- data.setMinSdkVersion(minSdkVersion);
// only look for more exports if the target is not clean.
if (mTarget != Target.CLEAN) {
@@ -386,7 +394,6 @@ public class MultiApkExportHelper {
bufferedReader = new BufferedReader(reader);
String line;
int lineIndex = 0;
- int apkIndex = 0;
while ((line = bufferedReader.readLine()) != null) {
line = line.trim();
if (line.length() == 0 || line.startsWith("#")) {
@@ -405,9 +412,8 @@ public class MultiApkExportHelper {
default:
// read apk description
ApkData data = new ApkData();
- data.setBuildInfo(apkIndex++);
datalist.add(data);
- data.read(line);
+ data.initFromLogLine(line);
if (data.getMinor() >= MAX_MINOR) {
throw new ExportException(
"Valid minor version code values are 0-" + (MAX_MINOR-1));
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java
index 869138a..ad0790e 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java
@@ -475,21 +475,20 @@ public class AndroidManifestParser {
private void processSupportsScreensNode(Attributes attributes) {
mManifestData.mSupportsScreensFromManifest = new SupportsScreens();
- mManifestData.mSupportsScreensFromManifest.setResizeable(Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_RESIZEABLE, true /*hasNamespace*/)));
- mManifestData.mSupportsScreensFromManifest.setAnyDensity(Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_ANYDENSITY, true /*hasNamespace*/)));
- mManifestData.mSupportsScreensFromManifest.setSmallScreens(Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_SMALLSCREENS, true /*hasNamespace*/)));
- mManifestData.mSupportsScreensFromManifest.setNormalScreens(Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_NORMALSCREENS, true /*hasNamespace*/)));
- mManifestData.mSupportsScreensFromManifest.setLargeScreens(Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_LARGESCREENS, true /*hasNamespace*/)));
+ mManifestData.mSupportsScreensFromManifest.setResizeable(getAttributeBooleanValue(
+ attributes, AndroidManifest.ATTRIBUTE_RESIZEABLE, true /*hasNamespace*/));
+
+ mManifestData.mSupportsScreensFromManifest.setAnyDensity(getAttributeBooleanValue(
+ attributes, AndroidManifest.ATTRIBUTE_ANYDENSITY, true /*hasNamespace*/));
+
+ mManifestData.mSupportsScreensFromManifest.setSmallScreens(getAttributeBooleanValue(
+ attributes, AndroidManifest.ATTRIBUTE_SMALLSCREENS, true /*hasNamespace*/));
+
+ mManifestData.mSupportsScreensFromManifest.setNormalScreens(getAttributeBooleanValue(
+ attributes, AndroidManifest.ATTRIBUTE_NORMALSCREENS, true /*hasNamespace*/));
+
+ mManifestData.mSupportsScreensFromManifest.setLargeScreens(getAttributeBooleanValue(
+ attributes, AndroidManifest.ATTRIBUTE_LARGESCREENS, true /*hasNamespace*/));
}
/**
@@ -499,15 +498,15 @@ public class AndroidManifestParser {
private void processUsesConfiguration(Attributes attributes) {
mManifestData.mUsesConfiguration = new UsesConfiguration();
- mManifestData.mUsesConfiguration.mReqFiveWayNav = Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_REQ_5WAYNAV, true /*hasNamespace*/));
+ mManifestData.mUsesConfiguration.mReqFiveWayNav = getAttributeBooleanValue(
+ attributes,
+ AndroidManifest.ATTRIBUTE_REQ_5WAYNAV, true /*hasNamespace*/);
mManifestData.mUsesConfiguration.mReqNavigation = Navigation.getEnum(
getAttributeValue(attributes,
AndroidManifest.ATTRIBUTE_REQ_NAVIGATION, true /*hasNamespace*/));
- mManifestData.mUsesConfiguration.mReqHardKeyboard = Boolean.valueOf(
- getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_REQ_HARDKEYBOARD, true /*hasNamespace*/));
+ mManifestData.mUsesConfiguration.mReqHardKeyboard = getAttributeBooleanValue(
+ attributes,
+ AndroidManifest.ATTRIBUTE_REQ_HARDKEYBOARD, true /*hasNamespace*/);
mManifestData.mUsesConfiguration.mReqKeyboardType = Keyboard.getEnum(
getAttributeValue(attributes,
AndroidManifest.ATTRIBUTE_REQ_KEYBOARDTYPE, true /*hasNamespace*/));
@@ -539,6 +538,35 @@ public class AndroidManifestParser {
return null;
}
+ /**
+ * Searches through the attributes list for a particular one and returns its value as a
+ * Boolean. If the attribute is not present, this will return null.
+ * @param attributes the attribute list to search through
+ * @param attributeName the name of the attribute to look for.
+ * @param hasNamespace Indicates whether the attribute has an android namespace.
+ * @return a String with the value or null if the attribute was not found.
+ * @see SdkConstants#NS_RESOURCES
+ */
+ private Boolean getAttributeBooleanValue(Attributes attributes, String attributeName,
+ boolean hasNamespace) {
+ int count = attributes.getLength();
+ for (int i = 0 ; i < count ; i++) {
+ if (attributeName.equals(attributes.getLocalName(i)) &&
+ ((hasNamespace &&
+ SdkConstants.NS_RESOURCES.equals(attributes.getURI(i))) ||
+ (hasNamespace == false && attributes.getURI(i).length() == 0))) {
+ String attr = attributes.getValue(i);
+ if (attr != null) {
+ return Boolean.valueOf(attr);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ return null;
+ }
+
}
private final static SAXParserFactory sParserFactory;
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java
index 168125e..955f8ed 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java
@@ -152,6 +152,19 @@ public final class ManifestData {
private Boolean mNormalScreens;
private Boolean mLargeScreens;
+ public SupportsScreens() {
+ }
+
+ public SupportsScreens(String value) {
+ String[] values = value.split("\\|");
+
+ mAnyDensity = Boolean.valueOf(values[0]);
+ mResizeable = Boolean.valueOf(values[1]);
+ mSmallScreens = Boolean.valueOf(values[2]);
+ mNormalScreens = Boolean.valueOf(values[3]);
+ mLargeScreens = Boolean.valueOf(values[4]);
+ }
+
/**
* Returns an instance of {@link SupportsScreens} initialized with the default values
* based on the given targetSdkVersion.
@@ -280,7 +293,7 @@ public final class ManifestData {
@Override
public String toString() {
- return String.format("AD: %1$s, RS: %2$s, SS: %3$s, NS: %4$s, LS: %5$s",
+ return String.format("%1$s|%2$s|%3$s|%4$s|%5$s",
mAnyDensity, mResizeable, mSmallScreens, mNormalScreens, mLargeScreens);
}
}
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/AndroidManifest-testapp2.xml b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/AndroidManifest-testapp2.xml
new file mode 100644
index 0000000..d5bcac7
--- /dev/null
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/AndroidManifest-testapp2.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.testapp" android:versionCode="42"
+ android:versionName="1.42">
+ <application android:icon="@drawable/icon"/>
+ <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" />
+ <supports-screens android:largeScreens="false" />
+</manifest>
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/xml/SupportsScreensTest.java b/sdkmanager/libs/sdklib/tests/com/android/sdklib/xml/SupportsScreensTest.java
new file mode 100644
index 0000000..c0cb12f
--- /dev/null
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/xml/SupportsScreensTest.java
@@ -0,0 +1,60 @@
+package com.android.sdklib.xml;
+
+import com.android.sdklib.xml.ManifestData.SupportsScreens;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+public class SupportsScreensTest extends TestCase {
+
+ private static final String TESTDATA_PATH =
+ "/com/android/sdklib/testdata/"; //$NON-NLS-1$
+ private static final String TESTAPP2_XML = TESTDATA_PATH +
+ "AndroidManifest-testapp2.xml"; //$NON-NLS-1$
+
+ public void testDefaultValuesApi3() {
+ SupportsScreens supportsScreens = SupportsScreens.getDefaultValues(3);
+
+ assertNotNull(supportsScreens);
+ assertEquals(Boolean.FALSE, supportsScreens.getAnyDensity());
+ assertEquals(Boolean.FALSE, supportsScreens.getResizeable());
+ assertEquals(Boolean.FALSE, supportsScreens.getSmallScreens());
+ assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
+ assertEquals(Boolean.FALSE, supportsScreens.getLargeScreens());
+ }
+
+ public void testDefaultValuesApi4() {
+ SupportsScreens supportsScreens = SupportsScreens.getDefaultValues(4);
+
+ assertNotNull(supportsScreens);
+ assertEquals(Boolean.TRUE, supportsScreens.getAnyDensity());
+ assertEquals(Boolean.TRUE, supportsScreens.getResizeable());
+ assertEquals(Boolean.TRUE, supportsScreens.getSmallScreens());
+ assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
+ assertEquals(Boolean.TRUE, supportsScreens.getLargeScreens());
+ }
+
+ public void testManifestParsing() throws Exception {
+ InputStream manifestStream = this.getClass().getResourceAsStream(TESTAPP2_XML);
+
+ ManifestData data = AndroidManifestParser.parse(manifestStream);
+ assertNotNull(data);
+
+ SupportsScreens supportsScreens = data.getSupportsScreensFromManifest();
+ assertNotNull(supportsScreens);
+ assertEquals(null, supportsScreens.getAnyDensity());
+ assertEquals(null, supportsScreens.getResizeable());
+ assertEquals(null, supportsScreens.getSmallScreens());
+ assertEquals(null, supportsScreens.getNormalScreens());
+ assertEquals(Boolean.FALSE, supportsScreens.getLargeScreens());
+
+ supportsScreens = data.getSupportsScreensValues();
+ assertNotNull(supportsScreens);
+ assertEquals(Boolean.TRUE, supportsScreens.getAnyDensity());
+ assertEquals(Boolean.TRUE, supportsScreens.getResizeable());
+ assertEquals(Boolean.TRUE, supportsScreens.getSmallScreens());
+ assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
+ assertEquals(Boolean.FALSE, supportsScreens.getLargeScreens());
+ }
+}