com.android.dvlib
Class DeviceSchema

java.lang.Object
  extended by com.android.dvlib.DeviceSchema

public class DeviceSchema
extends java.lang.Object


Field Summary
static java.lang.String ATTR_DEFAULT
           
static java.lang.String ATTR_NAME
           
static java.lang.String ATTR_UNIT
           
static java.lang.String NODE_ABI
           
static java.lang.String NODE_API_LEVEL
           
static java.lang.String NODE_AUTOFOCUS
           
static java.lang.String NODE_BLUETOOTH_PROFILES
           
static java.lang.String NODE_BOOT_PROP
           
static java.lang.String NODE_BOOT_PROPS
           
static java.lang.String NODE_BUTTONS
           
static java.lang.String NODE_CAMERA
           
static java.lang.String NODE_CPU
           
static java.lang.String NODE_DESCRIPTION
           
static java.lang.String NODE_DEVICE
          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.
static java.lang.String NODE_DEVICES
          The "devices" element is the root element of this schema.
static java.lang.String NODE_DIAGONAL_LENGTH
           
static java.lang.String NODE_DIMENSIONS
           
static java.lang.String NODE_DOCK
           
static java.lang.String NODE_FLASH
           
static java.lang.String NODE_FRAME
           
static java.lang.String NODE_GL_EXTENSIONS
           
static java.lang.String NODE_GL_VERSION
           
static java.lang.String NODE_GPU
           
static java.lang.String NODE_HARDWARE
          The "hardware" element contains all of the hardware information for a given device.
static java.lang.String NODE_ICONS
           
static java.lang.String NODE_ID
           
static java.lang.String NODE_INTERNAL_STORAGE
           
static java.lang.String NODE_KEYBOARD
           
static java.lang.String NODE_KEYBOARD_STATE
           
static java.lang.String NODE_LANDSCAPE_X_OFFSET
           
static java.lang.String NODE_LANDSCAPE_Y_OFFSET
           
static java.lang.String NODE_LIVE_WALLPAPER_SUPPORT
           
static java.lang.String NODE_LOCATION
           
static java.lang.String NODE_MANUFACTURER
           
static java.lang.String NODE_MECHANISM
           
static java.lang.String NODE_META
           
static java.lang.String NODE_MIC
           
static java.lang.String NODE_MULTITOUCH
           
static java.lang.String NODE_NAME
           
static java.lang.String NODE_NAV
           
static java.lang.String NODE_NAV_STATE
           
static java.lang.String NODE_NETWORKING
           
static java.lang.String NODE_PATH
           
static java.lang.String NODE_PIXEL_DENSITY
           
static java.lang.String NODE_PORTRAIT_X_OFFSET
           
static java.lang.String NODE_PORTRAIT_Y_OFFSET
           
static java.lang.String NODE_POWER_TYPE
           
static java.lang.String NODE_PROP_NAME
           
static java.lang.String NODE_PROP_VALUE
           
static java.lang.String NODE_RAM
           
static java.lang.String NODE_REMOVABLE_STORAGE
           
static java.lang.String NODE_SCREEN
           
static java.lang.String NODE_SCREEN_ORIENTATION
           
static java.lang.String NODE_SCREEN_RATIO
           
static java.lang.String NODE_SCREEN_SIZE
           
static java.lang.String NODE_SCREEN_TYPE
           
static java.lang.String NODE_SENSORS
           
static java.lang.String NODE_SIXTEEN
           
static java.lang.String NODE_SIXTY_FOUR
           
static java.lang.String NODE_SOFTWARE
          The "software" element contains all of the software information for an API version of the given device.
static java.lang.String NODE_STATE
          The "state" element contains all of the parameters for a given state of the device.
static java.lang.String NODE_STATUS_BAR
           
static java.lang.String NODE_TAG_ID
           
static java.lang.String NODE_TOUCH
           
static java.lang.String NODE_X_DIMENSION
           
static java.lang.String NODE_XDPI
           
static java.lang.String NODE_Y_DIMENSION
           
static java.lang.String NODE_YDPI
           
static java.lang.String NS_DEVICES_URI
          The XML namespace of the latest device XML.
static int NS_LATEST_VERSION
          The latest version of the device XML Schema.
 
Constructor Summary
DeviceSchema()
           
 
Method Summary
static javax.xml.validation.Schema getSchema(int version)
          Helper method that returns a validator for a specific version of the XSD.
static java.lang.String getSchemaUri(int version)
          Returns the URI of the SDK Repository schema for the given version number.
static int getXmlSchemaVersion(java.io.InputStream xml)
          Manually parses the root element of the XML to extract the schema version at the end of the xmlns:sdk="http://schemas.android.com/sdk/devices/$N" declaration.
static java.io.InputStream getXsdStream(int version)
          Returns a stream to the requested device XML Schema.
static boolean validate(java.io.InputStream deviceXml, java.io.OutputStream out, java.io.File parent)
          Validates the input stream against the corresponding Devices XSD schema and then does a sanity check on the content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NS_LATEST_VERSION

public static final int NS_LATEST_VERSION
The latest version of the device XML Schema. Valid version numbers are between 1 and this number, included.

