From 10ca09dea02aa82b2b3d5b750178b724e3454129 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Thu, 17 May 2012 17:40:58 -0700 Subject: Added new devices schema Also updated devices.xml to validate against it. Change-Id: Ia9b5212b8273e39f7f22022661e2c755c3a9d279 --- build/product_sdk.mk | 1 + build/tools.atree | 2 + device_validator/Android.mk | 5 + device_validator/MODULE_LICENSE_APACHE2 | 0 device_validator/app/.classpath | 7 + device_validator/app/.project | 17 + .../app/.settings/org.eclipse.jdt.ui.prefs | 3 + device_validator/app/Android.mk | 31 + device_validator/app/etc/Android.mk | 10 + device_validator/app/etc/device_validator | 79 ++ device_validator/app/etc/manifest.txt | 3 + .../src/com/android/validator/DeviceValidator.java | 55 ++ device_validator/dvlib/.classpath | 8 + device_validator/dvlib/.gitignore | 1 + device_validator/dvlib/.project | 17 + device_validator/dvlib/Android.mk | 26 + .../dvlib/src/com/android/dvlib/DeviceSchema.java | 344 ++++++++ .../dvlib/src/com/android/dvlib/devices.xsd | 884 +++++++++++++++++++++ device_validator/dvlib/tests/Android.mk | 30 + .../src/com/android/dvlib/DeviceSchemaTest.java | 311 ++++++++ .../dvlib/tests/src/com/android/dvlib/devices.xml | 290 +++++++ .../src/com/android/dvlib/devices_minimal.xml | 155 ++++ .../src/com/android/dvlib/devices_no_default.xml | 134 ++++ .../src/com/android/dvlib/devices_no_hardware.xml | 80 ++ .../src/com/android/dvlib/devices_no_software.xml | 80 ++ .../src/com/android/dvlib/devices_no_states.xml | 128 +++ .../android/dvlib/devices_too_many_defaults.xml | 140 ++++ .../tests/src/com/android/dvlib/extras/frame.jpeg | 0 .../tests/src/com/android/dvlib/extras/frame.png | 0 .../src/com/android/dvlib/extras/sixteen.jpeg | 0 .../tests/src/com/android/dvlib/extras/sixteen.png | 0 .../src/com/android/dvlib/extras/sixtyfour.jpeg | 0 .../src/com/android/dvlib/extras/sixtyfour.png | 0 33 files changed, 2841 insertions(+) create mode 100644 device_validator/Android.mk create mode 100644 device_validator/MODULE_LICENSE_APACHE2 create mode 100644 device_validator/app/.classpath create mode 100644 device_validator/app/.project create mode 100644 device_validator/app/.settings/org.eclipse.jdt.ui.prefs create mode 100644 device_validator/app/Android.mk create mode 100644 device_validator/app/etc/Android.mk create mode 100755 device_validator/app/etc/device_validator create mode 100644 device_validator/app/etc/manifest.txt create mode 100644 device_validator/app/src/com/android/validator/DeviceValidator.java create mode 100644 device_validator/dvlib/.classpath create mode 100644 device_validator/dvlib/.gitignore create mode 100644 device_validator/dvlib/.project create mode 100644 device_validator/dvlib/Android.mk create mode 100644 device_validator/dvlib/src/com/android/dvlib/DeviceSchema.java create mode 100644 device_validator/dvlib/src/com/android/dvlib/devices.xsd create mode 100644 device_validator/dvlib/tests/Android.mk create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/DeviceSchemaTest.java create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices_minimal.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices_no_default.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices_no_hardware.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices_no_software.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices_no_states.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/devices_too_many_defaults.xml create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/extras/frame.jpeg create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/extras/frame.png create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/extras/sixteen.jpeg create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/extras/sixteen.png create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/extras/sixtyfour.jpeg create mode 100644 device_validator/dvlib/tests/src/com/android/dvlib/extras/sixtyfour.png diff --git a/build/product_sdk.mk b/build/product_sdk.mk index 5646668..bb033ac 100644 --- a/build/product_sdk.mk +++ b/build/product_sdk.mk @@ -40,6 +40,7 @@ PRODUCT_PACKAGES += \ ddms \ ddmuilib \ draw9patch \ + dvlib \ emulator \ hierarchyviewer \ ide_common \ diff --git a/build/tools.atree b/build/tools.atree index 16fdaf5..6ec63c0 100644 --- a/build/tools.atree +++ b/build/tools.atree @@ -108,6 +108,7 @@ framework/lint.jar tools/lib/lint.jar framework/lint_api.jar tools/lib/lint_api.jar framework/lint_checks.jar tools/lib/lint_checks.jar framework/manifmerger.jar tools/lib/manifmerger.jar +framework/dvlib.jar tools/lib/dvlib.jar # 3rd Party java libraries @@ -163,6 +164,7 @@ framework/common-tests.jar tests/libtests/common-tests.jar framework/sdklib-tests.jar tests/libtests/sdklib-tests.jar framework/sdkuilib-tests.jar tests/libtests/sdkuilib-tests.jar framework/layoutlib_api.jar tests/libtests/layoutlib_api.jar +framework/dvlib-tests.jar tests/libtests/dvlib-tests.jar #FIXME breaks build, manifmerger jar files not properly built #framework/manifmerger-tests.jar tests/libtests/manifmerger-tests.jar diff --git a/device_validator/Android.mk b/device_validator/Android.mk new file mode 100644 index 0000000..9e32461 --- /dev/null +++ b/device_validator/Android.mk @@ -0,0 +1,5 @@ +# Copyright 2012 The Android Open Source Project + +DEVICE_VALIDATOR_LOCAL_DIR := $(call my-dir) +include $(DEVICE_VALIDATOR_LOCAL_DIR)/dvlib/Android.mk +include $(DEVICE_VALIDATOR_LOCAL_DIR)/app/Android.mk diff --git a/device_validator/MODULE_LICENSE_APACHE2 b/device_validator/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 diff --git a/device_validator/app/.classpath b/device_validator/app/.classpath new file mode 100644 index 0000000..a1d7856 --- /dev/null +++ b/device_validator/app/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/device_validator/app/.project b/device_validator/app/.project new file mode 100644 index 0000000..fda9e3d --- /dev/null +++ b/device_validator/app/.project @@ -0,0 +1,17 @@ + + + device_validator + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/device_validator/app/.settings/org.eclipse.jdt.ui.prefs b/device_validator/app/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..c0fbc32 --- /dev/null +++ b/device_validator/app/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +#Fri May 25 10:41:24 PDT 2012 +eclipse.preferences.version=1 +formatter_settings_version=11 diff --git a/device_validator/app/Android.mk b/device_validator/app/Android.mk new file mode 100644 index 0000000..93e6226 --- /dev/null +++ b/device_validator/app/Android.mk @@ -0,0 +1,31 @@ +# Copyright (C) 2012 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. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_JAR_MANIFEST := etc/manifest.txt + +LOCAL_JAVA_LIBRARIES := \ + dvlib + +LOCAL_MODULE := device_validator +LOCAL_MODULE_TAGS := optional + +include $(BUILD_HOST_JAVA_LIBRARY) + +# Build all sub-directories +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/device_validator/app/etc/Android.mk b/device_validator/app/etc/Android.mk new file mode 100644 index 0000000..69a948c --- /dev/null +++ b/device_validator/app/etc/Android.mk @@ -0,0 +1,10 @@ +# Copyright 2012 The Android Open Source Project +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_PREBUILT_EXECUTABLES := device_validator +LOCAL_MODULE_TAGS := optional + +include $(BUILD_HOST_PREBUILT) + diff --git a/device_validator/app/etc/device_validator b/device_validator/app/etc/device_validator new file mode 100755 index 0000000..08a1023 --- /dev/null +++ b/device_validator/app/etc/device_validator @@ -0,0 +1,79 @@ +#!/bin/bash +# Copyright 2012, 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. + +# Set up prog to be the path of this script, including following symlinks, +# and set up progdir to be the fully-qualified pathname of its directory. +prog="$0" +while [ -h "${prog}" ]; do + newProg=`/bin/ls -ld "${prog}"` + newProg=`expr "${newProg}" : ".* -> \(.*\)$"` + if expr "x${newProg}" : 'x/' >/dev/null; then + prog="${newProg}" + else + progdir=`dirname "${prog}"` + prog="${progdir}/${newProg}" + fi +done +oldwd=`pwd` +progdir=`dirname "${prog}"` +cd "${progdir}" +progdir=`pwd` +prog="${progdir}"/`basename "${prog}"` +cd "${oldwd}" + +jarfile=device_validator.jar +frameworkdir="$progdir" +libdir="$progdir" +if [ ! -r "$frameworkdir/$jarfile" ] +then + frameworkdir=`dirname "$progdir"`/tools/lib + libdir=`dirname "$progdir"`/tools/lib +fi +if [ ! -r "$frameworkdir/$jarfile" ] +then + frameworkdir=`dirname "$progdir"`/framework + libdir=`dirname "$progdir"`/lib +fi +if [ ! -r "$frameworkdir/$jarfile" ] +then + echo `basename "$prog"`": can't find $jarfile" + exit 1 +fi + + +# Check args. +if [ debug = "$1" ]; then + # add this in for debugging + java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y + shift 1 +else + java_debug= +fi + +javaCmd="java" + +# Mac OS X needs an additional arg, or you get an "illegal thread" complaint. +if [ `uname` = "Darwin" ]; then + os_opts="-XstartOnFirstThread" +else + os_opts= +fi + +jarpath="$frameworkdir/$jarfile" + +exec "$javaCmd" \ + -Xmx256M $os_opts $java_debug \ + -classpath "$jarpath" \ + com.android.validator.DeviceValidator "$@" diff --git a/device_validator/app/etc/manifest.txt b/device_validator/app/etc/manifest.txt new file mode 100644 index 0000000..55b9038 --- /dev/null +++ b/device_validator/app/etc/manifest.txt @@ -0,0 +1,3 @@ +Main-Class: com.android.validator.DeviceValidator +Class-Path: dvlib.jar + diff --git a/device_validator/app/src/com/android/validator/DeviceValidator.java b/device_validator/app/src/com/android/validator/DeviceValidator.java new file mode 100644 index 0000000..4b4b16d --- /dev/null +++ b/device_validator/app/src/com/android/validator/DeviceValidator.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php + * + * 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.validator; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import com.android.dvlib.DeviceSchema; + +public class DeviceValidator { + + public static void main(String[] args) { + if (args.length == 0){ + printHelp(); + System.exit(1); + } + int ret = 0; + for (String a : args) { + File f = new File(a); + try { + if (!DeviceSchema.validate(new FileInputStream(f), System.err, f.getParentFile())) { + System.err.println("Error validating " + f.getAbsolutePath()); + System.out.println(); + ret = 1; + } else { + System.out.println(f.getAbsolutePath() + " validated successfully."); + } + } catch (FileNotFoundException e) { + System.err.println("File not found: " + a); + ret = 1; + } + } + System.exit(ret); + } + + private static void printHelp() { + System.err.printf("Usage: device_validator [files to validate]...\n"); + } + +} diff --git a/device_validator/dvlib/.classpath b/device_validator/dvlib/.classpath new file mode 100644 index 0000000..88fb9b4 --- /dev/null +++ b/device_validator/dvlib/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/device_validator/dvlib/.gitignore b/device_validator/dvlib/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/device_validator/dvlib/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/device_validator/dvlib/.project b/device_validator/dvlib/.project new file mode 100644 index 0000000..13abbdf --- /dev/null +++ b/device_validator/dvlib/.project @@ -0,0 +1,17 @@ + + + dvlib + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/device_validator/dvlib/Android.mk b/device_validator/dvlib/Android.mk new file mode 100644 index 0000000..1869adb --- /dev/null +++ b/device_validator/dvlib/Android.mk @@ -0,0 +1,26 @@ +# Copyright (C) 2012 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. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_JAVA_RESOURCE_DIRS := src + +LOCAL_MODULE := dvlib +LOCAL_MODULE_TAGS := optional + +include $(BUILD_HOST_JAVA_LIBRARY) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/device_validator/dvlib/src/com/android/dvlib/DeviceSchema.java b/device_validator/dvlib/src/com/android/dvlib/DeviceSchema.java new file mode 100644 index 0000000..101baf4 --- /dev/null +++ b/device_validator/dvlib/src/com/android/dvlib/DeviceSchema.java @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php + * + * 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.dvlib; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; + +import javax.xml.XMLConstants; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +public class DeviceSchema { + + public static final String NS_DEVICES_XSD = "http://schemas.android.com/sdk/devices/1"; + + /** + * The "devices" element is the root element of this schema. + * + * It must contain one or more "device" elements that each define the + * hardware, software, and states for a given device. + */ + public static final String NODE_DEVICES = "devices"; + + /** + * A "device" element contains a "hardware" element, a "software" element + * for each API version it supports, and a "state" element for each possible + * state the device could be in. + */ + public static final String NODE_DEVICE = "device"; + + /** + * The "hardware" element contains all of the hardware information for a + * given device. + */ + public static final String NODE_HARDWARE = "hardware"; + + /** + * The "software" element contains all of the software information for an + * API version of the given device. + */ + public static final String NODE_SOFTWARE = "software"; + + /** + * The "state" element contains all of the parameters for a given state of + * the device. It's also capable of redefining hardware configurations if + * they change based on state. + */ + public static final String NODE_STATE = "state"; + + public static final String NODE_KEYBOARD = "keyboard"; + + public static final String NODE_TOUCH = "touch"; + + public static final String NODE_GL_EXTENSIONS = "gl-extensions"; + + public static final String NODE_GL_VERSION = "gl-version"; + + public static final String NODE_NETWORKING = "networking"; + + public static final String NODE_REMOVABLE_STORAGE = "removable-storage"; + + public static final String NODE_FLASH = "flash"; + + public static final String NODE_LIVE_WALLPAPER_SUPPORT = "live-wallpaper-support"; + + public static final String NODE_BUTTONS = "buttons"; + + public static final String NODE_CAMERA = "camera"; + + public static final String NODE_LOCATION = "location"; + + public static final String NODE_GPU = "gpu"; + + public static final String NODE_DOCK = "dock"; + + public static final String NODE_YDPI = "ydpi"; + + public static final String NODE_PLUGGED_IN = "plugged-in"; + + public static final String NODE_Y_DIMENSION = "y-dimension"; + + public static final String NODE_SCREEN_RATIO = "screen-ratio"; + + public static final String NODE_NAV_STATE = "nav-state"; + + public static final String NODE_HAS_MIC = "has-mic"; + + public static final String NODE_RAM = "ram"; + + public static final String NODE_XDPI = "xdpi"; + + public static final String NODE_DIMENSIONS = "dimensions"; + + public static final String NODE_ABI = "abi"; + + public static final String NODE_MECHANISM = "mechanism"; + + public static final String NODE_MULTITOUCH = "multitouch"; + + public static final String NODE_NAV = "nav"; + + public static final String NODE_PIXEL_DENSITY = "pixel-density"; + + public static final String NODE_SCREEN_ORIENTATION = "screen-orientation"; + + public static final String NODE_AUTOFOCUS = "autofocus"; + + public static final String NODE_SCREEN_SIZE = "screen-size"; + + public static final String NODE_DESCRIPTION = "description"; + + public static final String NODE_BLUETOOTH_PROFILES = "bluetooth-profiles"; + + public static final String NODE_SCREEN = "screen"; + + public static final String NODE_SENSORS = "sensors"; + + public static final String NODE_DIAGONAL_LENGTH = "diagonal-length"; + + public static final String NODE_SCREEN_TYPE = "screen-type"; + + public static final String NODE_KEYBOARD_STATE = "keyboard-state"; + + public static final String NODE_X_DIMENSION = "x-dimension"; + + public static final String NODE_CPU = "cpu"; + + public static final String NODE_INTERNAL_STORAGE = "internal-storage"; + + public static final String NODE_META = "meta"; + + public static final String NODE_ICONS = "icons"; + + public static final String NODE_SIXTY_FOUR = "sixty-four"; + + public static final String NODE_SIXTEEN = "sixteen"; + + public static final String NODE_FRAME = "frame"; + + public static final String NODE_PATH = "path"; + + public static final String NODE_PORTRAIT_X_OFFSET = "portrait-x-offset"; + + public static final String NODE_PORTRAIT_Y_OFFSET = "portrait-y-offset"; + + public static final String NODE_LANDSCAPE_X_OFFSET = "landscape-x-offset"; + + public static final String NODE_LANDSCAPE_Y_OFFSET = "landscape-y-offset"; + + public static final String NODE_NAME = "name"; + + public static final String NODE_API_LEVEL = "api-level"; + + public static final String NODE_MANUFACTURER = "manufacturer"; + + public static final String ATTR_DEFAULT = "default"; + + public static final String ATTR_UNIT = "unit"; + + /** + * Validates the input stream. + * + * @param deviceXml + * The XML InputStream to validate. + * @param out + * The OutputStream for error messages. + * @param parent + * The parent directory of the input stream. + * @return Whether the given input constitutes a valid devices file. + */ + public static boolean validate(InputStream deviceXml, OutputStream out, File parent) { + Schema s; + SAXParserFactory factory = SAXParserFactory.newInstance(); + PrintWriter writer = new PrintWriter(out); + try { + s = DeviceSchema.getSchema(); + factory.setValidating(false); + factory.setNamespaceAware(true); + factory.setSchema(s); + ValidationHandler validator = new ValidationHandler(parent, writer); + SAXParser parser = factory.newSAXParser(); + parser.parse(deviceXml, validator); + return validator.isValidDevicesFile(); + } catch (SAXException e) { + writer.println(e.getMessage()); + return false; + } catch (ParserConfigurationException e) { + writer.println("Error creating SAX parser:"); + writer.println(e.getMessage()); + return false; + } catch (IOException e) { + writer.println("Error reading file stream:"); + writer.println(e.getMessage()); + return false; + } finally { + writer.flush(); + } + } + + /** + * Helper to get an input stream of the device config XML schema. + */ + public static InputStream getXsdStream() { + return DeviceSchema.class.getResourceAsStream("devices.xsd"); //$NON-NLS-1$ + } + + /** Helper method that returns a {@link Validator} for our XSD */ + public static Schema getSchema() throws SAXException { + InputStream xsdStream = getXsdStream(); + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = factory.newSchema(new StreamSource(xsdStream)); + return schema; + } + + /** + * A DefaultHandler that parses only to validate the XML is actually a valid + * devices config, since validation can't be entirely encoded in the devices + * schema. + */ + private static class ValidationHandler extends DefaultHandler { + private boolean mValidDevicesFile = true; + private boolean mDefaultSeen = false; + private String mDeviceName; + private final File mDirectory; + private final PrintWriter mWriter; + private final StringBuilder mStringAccumulator = new StringBuilder(); + + public ValidationHandler(File directory, PrintWriter writer) { + mDirectory = directory; // Possibly null + mWriter = writer; + } + + @Override + public void startElement(String uri, String localName, String name, Attributes attributes) + throws SAXException { + if (NODE_DEVICE.equals(localName)) { + // Reset for a new device + mDefaultSeen = false; + } else if (NODE_STATE.equals(localName)) { + // Check if the state is set to be a default state + String val = attributes.getValue(ATTR_DEFAULT); + if (val != null && ("1".equals(val) || Boolean.parseBoolean(val))) { + /* + * If it is and we already have a default state for this + * device, then the device configuration is invalid. + * Otherwise, set that we've seen a default state for this + * device and continue + */ + + if (mDefaultSeen) { + validationError("More than one default state for device " + mDeviceName); + } else { + mDefaultSeen = true; + } + } + } + mStringAccumulator.setLength(0); + } + + @Override + public void characters(char[] ch, int start, int length) { + mStringAccumulator.append(ch, start, length); + } + + @Override + public void endElement(String uri, String localName, String name) throws SAXException { + // If this is the end of a device node, make sure we have at least + // one default state + if (NODE_DEVICE.equals(localName) && !mDefaultSeen) { + validationError("No default state for device " + mDeviceName); + } else if (NODE_NAME.equals(localName)) { + mDeviceName = mStringAccumulator.toString().trim(); + } else if (NODE_PATH.equals(localName) || NODE_SIXTY_FOUR.equals(localName) + || NODE_SIXTEEN.equals(localName)) { + if (mDirectory == null) { + // There is no given parent directory, so this is not a + // valid devices file + validationError("No parent directory given, but relative paths exist."); + return; + } + // This is going to break on any files that end with a space, + // but that should be an incredibly rare corner case. + String relativePath = mStringAccumulator.toString().trim(); + File f = new File(mDirectory, relativePath); + if (f == null || !f.isFile()) { + validationError(relativePath + " is not a valid path."); + return; + } + String fileName = f.getName(); + int extensionStart = fileName.lastIndexOf("."); + if (extensionStart == -1 || !fileName.substring(extensionStart + 1).equals("png")) { + validationError(relativePath + " is not a valid file type."); + } + } + } + + @Override + public void error(SAXParseException e) { + validationError(e.getMessage()); + } + + @Override + public void fatalError(SAXParseException e) { + validationError(e.getMessage()); + } + + public boolean isValidDevicesFile() { + return mValidDevicesFile; + } + + private void validationError(String reason) { + mWriter.println("Error: " + reason); + mValidDevicesFile = false; + } + + } +} diff --git a/device_validator/dvlib/src/com/android/dvlib/devices.xsd b/device_validator/dvlib/src/com/android/dvlib/devices.xsd new file mode 100644 index 0000000..c3fa482 --- /dev/null +++ b/device_validator/dvlib/src/com/android/dvlib/devices.xsd @@ -0,0 +1,884 @@ + + + + + + + + + + + The "devices" element is the root element of this schema. + + It must contain one or more "device" elements that each define the configurations + and states available for a given device. + + + + + + + A device element contains one hardware profile for a device, along with + 1 or more software profiles and 1 or more states. Each software profile + defines the supported software for a given API release, and each state + profile defines a different possible state of the device (screen in + portrait orientation, screen in landscape orientation with the keyboard + out, etc.) + + + + + + + + + + + + + + + + + + + + The hardwareType contains all of the hardware information for + a given device. This includes things like the GPU type, screen + size, mic presence, etc. + + + + + + + + + + + + + + + + + + + + + + + + + + The softwareType contains all of the device's software + information for a given API version. This includes things like + live wallpaper support, OpenGL version, etc. + + + + + + + Specifies which API version(s) this this element is + defining. This can in the form of a single number + or a range of low to high, separated with a dash and + with either limit missing. The default lower limit is + one, and the default upper limit is unbounded. + The following are valid: + 10 + 7-10 + -10 + 7- + - + + + + + + + + + + + + Specifies whether the device supports live wallpapers. + + + + + + + + Specifies all of the available Bluetooth profiles. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specifies the OpenGL version supported for this release. + + + + + + + + + + + + + Specifies all of the supported OpenGL extensions for + this release. + + + + + + + + + + + + + The stateType contains the information for a given state of + of the device. States include things like portrait mode, + landscape with the keyboard exposed, etc. States can also + modify the hardware attributes of a device. For instance, if + sliding out the keyboard increased the available screen + real estate, you can define a new screenType to override the + default one defined in the device's hardwareType. + + + + + + + A description of the defined state. + + + + + + + + Defines the orientation of the screen. Use square if + the device's screen has equal height and width, + otherwise use landscape or portrait. + + + + + + + + + + + + + + + Defines the state of the keyboard. If the device has no + keyboard use keysoft, otherwise use keysexposed or keyshidden. + + + + + + + + + + + + + + Defines the state of the primary non-touchscreen + navigation hardware on the devices. If the device + doesn't have non-touchscreen navigation hardware use + nonav, otherwise use navexposed or navhidden. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Details where more device information can be found, such as + icons and frame images. + + + + + + + Contains the relative paths to the icon files for this + device. + + + + + + + + Relative path for the 64x64 icon. + + + + + + + Relative path for the 16x16 icon. + + + + + + + + + + Contains information about the frame for the device. + + + + + + + + The relative path to the emulator frame for + the device. + + + + + + + The offset for the frame in the x direction, + in portrait mode. + + + + + + + The offset for the frame in the y direction, + in portrait mode. + + + + + + + The offset for the frame in the x direction, + in landscape mode. + + + + + + + The offset for the frame in the y direction, + in landscape mode. + + + + + + + + + + + + + Contains the specifications for the device's screen. + + + + + + + + Specifies the class of the screen. + + + + + + + + + + + + + + + Specifies the diagonal length of the screen in inches. + + + + + + + + + + + + + + Specifies the screen density of the device. The + medium density of traditional HVGA screens (mdpi) + is defined to be approximately 160dpi; low density + (ldpi) is 120, and high density (hdpi) is 240. There + is thus a 4:3 scaling factor between each density, + so a 9x9 bitmap in ldpi would be 12x12 in mdpi and + 16x16 in hdpi. + + + + + + + + + + + + + + + + + Specifies whether the configuration is for a taller or + wider than traditional screen. This is based purely on + the aspect ratio of the screen: QVGA, HVGA, and VGA are + notlong; WQVGA, WVGA, FWVGA are long. Note that long may + mean either wide or tall, depending on the current + orientation. + + + + + + + + + + + + + + Specifies the device screen resolution in pixels. + + + + + + + + Specifies the x-dimension's resolution in + pixels. + + + + + + + + + + Specifies the y-dimension's resolution in + pixels. + + + + + + + + + + + + + + Specifies the actual density in X of the device screen. + + + + + + + + + + + + + + Specifies the actual density in Y of the device screen. + + + + + + + + + + + + + + Specifies the touch properties of the device. + + + + + + + + Specifies the multitouch capabilities of the + device. This can be none if multitouch is + not supported, basic if the device can track + only basic two finger gestures, distinct if + the device can track two or more fingers + simultaneously, or jazz-hands if the device + can track 5 or more fingers simultaneously. + + + + + + + + + + + + + + + + Specifies the mechanism the device was + created for. + + + + + + + + + + + + + + + Specifies the type of touch screen on the + device. + + + + + + + + + + + + + + + + + + + + + Specifies the available networking hardware. + + + + + + + + + + + + + + + + + Specifies the available sensors. + + + + + + + + + + + + + + + + + + + + + Specifies whether the device has a mic or not. + + + + + + + + + Specifies the attributes of the camera. + + + + + + + Specifies the location of the camera. + + + + + + + + + + + + + + Specifies whether the camera can autofocus + + + + + + + + Specifies whether the camera has flash. + + + + + + + + + + Specifies the type of keyboard on the device. + + + + + + + + + + + + + Specifies the primary non-touchscreen navigation + hardware on the device. + + + + + + + + + + + + + + Specifies the amount of RAM on the device in the unit provided. + + + + + + + + + + + + + Specifies whether the device has physical (hard) buttons + (Home, Search, etc.), or uses soft buttons. + + + + + + + + + + + + A list specifying the sizes of internal storage in + the device, in the storage size unit provided. + + + + + + + + + + + + + Specifies the range of available removable storage sizes + in the unit provided. A positive value indicates the device is + available with that storage size included while a zero value + indicates an empty storage slot. + + + + + + + + + + + + + Defines a list for storage configurations such as internal or + removable storage. A positive value indicates the the device + has a storage unit of that size, while a zero value indicates + there is an empty location for a storage unit (such as an empty + SD card slot). + + + + + + + + + + + + Specifies the device's GPU. + + + + + + + + + + + Specifies the device's CPU. + + + + + + + + + + + Specifies which ABIs the device conforms to. + + + + + + + + + + + + + + + + + + Specifies the official docks available for the device. + + + + + + + + + + + + + + + + + Specifies when the device is plugged in. + + + + + + + + + + + + + Specifies the unit of storage. This can be MiB, GiB, etc. + + + + + + + + + + + + diff --git a/device_validator/dvlib/tests/Android.mk b/device_validator/dvlib/tests/Android.mk new file mode 100644 index 0000000..5094d7a --- /dev/null +++ b/device_validator/dvlib/tests/Android.mk @@ -0,0 +1,30 @@ +# Copyright (C) 2012 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. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_JAVA_RESOURCE_DIRS := src + +LOCAL_MODULE := dvlib-tests +LOCAL_MODULE_TAGS := optional + +LOCAL_JAVA_LIBRARIES := \ + dvlib \ + junit + +include $(BUILD_HOST_JAVA_LIBRARY) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/DeviceSchemaTest.java b/device_validator/dvlib/tests/src/com/android/dvlib/DeviceSchemaTest.java new file mode 100644 index 0000000..174f27c --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/DeviceSchemaTest.java @@ -0,0 +1,311 @@ +package com.android.dvlib; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.StringWriter; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import junit.framework.TestCase; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +public class DeviceSchemaTest extends TestCase { + + private void checkFailure(Map replacements, String regex) throws Exception { + // Generate XML stream with replacements + InputStream xmlStream = getReplacedStream(replacements); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + URL location = DeviceSchemaTest.class.getResource("."); + File parent = new File(location.toURI()); + assertFalse( + "Validation Assertion Failed, XML failed to validate when it was expected to pass\n", + DeviceSchema.validate(xmlStream, baos, parent)); + assertTrue(String.format("Regex Assertion Failed:\nExpected: %s\nActual: %s\n", regex, baos + .toString().trim()), baos.toString().trim().matches(regex)); + } + + private void checkFailure(String resource, String regex) throws Exception { + URL location = DeviceSchemaTest.class.getResource(resource); + File xml = new File(location.toURI()); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + assertFalse("Validation Assertion Failed, XML validated when it was expected to fail\n", + DeviceSchema.validate(new FileInputStream(xml), baos, xml.getParentFile())); + assertTrue(String.format("Regex Assertion Failed:\nExpected: %s\nActual: %s\n", regex, baos + .toString().trim()), baos.toString().trim().matches(regex)); + } + + private void checkSuccess(Map replacements) throws Exception { + InputStream xmlStream = getReplacedStream(replacements); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + URL location = DeviceSchemaTest.class.getResource("."); + File parent = new File(location.toURI()); + assertTrue(DeviceSchema.validate(xmlStream, baos, parent)); + assertTrue(baos.toString().trim().matches("")); + } + + private InputStream getReplacedStream(Map replacements) throws Exception { + URL location = DeviceSchema.class.getResource("devices_minimal.xml"); + File xml = new File(location.toURI()); + SAXParserFactory factory = SAXParserFactory.newInstance(); + factory.setNamespaceAware(true); + SAXParser parser = factory.newSAXParser(); + ReplacementHandler replacer = new ReplacementHandler(replacements); + parser.parse(xml, replacer); + Document doc = replacer.getGeneratedDocument(); + Transformer tf = TransformerFactory.newInstance().newTransformer(); + // Add indents so we're closer to user generated output + tf.setOutputProperty(OutputKeys.INDENT, "yes"); + DOMSource source = new DOMSource(doc); + StringWriter out = new StringWriter(); + StreamResult result = new StreamResult(out); + tf.transform(source, result); + return new ByteArrayInputStream(out.toString().getBytes("UTF-8")); + } + + public void testValidXml() throws Exception { + URL location = DeviceSchemaTest.class.getResource("devices.xml"); + File xml = new File(location.toURI()); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + boolean result = DeviceSchema.validate(new FileInputStream(xml), baos, xml.getParentFile()); + String output = baos.toString().trim(); + assertTrue( + String.format( + "Validation Assertion Failed, XML failed to validate when it was expected to pass\n%s\n",output), result); + assertTrue(String.format("Regex Assertion Failed\nExpected No Output\nActual: %s\n", baos + .toString().trim()), baos.toString().trim().matches("")); + } + + public void testNoHardware() throws Exception { + String regex = "Error: cvc-complex-type.2.4.a: Invalid content was found starting with " + + "element 'd:software'.*"; + checkFailure("devices_no_hardware.xml", regex); + } + + public void testNoSoftware() throws Exception { + String regex = "Error: cvc-complex-type.2.4.a: Invalid content was found starting with " + + "element 'd:state'.*"; + checkFailure("devices_no_software.xml", regex); + } + + public void testNoDefault() throws Exception { + String regex = "Error: No default state for device Galaxy Nexus.*"; + checkFailure("devices_no_default.xml", regex); + } + + public void testTooManyDefaults() throws Exception { + String regex = "Error: More than one default state for device Galaxy Nexus.*"; + checkFailure("devices_too_many_defaults.xml", regex); + } + + public void testNoStates() throws Exception { + String regex = "Error: cvc-complex-type.2.4.b: The content of element 'd:device' is not " + + "complete.*\nError: No default state for device Galaxy Nexus.*"; + checkFailure("devices_no_states.xml", regex); + } + + public void testBadMechanism() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_MECHANISM, "fanger"); + checkFailure(replacements, "Error: cvc-enumeration-valid: Value 'fanger' is not " + + "facet-valid.*\nError: cvc-type.3.1.3: The value 'fanger' of element " + + "'d:mechanism' is not valid.*"); + } + + public void testNegativeXdpi() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_XDPI, "-1.0"); + checkFailure(replacements, "Error: cvc-minInclusive-valid: Value '-1.0'.*\n" + + "Error: cvc-type.3.1.3: The value '-1.0' of element 'd:xdpi' is not valid.*"); + } + + public void testNegativeYdpi() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_YDPI, "-1"); + checkFailure(replacements, "Error: cvc-minInclusive-valid: Value '-1'.*\n" + + "Error: cvc-type.3.1.3: The value '-1' of element 'd:ydpi' is not valid.*"); + + } + + public void testNegativeDiagonalLength() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_DIAGONAL_LENGTH, "-1.0"); + + checkFailure(replacements, "Error: cvc-minInclusive-valid: Value '-1.0'.*\n" + + "Error: cvc-type.3.1.3: The value '-1.0' of element 'd:diagonal-length'.*"); + + } + + public void testInvalidOpenGLVersion() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_GL_VERSION, "2"); + checkFailure(replacements, "Error: cvc-pattern-valid: Value '2' is not facet-valid.*\n" + + "Error: cvc-type.3.1.3: The value '2' of element 'd:gl-version' is not valid.*"); + } + + public void testInvalidIconTypes() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_SIXTEEN, "extras/sixteen.jpeg"); + replacements.put(DeviceSchema.NODE_SIXTY_FOUR, "extras/sixtyfour.jpeg"); + replacements.put(DeviceSchema.NODE_PATH, "extras/frame.jpeg"); + checkFailure(replacements, "Error: extras/sixtyfour.jpeg is not a valid file type.\n" + + "Error: extras/sixteen.jpeg is not a valid file type.\n" + + "Error: extras/frame.jpeg is not a valid file type."); + } + + public void testMissingIcons() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_SIXTEEN, "extras/missing"); + replacements.put(DeviceSchema.NODE_SIXTY_FOUR, "extras/missing"); + replacements.put(DeviceSchema.NODE_PATH, "extras/missing"); + checkFailure(replacements, "Error: extras/missing is not a valid path.\n" + + "Error: extras/missing is not a valid path.\n" + + "Error: extras/missing is not a valid path."); + } + + public void testEmptyOpenGLExtensions() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_GL_EXTENSIONS, ""); + checkSuccess(replacements); + } + + public void testEmptySensors() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_SENSORS, ""); + checkSuccess(replacements); + } + + public void testEmptyNetworking() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_NETWORKING, ""); + checkSuccess(replacements); + } + + public void testEmptyCpu() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_CPU, ""); + checkFailure(replacements, "Error: cvc-minLength-valid: Value '' with length = '0'.*\n" + + "Error: cvc-type.3.1.3: The value '' of element 'd:cpu' is not valid.*"); + } + + public void testEmptyGpu() throws Exception { + Map replacements = new HashMap(); + replacements.put(DeviceSchema.NODE_GPU, ""); + checkFailure(replacements, "Error: cvc-minLength-valid: Value '' with length = '0'.*\n" + + "Error: cvc-type.3.1.3: The value '' of element 'd:gpu' is not valid.*"); + } + + /** + * Reads in a valid devices XML file and if an element tag is in the + * replacements map, it replaces its text content with the corresponding + * value. Note this has no concept of namespaces or hierarchy, so it will + * replace the contents any and all elements with the specified tag name. + */ + private static class ReplacementHandler extends DefaultHandler { + private Element mCurrElement = null; + private Document mDocument; + private final Stack mElementStack = new Stack(); + private final Map mPrefixes = new HashMap(); + private final Map mReplacements; + private final StringBuilder mStringAccumulator = new StringBuilder(); + + public ReplacementHandler(Map replacements) { + mReplacements = replacements; + } + + @Override + public void startDocument() { + try { + mDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + } catch (ParserConfigurationException e) { + fail(e.getMessage()); + } + } + + @Override + public void startElement(String uri, String localName, String name, Attributes attributes) { + Element element = mDocument.createElement(name); + for (int i = 0; i < attributes.getLength(); i++) { + element.setAttribute(attributes.getQName(i), attributes.getValue(i)); + } + for (String key : mPrefixes.keySet()) { + element.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + key, mPrefixes.get(key)); + } + mPrefixes.clear(); + if (mCurrElement != null) { + mElementStack.push(mCurrElement); + } + mCurrElement = element; + } + + @Override + public void startPrefixMapping(String prefix, String uri) throws SAXException { + mPrefixes.put(prefix, uri); + } + + @Override + public void characters(char[] ch, int start, int length) { + mStringAccumulator.append(ch, start, length); + } + + @Override + public void endElement(String uri, String localName, String name) throws SAXException { + if (mReplacements.containsKey(localName)) { + mCurrElement.appendChild(mDocument.createTextNode(mReplacements.get(localName))); + } else { + String content = mStringAccumulator.toString().trim(); + if (!content.isEmpty()) { + mCurrElement.appendChild(mDocument.createTextNode(content)); + } + } + + if (mElementStack.empty()) { + mDocument.appendChild(mCurrElement); + mCurrElement = null; + } else { + Element parent = mElementStack.pop(); + parent.appendChild(mCurrElement); + mCurrElement = parent; + } + mStringAccumulator.setLength(0); + } + + @Override + public void error(SAXParseException e) { + fail(e.getMessage()); + } + + @Override + public void fatalError(SAXParseException e) { + fail(e.getMessage()); + } + + public Document getGeneratedDocument() { + return mDocument; + } + + } +} diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices.xml new file mode 100644 index 0000000..aeb0f04 --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices.xml @@ -0,0 +1,290 @@ + + + + + + Galaxy Nexus + + + Samsung + + + + + extras/sixtyfour.png + + + extras/sixteen.png + + + + + extras/frame.png + + 0 + 0 + 0 + 0 + + + + + normal + 4.65 + xhdpi + long + + 720 + 1280 + + 316 + 316 + + jazz-hands + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Gyroscope + Compass + GPS + ProximitySensor + + true + + front + true + false + + + back + true + true + + nokeys + nonav + 1 + soft + 16 + + OMAP 4460 + PowerVR SGX540 + + armeabi + armeabi-v7a + + + + + + charge + + + 14- + true + + HSP + HFP + SPP + A2DP + AVRCP + OPP + PBAP + GAVDP + AVDTP + HID + HDP + PAN + + 2.0 + + + GL_EXT_discard_framebuffer + GL_EXT_multi_draw_arrays + GL_EXT_shader_texture_lod + GL_EXT_texture_format_BGRA8888 + GL_IMG_multisampled_render_to_texture + GL_IMG_program_binary + GL_IMG_read_format + GL_IMG_shader_binary + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_IMG_texture_npot + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_depth_texture + GL_OES_depth24 + GL_OES_EGL_image + GL_OES_EGL_image_external + GL_OES_egl_sync + GL_OES_element_index_uint + GL_OES_fragment_precision_high + GL_OES_get_program_binary + GL_OES_mapbuffer + GL_OES_packed_depth_stencil + GL_OES_required_internalformat + GL_OES_rgb8_rgba8 + GL_OES_standard_derivatives + GL_OES_texture_float + GL_OES_texture_half_float + GL_OES_vertex_array_object + GL_OES_vertex_half_float + + + + The phone in portrait view + portrait + keyssoft + nonav + + + The phone in landscape view + landscape + keyssoft + nonav + + + + Droid + Motorola + + + normal + 3.7 + hdpi + long + + 480 + 854 + + 265 + 265 + + distinct + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Compass + GPS + ProximitySensor + LightSensor + + true + + back + true + true + + qwerty + dpad + 256 + hard + 512 + 16 + OMAP 3430 + PowerVR SGX 53 + + armeabi + armeabi-v7a + + + car + desk + + charge + + + 5-8 + false + + GAP + SPP + HSP + HFP + A2DP + AVRCP + SDAP + + 1.1 + + + GL_OES_byte_coordinates + GL_OES_fixed_point + GL_OES_single_precision + GL_OES_matrix_get + GL_OES_read_format + GL_OES_compressed_paletted_texture + GL_OES_point_sprite + GL_OES_point_size_array + GL_OES_matrix_palette + GL_OES_draw_texture + GL_OES_query_matrix + GL_OES_texture_env_crossbar + GL_OES_texture_mirrored_repeat + GL_OES_texture_cube_map + GL_OES_blend_subtract + GL_OES_blend_func_separate + GL_OES_blend_equation_separate + GL_OES_stencil_wrap + GL_OES_extended_matrix_palette + GL_OES_framebuffer_object + GL_OES_rgb8_rgba8 + GL_OES_depth24 + GL_OES_stencil8 + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_mapbuffer + GL_OES_EGL_image + GL_EXT_multi_draw_arrays + GL_OES_required_internalformat + GL_IMG_read_format + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_EXT_texture_format_BGRA8888 + GL_IMG_texture_stream + GL_IMG_vertex_program + + + + The phone in portrait view + portrait + keyshidden + navhidden + + + The phone in landscape view with the keyboard closed + landscape + keyshidden + navhidden + + + The phone in landscape view with the keyboard open + landscape + keysexposed + navexposed + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices_minimal.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices_minimal.xml new file mode 100644 index 0000000..71ab61a --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices_minimal.xml @@ -0,0 +1,155 @@ + + + + + + Galaxy Nexus + + + Samsung + + + + + extras/sixtyfour.png + + + extras/sixteen.png + + + + + extras/frame.png + + 0 + 0 + 0 + 0 + + + + + normal + 4.65 + xhdpi + long + + 720 + 1280 + + 316 + 316 + + jazz-hands + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Gyroscope + Compass + GPS + ProximitySensor + + true + + front + true + false + + + back + true + true + + nokeys + nonav + 1 + soft + 16 + + OMAP 4460 + PowerVR SGX540 + + armeabi + armeabi-v7a + + + + + + charge + + + 15 + true + + HSP + HFP + SPP + A2DP + AVRCP + OPP + PBAP + GAVDP + AVDTP + HID + HDP + PAN + + 2.0 + + GL_EXT_discard_framebuffer + GL_EXT_multi_draw_arrays + GL_EXT_shader_texture_lod + GL_EXT_texture_format_BGRA8888 + GL_IMG_multisampled_render_to_texture + GL_IMG_program_binary + GL_IMG_read_format + GL_IMG_shader_binary + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_IMG_texture_npot + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_depth_texture + GL_OES_depth24 + GL_OES_EGL_image + GL_OES_EGL_image_external + GL_OES_egl_sync + GL_OES_element_index_uint + GL_OES_fragment_precision_high + GL_OES_get_program_binary + GL_OES_mapbuffer + GL_OES_packed_depth_stencil + GL_OES_required_internalformat + GL_OES_rgb8_rgba8 + GL_OES_standard_derivatives + GL_OES_texture_float + GL_OES_texture_half_float + GL_OES_vertex_array_object + GL_OES_vertex_half_float + + + + The phone in portrait view + portrait + keyssoft + nonav + + + The phone in landscape view + landscape + keyssoft + nonav + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_default.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_default.xml new file mode 100644 index 0000000..3ebcedb --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_default.xml @@ -0,0 +1,134 @@ + + + + + + Galaxy Nexus + + + Samsung + + + + normal + 4.65 + xhdpi + long + + 720 + 1280 + + 316 + 316 + + jazz-hands + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Gyroscope + Compass + GPS + ProximitySensor + + true + + front + true + false + + + back + true + true + + nokeys + nonav + 1 + soft + 16 + + OMAP 4460 + PowerVR SGX540 + + armeabi + armeabi-v7a + + + + + + charge + + + 14 + true + + HSP + HFP + SPP + A2DP + AVRCP + OPP + PBAP + GAVDP + AVDTP + HID + HDP + PAN + + 2.0 + + + GL_EXT_discard_framebuffer + GL_EXT_multi_draw_arrays + GL_EXT_shader_texture_lod + GL_EXT_texture_format_BGRA8888 + GL_IMG_multisampled_render_to_texture + GL_IMG_program_binary + GL_IMG_read_format + GL_IMG_shader_binary + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_IMG_texture_npot + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_depth_texture + GL_OES_depth24 + GL_OES_EGL_image + GL_OES_EGL_image_external + GL_OES_egl_sync + GL_OES_element_index_uint + GL_OES_fragment_precision_high + GL_OES_get_program_binary + GL_OES_mapbuffer + GL_OES_packed_depth_stencil + GL_OES_required_internalformat + GL_OES_rgb8_rgba8 + GL_OES_standard_derivatives + GL_OES_texture_float + GL_OES_texture_half_float + GL_OES_vertex_array_object + GL_OES_vertex_half_float + + + + The phone in portrait view + portrait + keyssoft + nonav + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_hardware.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_hardware.xml new file mode 100644 index 0000000..a5c3da1 --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_hardware.xml @@ -0,0 +1,80 @@ + + + + + + Galaxy Nexus + + + Samsung + + + 14 + true + + HSP + HFP + SPP + A2DP + AVRCP + OPP + PBAP + GAVDP + AVDTP + HID + HDP + PAN + + 2.0 + + + GL_EXT_discard_framebuffer + GL_EXT_multi_draw_arrays + GL_EXT_shader_texture_lod + GL_EXT_texture_format_BGRA8888 + GL_IMG_multisampled_render_to_texture + GL_IMG_program_binary + GL_IMG_read_format + GL_IMG_shader_binary + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_IMG_texture_npot + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_depth_texture + GL_OES_depth24 + GL_OES_EGL_image + GL_OES_EGL_image_external + GL_OES_egl_sync + GL_OES_element_index_uint + GL_OES_fragment_precision_high + GL_OES_get_program_binary + GL_OES_mapbuffer + GL_OES_packed_depth_stencil + GL_OES_required_internalformat + GL_OES_rgb8_rgba8 + GL_OES_standard_derivatives + GL_OES_texture_float + GL_OES_texture_half_float + GL_OES_vertex_array_object + GL_OES_vertex_half_float + + + + The phone in portrait view + portrait + keyssoft + nonav + + + The phone in landscape view + landscape + keyssoft + nonav + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_software.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_software.xml new file mode 100644 index 0000000..899110a --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_software.xml @@ -0,0 +1,80 @@ + + + + + + Galaxy Nexus + + + Samsung + + + + normal + 4.65 + xhdpi + long + + 720 + 1280 + + 316 + 316 + + jazz-hands + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Gyroscope + Compass + GPS + ProximitySensor + + true + + front + true + false + + + back + true + true + + nokeys + nonav + 1 + soft + 16 + + OMAP 4460 + PowerVR SGX540 + + armeabi + armeabi-v7a + + + + + + charge + + + The phone in portrait view + portrait + keyssoft + nonav + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_states.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_states.xml new file mode 100644 index 0000000..c4955b4 --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices_no_states.xml @@ -0,0 +1,128 @@ + + + + + + Galaxy Nexus + + + Samsung + + + + normal + 4.65 + xhdpi + long + + 720 + 1280 + + 316 + 316 + + jazz-hands + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Gyroscope + Compass + GPS + ProximitySensor + + true + + front + true + false + + + back + true + true + + nokeys + nonav + 1 + soft + 16 + + OMAP 4460 + PowerVR SGX540 + + armeabi + armeabi-v7a + + + + + + charge + + + 14 + true + + HSP + HFP + SPP + A2DP + AVRCP + OPP + PBAP + GAVDP + AVDTP + HID + HDP + PAN + + 2.0 + + + GL_EXT_discard_framebuffer + GL_EXT_multi_draw_arrays + GL_EXT_shader_texture_lod + GL_EXT_texture_format_BGRA8888 + GL_IMG_multisampled_render_to_texture + GL_IMG_program_binary + GL_IMG_read_format + GL_IMG_shader_binary + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_IMG_texture_npot + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_depth_texture + GL_OES_depth24 + GL_OES_EGL_image + GL_OES_EGL_image_external + GL_OES_egl_sync + GL_OES_element_index_uint + GL_OES_fragment_precision_high + GL_OES_get_program_binary + GL_OES_mapbuffer + GL_OES_packed_depth_stencil + GL_OES_required_internalformat + GL_OES_rgb8_rgba8 + GL_OES_standard_derivatives + GL_OES_texture_float + GL_OES_texture_half_float + GL_OES_vertex_array_object + GL_OES_vertex_half_float + + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/devices_too_many_defaults.xml b/device_validator/dvlib/tests/src/com/android/dvlib/devices_too_many_defaults.xml new file mode 100644 index 0000000..a4e464c --- /dev/null +++ b/device_validator/dvlib/tests/src/com/android/dvlib/devices_too_many_defaults.xml @@ -0,0 +1,140 @@ + + + + + + Galaxy Nexus + + + Samsung + + + + normal + 4.65 + xhdpi + long + + 720 + 1280 + + 316 + 316 + + jazz-hands + finger + capacitive + + + + Bluetooth + Wifi + NFC + + + Accelerometer + Barometer + Gyroscope + Compass + GPS + ProximitySensor + + true + + front + true + false + + + back + true + true + + nokeys + nonav + 1 + soft + 16 + + OMAP 4460 + PowerVR SGX540 + + armeabi + armeabi-v7a + + + + + + charge + + + 14 + true + + HSP + HFP + SPP + A2DP + AVRCP + OPP + PBAP + GAVDP + AVDTP + HID + HDP + PAN + + 2.0 + + + GL_EXT_discard_framebuffer + GL_EXT_multi_draw_arrays + GL_EXT_shader_texture_lod + GL_EXT_texture_format_BGRA8888 + GL_IMG_multisampled_render_to_texture + GL_IMG_program_binary + GL_IMG_read_format + GL_IMG_shader_binary + GL_IMG_texture_compression_pvrtc + GL_IMG_texture_format_BGRA8888 + GL_IMG_texture_npot + GL_OES_compressed_ETC1_RGB8_texture + GL_OES_depth_texture + GL_OES_depth24 + GL_OES_EGL_image + GL_OES_EGL_image_external + GL_OES_egl_sync + GL_OES_element_index_uint + GL_OES_fragment_precision_high + GL_OES_get_program_binary + GL_OES_mapbuffer + GL_OES_packed_depth_stencil + GL_OES_required_internalformat + GL_OES_rgb8_rgba8 + GL_OES_standard_derivatives + GL_OES_texture_float + GL_OES_texture_half_float + GL_OES_vertex_array_object + GL_OES_vertex_half_float + + + + The phone in portrait view + portrait + keyssoft + nonav + + + The phone in landscape view + landscape + keyssoft + nonav + + + diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/extras/frame.jpeg b/device_validator/dvlib/tests/src/com/android/dvlib/extras/frame.jpeg new file mode 100644 index 0000000..e69de29 diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/extras/frame.png b/device_validator/dvlib/tests/src/com/android/dvlib/extras/frame.png new file mode 100644 index 0000000..e69de29 diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixteen.jpeg b/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixteen.jpeg new file mode 100644 index 0000000..e69de29 diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixteen.png b/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixteen.png new file mode 100644 index 0000000..e69de29 diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixtyfour.jpeg b/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixtyfour.jpeg new file mode 100644 index 0000000..e69de29 diff --git a/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixtyfour.png b/device_validator/dvlib/tests/src/com/android/dvlib/extras/sixtyfour.png new file mode 100644 index 0000000..e69de29 -- cgit v1.1