1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3  ~ Copyright (C) 2020 The Android Open Source Project
4  ~
5  ~ Licensed under the Apache License, Version 2.0 (the "License");
6  ~ you may not use this file except in compliance with the License.
7  ~ You may obtain a copy of the License at
8  ~
9  ~      http://www.apache.org/licenses/LICENSE-2.0
10  ~
11  ~ Unless required by applicable law or agreed to in writing, software
12  ~ distributed under the License is distributed on an "AS IS" BASIS,
13  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  ~ See the License for the specific language governing permissions and
15  ~ limitations under the License.
16  -->
17
18<xs:schema version="2.0"
19           elementFormDefault="qualified"
20           xmlns:xs="http://www.w3.org/2001/XMLSchema">
21
22    <xs:element name="device-state-config">
23        <xs:complexType>
24            <xs:sequence>
25                <xs:element name="device-state" type="deviceState" maxOccurs="256" />
26            </xs:sequence>
27        </xs:complexType>
28    </xs:element>
29
30    <xs:complexType name="deviceState">
31        <xs:sequence>
32            <xs:element name="identifier">
33                <xs:simpleType>
34                    <xs:restriction base="xs:integer">
35                        <xs:minInclusive value="0" />
36                        <xs:maxInclusive value="255" />
37                    </xs:restriction>
38                </xs:simpleType>
39            </xs:element>
40            <xs:element name="name" type="xs:string" minOccurs="0">
41                <xs:annotation name="nullable" />
42            </xs:element>
43            <xs:element name="flags" type="flags" />
44            <xs:element name="conditions" type="conditions" />
45        </xs:sequence>
46    </xs:complexType>
47
48    <xs:complexType name="flags">
49        <xs:sequence>
50            <xs:element name="flag" type="xs:string" minOccurs="0" maxOccurs="unbounded">
51                <xs:annotation name="nullable" />
52            </xs:element>
53        </xs:sequence>
54    </xs:complexType>
55
56    <xs:complexType name="conditions">
57        <xs:sequence>
58            <xs:element name="lid-switch" type="lidSwitchCondition" minOccurs="0">
59                <xs:annotation name="nullable" />
60            </xs:element>
61            <xs:element name="sensor" type="sensorCondition" minOccurs="0" maxOccurs="unbounded">
62                <xs:annotation name="nullable" />
63            </xs:element>
64        </xs:sequence>
65    </xs:complexType>
66
67    <xs:complexType name="lidSwitchCondition">
68        <xs:sequence>
69            <xs:element name="open" type="xs:boolean" />
70        </xs:sequence>
71    </xs:complexType>
72
73    <xs:complexType name="sensorCondition">
74        <xs:sequence>
75            <xs:element name="type" type="xs:string" />
76            <xs:element name="name" type="xs:string" />
77            <xs:element name="value" type="numericRange" maxOccurs="unbounded" />
78        </xs:sequence>
79    </xs:complexType>
80
81    <xs:complexType name="numericRange">
82        <xs:sequence>
83            <xs:choice minOccurs="0">
84                <xs:element name="min" type="xs:decimal">
85                    <xs:annotation name="nullable" />
86                </xs:element>
87                <xs:element name="min-inclusive" type="xs:decimal">
88                    <xs:annotation name="nullable" />
89                </xs:element>
90            </xs:choice>
91            <xs:choice minOccurs="0">
92                <xs:element name="max" type="xs:decimal">
93                    <xs:annotation name="nullable" />
94                </xs:element>
95                <xs:element name="max-inclusive" type="xs:decimal">
96                    <xs:annotation name="nullable" />
97                </xs:element>
98            </xs:choice>
99        </xs:sequence>
100    </xs:complexType>
101</xs:schema>
102