See Also:
Constant Field Values

NS_DEVICES_URI

public static final java.lang.String NS_DEVICES_URI
The XML namespace of the latest device XML.


NODE_DEVICES

public static final java.lang.String NODE_DEVICES
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.

See Also:
Constant Field Values

NODE_DEVICE

public static final java.lang.String NODE_DEVICE
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.

See Also:
Constant Field Values

NODE_HARDWARE

public static final java.lang.String NODE_HARDWARE
The "hardware" element contains all of the hardware information for a given device.

See Also:
Constant Field Values

NODE_SOFTWARE

public static final java.lang.String NODE_SOFTWARE
The "software" element contains all of the software information for an API version of the given device.

See Also:
Constant Field Values

NODE_STATE

public static final java.lang.String NODE_STATE
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.

See Also:
Constant Field Values

NODE_KEYBOARD

public static final java.lang.String NODE_KEYBOARD
See Also:
Constant Field Values

NODE_TOUCH

public static final java.lang.String NODE_TOUCH
See Also:
Constant Field Values

NODE_GL_EXTENSIONS

public static final java.lang.String NODE_GL_EXTENSIONS
See Also:
Constant Field Values

NODE_GL_VERSION

public static final java.lang.String NODE_GL_VERSION
See Also:
Constant Field Values

NODE_NETWORKING

public static final java.lang.String NODE_NETWORKING
See Also:
Constant Field Values

NODE_REMOVABLE_STORAGE

public static final java.lang.String NODE_REMOVABLE_STORAGE
See Also:
Constant Field Values

NODE_FLASH

public static final java.lang.String NODE_FLASH
See Also:
Constant Field Values

NODE_LIVE_WALLPAPER_SUPPORT

public static final java.lang.String NODE_LIVE_WALLPAPER_SUPPORT
See Also:
Constant Field Values

NODE_STATUS_BAR

public static final java.lang.String NODE_STATUS_BAR
See Also:
Constant Field Values

NODE_BUTTONS

public static final java.lang.String NODE_BUTTONS
See Also:
Constant Field Values

NODE_CAMERA

public static final java.lang.String NODE_CAMERA
See Also:
Constant Field Values

NODE_LOCATION

public static final java.lang.String NODE_LOCATION
See Also:
Constant Field Values

NODE_GPU

public static final java.lang.String NODE_GPU
See Also:
Constant Field Values

NODE_DOCK

public static final java.lang.String NODE_DOCK
See Also:
Constant Field Values

NODE_YDPI

public static final java.lang.String NODE_YDPI
See Also:
Constant Field Values

NODE_POWER_TYPE

public static final java.lang.String NODE_POWER_TYPE
See Also:
Constant Field Values

NODE_Y_DIMENSION

public static final java.lang.String NODE_Y_DIMENSION
See Also:
Constant Field Values

NODE_SCREEN_RATIO

public static final java.lang.String NODE_SCREEN_RATIO
See Also:
Constant Field Values

NODE_NAV_STATE

public static final java.lang.String NODE_NAV_STATE
See Also:
Constant Field Values

NODE_MIC

public static final java.lang.String NODE_MIC
See Also:
Constant Field Values

NODE_RAM

public static final java.lang.String NODE_RAM
See Also:
Constant Field Values

NODE_XDPI

public static final java.lang.String NODE_XDPI
See Also:
Constant Field Values

NODE_DIMENSIONS

public static final java.lang.String NODE_DIMENSIONS
See Also:
Constant Field Values

NODE_ABI

public static final java.lang.String NODE_ABI
See Also:
Constant Field Values

NODE_MECHANISM

public static final java.lang.String NODE_MECHANISM
See Also:
Constant Field Values

NODE_MULTITOUCH

public static final java.lang.String NODE_MULTITOUCH
See Also:
Constant Field Values

NODE_NAV

public static final java.lang.String NODE_NAV
See Also:
Constant Field Values

NODE_PIXEL_DENSITY

public static final java.lang.String NODE_PIXEL_DENSITY
See Also:
Constant Field Values

NODE_SCREEN_ORIENTATION

public static final java.lang.String NODE_SCREEN_ORIENTATION
See Also:
Constant Field Values

NODE_AUTOFOCUS

public static final java.lang.String NODE_AUTOFOCUS
See Also:
Constant Field Values

NODE_SCREEN_SIZE

public static final java.lang.String NODE_SCREEN_SIZE
See Also:
Constant Field Values

NODE_DESCRIPTION

public static final java.lang.String NODE_DESCRIPTION
See Also:
Constant Field Values

NODE_BLUETOOTH_PROFILES

public static final java.lang.String NODE_BLUETOOTH_PROFILES
See Also:
Constant Field Values

NODE_SCREEN

public static final java.lang.String NODE_SCREEN
See Also:
Constant Field Values

NODE_SENSORS

public static final java.lang.String NODE_SENSORS
See Also:
Constant Field Values

NODE_DIAGONAL_LENGTH

public static final java.lang.String NODE_DIAGONAL_LENGTH
See Also:
Constant Field Values

NODE_SCREEN_TYPE

