Class DeviceSchema


  • public class DeviceSchema
    extends java.lang.Object
    • 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_GL_EXTENSIONS

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

        public static final java.lang.String NODE_REMOVABLE_STORAGE
        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_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_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_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_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_X_FOLDED_OFFSET

        public static final java.lang.String NODE_X_FOLDED_OFFSET
        See Also:
        Constant Field Values
      • NODE_Y_FOLDED_OFFSET

        public static final java.lang.String NODE_Y_FOLDED_OFFSET
        See Also:
        Constant Field Values
      • NODE_X_FOLDED_DIMENSION

        public static final java.lang.String NODE_X_FOLDED_DIMENSION
        See Also:
        Constant Field Values
      • NODE_Y_FOLDED_DIMENSION

        public static final java.lang.String NODE_Y_FOLDED_DIMENSION
        See Also:
        Constant Field Values
      • NODE_X_FOLDED_OFFSET_2

        public static final java.lang.String NODE_X_FOLDED_OFFSET_2
        See Also:
        Constant Field Values
      • NODE_Y_FOLDED_OFFSET_2

        public static final java.lang.String NODE_Y_FOLDED_OFFSET_2
        See Also:
        Constant Field Values
      • NODE_X_FOLDED_DIMENSION_2

        public static final java.lang.String NODE_X_FOLDED_DIMENSION_2
        See Also:
        Constant Field Values
      • NODE_Y_FOLDED_DIMENSION_2

        public static final java.lang.String NODE_Y_FOLDED_DIMENSION_2
        See Also:
        Constant Field Values
      • NODE_X_FOLDED_OFFSET_3

        public static final java.lang.String NODE_X_FOLDED_OFFSET_3
        See Also:
        Constant Field Values
      • NODE_Y_FOLDED_OFFSET_3

        public static final java.lang.String NODE_Y_FOLDED_OFFSET_3
        See Also:
        Constant Field Values
      • NODE_X_FOLDED_DIMENSION_3

        public static final java.lang.String NODE_X_FOLDED_DIMENSION_3
        See Also:
        Constant Field Values
      • NODE_Y_FOLDED_DIMENSION_3

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

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

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

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