public static final java.lang.String NODE_SCREEN_TYPE
See Also:
Constant Field Values

NODE_KEYBOARD_STATE

public static final java.lang.String NODE_KEYBOARD_STATE
See Also:
Constant Field Values

NODE_X_DIMENSION

public static final java.lang.String NODE_X_DIMENSION
See Also:
Constant Field Values

NODE_CPU

public static final java.lang.String NODE_CPU
See Also:
Constant Field Values

NODE_INTERNAL_STORAGE

public static final java.lang.String NODE_INTERNAL_STORAGE
See Also:
Constant Field Values

NODE_META

public static final java.lang.String NODE_META
See Also:
Constant Field Values

NODE_ICONS

public static final java.lang.String NODE_ICONS
See Also:
Constant Field Values

NODE_SIXTY_FOUR

public static final java.lang.String NODE_SIXTY_FOUR
See Also:
Constant Field Values

NODE_SIXTEEN

public static final java.lang.String NODE_SIXTEEN
See Also:
Constant Field Values

NODE_FRAME

public static final java.lang.String NODE_FRAME
See Also:
Constant Field Values

NODE_PATH

public static final java.lang.String NODE_PATH
See Also:
Constant Field Values

NODE_PORTRAIT_X_OFFSET

public static final java.lang.String NODE_PORTRAIT_X_OFFSET
See Also:
Constant Field Values

NODE_PORTRAIT_Y_OFFSET

public static final java.lang.String NODE_PORTRAIT_Y_OFFSET
See Also:
Constant Field Values

NODE_LANDSCAPE_X_OFFSET

public static final java.lang.String NODE_LANDSCAPE_X_OFFSET
See Also:
Constant Field Values

NODE_LANDSCAPE_Y_OFFSET

public static final java.lang.String NODE_LANDSCAPE_Y_OFFSET
See Also:
Constant Field Values

NODE_NAME

public static final java.lang.String NODE_NAME
See Also:
Constant Field Values

NODE_ID

public static final java.lang.String NODE_ID
See Also:
Constant Field Values

NODE_API_LEVEL

public static final java.lang.String NODE_API_LEVEL
See Also:
Constant Field Values

NODE_MANUFACTURER

public static final java.lang.String NODE_MANUFACTURER
See Also:
Constant Field Values

NODE_TAG_ID

public static final java.lang.String NODE_TAG_ID
See Also:
Constant Field Values

NODE_BOOT_PROPS

public static final java.lang.String NODE_BOOT_PROPS
See Also:
Constant Field Values

NODE_BOOT_PROP

public static final java.lang.String NODE_BOOT_PROP
See Also:
Constant Field Values

NODE_PROP_NAME

public static final java.lang.String NODE_PROP_NAME
See Also:
Constant Field Values

NODE_PROP_VALUE

public static final java.lang.String NODE_PROP_VALUE
See Also:
Constant Field Values

ATTR_DEFAULT

public static final java.lang.String ATTR_DEFAULT
See Also:
Constant Field Values

ATTR_UNIT

public static final java.lang.String ATTR_UNIT
See Also:
Constant Field Values

ATTR_NAME

public static final java.lang.String ATTR_NAME
See Also:
Constant Field Values
Constructor Detail

DeviceSchema

public DeviceSchema()
Method Detail

getSchemaUri

public static java.lang.String getSchemaUri(int version)
Returns the URI of the SDK Repository schema for the given version number.

Parameters:
version - Between 1 and NS_LATEST_VERSION included.

getXsdStream

public static java.io.InputStream getXsdStream(int version)
Returns a stream to the requested device XML Schema.

Parameters:
version - Between 1 and NS_LATEST_VERSION, included.
Returns:
An InputStream object for the local XSD file or null if there is no schema for the requested version.

validate

public static boolean validate(java.io.InputStream deviceXml,
                               java.io.OutputStream out,
                               java.io.File parent)
Validates the input stream against the corresponding Devices XSD schema and then does a sanity check on the content.

Parameters:
deviceXml - The XML InputStream to validate. The XML input stream must supports the mark/reset() methods (that is its InputStream.markSupported() must return true) and which mark has already been set to the beginning of the stream.
out - The OutputStream for error messages.
parent - The parent directory of the input stream.
Returns:
Whether the given input constitutes a valid devices file.

getSchema

@Nullable
public static javax.xml.validation.Schema getSchema(int version)
                                             throws org.xml.sax.SAXException
Helper method that returns a validator for a specific version of the XSD.

Parameters:
version - Between 1 and NS_LATEST_VERSION, included.
Returns:
A Schema validator or null.
Throws:
org.xml.sax.SAXException

getXmlSchemaVersion

public static int getXmlSchemaVersion(java.io.InputStream xml)
Manually parses the root element of the XML to extract the schema version at the end of the xmlns:sdk="http://schemas.android.com/sdk/devices/$N" declaration.

Parameters:
xml - An XML input stream that supports the mark/reset() methods (that is its InputStream.markSupported() must return true) and which mark has already been set to the beginning of the stream.
Returns:
1+ for a valid schema version or 0 if no schema could be found.