1<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2<!-- Copyright (C) 2019 The Android Open Source Project
3
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7
8          http://www.apache.org/licenses/LICENSE-2.0
9
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15     -->
16
17 <xs:schema version="2.0"
18            elementFormDefault="qualified"
19            attributeFormDefault="unqualified"
20            xmlns:xs="http://www.w3.org/2001/XMLSchema">
21    <!-- List the config versions supported by audio policy engine. -->
22    <xs:simpleType name="version">
23        <xs:restriction base="xs:decimal">
24            <xs:enumeration value="1.0"/>
25        </xs:restriction>
26    </xs:simpleType>
27
28    <xs:element name="configuration">
29        <xs:complexType>
30            <xs:sequence>
31                <xs:element name="ProductStrategies" type="ProductStrategies"  minOccurs="0" maxOccurs="unbounded"/>
32                <xs:element name="criterion_types" type="criterionTypesType"  minOccurs="0" maxOccurs="unbounded"/>
33                <xs:element name="criteria" type="criteriaType"  minOccurs="0" maxOccurs="unbounded"/>
34                <xs:element name="volumeGroups" type="volumeGroupsType"  minOccurs="0" maxOccurs="unbounded"/>
35                <xs:element name="volumes" type="volumesType" minOccurs="0" maxOccurs="unbounded"/>
36                <xs:element name="attributesRef" type="attributesRef"  minOccurs="0" maxOccurs="unbounded"/>
37            </xs:sequence>
38            <xs:attribute name="version" type="version" use="required"/>
39        </xs:complexType>
40
41        <xs:key name="volumeCurveNameKey">
42            <xs:selector xpath="volumes/reference"/>
43            <xs:field xpath="@name"/>
44        </xs:key>
45        <xs:keyref name="volumeCurveRef" refer="volumeCurveNameKey">
46            <xs:selector xpath="volumeGroups/volumeGroup"/>
47            <xs:field xpath="@ref"/>
48        </xs:keyref>
49
50        <xs:key name="attributesRefNameKey">
51            <xs:selector xpath="attributesRef/reference"/>
52            <xs:field xpath="@name"/>
53        </xs:key>
54        <xs:keyref name="volumeGroupAttributesRef" refer="attributesRefNameKey">
55            <xs:selector xpath="volumeGroups/volumeGroup/volume"/>
56            <xs:field xpath="@attributesRef"/>
57        </xs:keyref>
58        <xs:keyref name="ProductStrategyAttributesRef" refer="attributesRefNameKey">
59            <xs:selector xpath="ProductStrategies/ProductStrategy/Attributes"/>
60            <xs:field xpath="@attributesRef"/>
61        </xs:keyref>
62
63        <xs:unique name="productStrategyNameUniqueness">
64            <xs:selector xpath="ProductStrategies/ProductStrategy"/>
65            <xs:field xpath="@name"/>
66        </xs:unique>
67
68        <!-- ensure validity of volume group referred in product strategy-->
69        <xs:key name="volumeGroupKey">
70            <xs:selector xpath="volumeGroups/volumeGroup/name"/>
71            <xs:field xpath="."/>
72        </xs:key>
73        <xs:keyref name="volumeGroupRef" refer="volumeGroupKey">
74            <xs:selector xpath="ProductStrategies/ProductStrategy/AttributesGroup"/>
75            <xs:field xpath="@volumeGroup"/>
76        </xs:keyref>
77
78        <xs:unique name="volumeTargetUniqueness">
79            <xs:selector xpath="volumeGroups/volumeGroup"/>
80            <xs:field xpath="@name"/>
81            <xs:field xpath="@deviceCategory"/>
82        </xs:unique>
83
84        <!-- ensure validity of criterion type referred in criterion-->
85        <xs:key name="criterionTypeKey">
86            <xs:selector xpath="criterion_types/criterion_type"/>
87            <xs:field xpath="@name"/>
88        </xs:key>
89        <xs:keyref name="criterionTypeKeyRef" refer="criterionTypeKey">
90            <xs:selector xpath="criteria/criterion"/>
91            <xs:field xpath="@type"/>
92        </xs:keyref>
93
94    </xs:element>
95
96    <xs:complexType name="ProductStrategies">
97        <xs:annotation>
98            <xs:documentation xml:lang="en">
99            </xs:documentation>
100        </xs:annotation>
101        <xs:sequence>
102            <xs:element name="ProductStrategy" maxOccurs="unbounded">
103                <xs:complexType>
104                    <xs:sequence>
105                        <xs:element name="AttributesGroup" type="AttributesGroup" minOccurs="1" maxOccurs="unbounded"/>
106                    </xs:sequence>
107                    <xs:attribute name="name" type="xs:string" use="required"/>
108                </xs:complexType>
109            </xs:element>
110        </xs:sequence>
111    </xs:complexType>
112
113    <xs:complexType name="AttributesGroup">
114        <xs:sequence>
115            <xs:choice minOccurs="0">
116                <xs:element name="Attributes" type="AttributesType" minOccurs="1" maxOccurs="unbounded"/>
117                <xs:sequence>
118                    <xs:element name="ContentType" type="ContentTypeType" minOccurs="0" maxOccurs="1"/>
119                    <xs:element name="Usage" type="UsageType" minOccurs="1" maxOccurs="1"/>
120                    <xs:element name="Source" type="SourceType" minOccurs="0" maxOccurs="1"/>
121                    <xs:element name="Flags" type="FlagsType" minOccurs="0" maxOccurs="1"/>
122                    <xs:element name="Bundle" type="BundleType" minOccurs="0" maxOccurs="1"/>
123                </xs:sequence>
124            </xs:choice>
125        </xs:sequence>
126        <xs:attribute name="streamType" type="stream" use="optional"/>
127        <xs:attribute name="volumeGroup" type="xs:string" use="optional"/>
128    </xs:complexType>
129
130    <xs:complexType name="volumeGroupsType">
131        <xs:sequence>
132             <xs:element name="volumeGroup" minOccurs="0" maxOccurs="unbounded">
133                <xs:complexType>
134                    <xs:sequence>
135                         <xs:element name="name" type="xs:token"/>
136                         <xs:element name="indexMin" type="xs:int" minOccurs="0" maxOccurs="1"/>
137                         <xs:element name="indexMax" type="xs:int" minOccurs="0" maxOccurs="1"/>
138                         <xs:element name="volume" type="volume" minOccurs="1" maxOccurs="unbounded"/>
139                     </xs:sequence>
140                </xs:complexType>
141                <xs:unique name="volumeAttributesUniqueness">
142                    <xs:selector xpath="volume"/>
143                    <xs:field xpath="deviceCategory"/>
144                </xs:unique>
145             </xs:element>
146        </xs:sequence>
147    </xs:complexType>
148
149    <xs:complexType name="volumesType">
150        <xs:sequence>
151            <xs:element name="reference" type="volumeRef" minOccurs="0" maxOccurs="unbounded"/>
152        </xs:sequence>
153    </xs:complexType>
154
155    <xs:complexType name="attributesRef">
156        <xs:sequence>
157            <xs:element name="reference" type="attributesRefType" minOccurs="0" maxOccurs="unbounded"/>
158        </xs:sequence>
159    </xs:complexType>
160
161    <xs:complexType name="criteriaType">
162        <xs:sequence>
163            <xs:element name="criterion" type="criterionType" maxOccurs="unbounded"/>
164        </xs:sequence>
165    </xs:complexType>
166    <xs:complexType name="criterionType">
167        <xs:attribute name="name" type="xs:string" use="required"/>
168        <xs:attribute name="type" type="xs:string" use="required"/>
169        <xs:attribute name="default" type="xs:string" use="optional"/>
170    </xs:complexType>
171
172    <xs:complexType name="criterionTypesType">
173        <xs:sequence>
174            <xs:element name="criterion_type" type="criterionTypeType" maxOccurs="unbounded"/>
175        </xs:sequence>
176    </xs:complexType>
177    <xs:complexType name="criterionTypeType">
178        <xs:sequence>
179            <xs:element name="values" type="valuesType" minOccurs="0" maxOccurs="1"/>
180        </xs:sequence>
181        <xs:attribute name="name" type="xs:token" use="required"/>
182        <xs:attribute name="type" type="pfwCriterionTypeEnum" use="required"/>
183    </xs:complexType>
184
185    <xs:complexType name="valuesType">
186        <xs:sequence>
187            <xs:element name="value" type="valueType" maxOccurs="unbounded"/>
188        </xs:sequence>
189    </xs:complexType>
190    <xs:complexType name="valueType">
191        <xs:attribute name="literal" type="xs:string" use="required"/>
192        <xs:attribute name="numerical" type="xs:int" use="required"/>
193    </xs:complexType>
194
195    <xs:complexType name="attributesRefType">
196        <xs:sequence>
197            <xs:element name="Attributes" type="AttributesType" minOccurs="1" maxOccurs="1"/>
198        </xs:sequence>
199        <xs:attribute name="name" type="xs:token" use="required"/>
200    </xs:complexType>
201
202    <xs:complexType name="AttributesType">
203        <xs:sequence>
204            <xs:element name="ContentType" type="ContentTypeType" minOccurs="0" maxOccurs="1"/>
205            <xs:element name="Usage" type="UsageType" minOccurs="0" maxOccurs="1"/>
206            <xs:element name="Source" type="SourceType" minOccurs="0" maxOccurs="1"/>
207            <xs:element name="Flags" type="FlagsType" minOccurs="0" maxOccurs="1"/>
208            <xs:element name="Bundle" type="BundleType" minOccurs="0" maxOccurs="1"/>
209        </xs:sequence>
210        <xs:attribute name="attributesRef" type="xs:token" use="optional"/>
211        <!-- with xsd 1.1, it is impossible to make choice on either attributes or element...-->
212    </xs:complexType>
213
214    <xs:complexType name="ContentTypeType">
215        <xs:attribute name="value" type="contentType" use="required"/>
216    </xs:complexType>
217    <xs:complexType name="UsageType">
218        <xs:attribute name="value" type="usageEnumType" use="required"/>
219    </xs:complexType>
220    <xs:complexType name="SourceType">
221        <xs:attribute name="value" type="sourceEnumType" use="required"/>
222    </xs:complexType>
223    <xs:complexType name="FlagsType">
224        <xs:attribute name="value" type="flagsEnumType" use="required"/>
225    </xs:complexType>
226    <xs:complexType name="BundleType">
227        <xs:attribute name="key" type="xs:string" use="required"/>
228        <xs:attribute name="value" type="xs:string" use="required"/>
229    </xs:complexType>
230
231    <xs:complexType name="volume">
232        <xs:annotation>
233            <xs:documentation xml:lang="en">
234                Volume section defines a volume curve for a given use case and device category.
235                It contains a list of points of this curve expressing the attenuation in Millibels
236                for a given volume index from 0 to 100.
237                <volume deviceCategory="DEVICE_CATEGORY_SPEAKER">
238                    <point>0,-9600</point>
239                    <point>100,0</point>
240                </volume>
241
242                It may also reference a reference/@name to avoid duplicating curves.
243                <volume deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_MEDIA_VOLUME_CURVE"/>
244                <reference name="DEFAULT_MEDIA_VOLUME_CURVE">
245                    <point>0,-9600</point>
246                    <point>100,0</point>
247                </reference>
248            </xs:documentation>
249        </xs:annotation>
250        <xs:sequence>
251            <xs:element name="point" type="volumePoint" minOccurs="0" maxOccurs="unbounded"/>
252        </xs:sequence>
253        <xs:attribute name="deviceCategory" type="deviceCategory"/>
254        <xs:attribute name="ref" type="xs:token" use="optional"/>
255    </xs:complexType>
256
257    <xs:complexType name="volumeRef">
258        <xs:sequence>
259            <xs:element name="point" type="volumePoint" minOccurs="2" maxOccurs="unbounded"/>
260        </xs:sequence>
261        <xs:attribute name="name" type="xs:token" use="required"/>
262    </xs:complexType>
263
264    <xs:simpleType name="volumePoint">
265        <xs:annotation>
266            <xs:documentation xml:lang="en">
267                Comma separated pair of number.
268                The fist one is the framework level (between 0 and 100).
269                The second one is the volume to send to the HAL.
270                The framework will interpolate volumes not specified.
271                Their MUST be at least 2 points specified.
272            </xs:documentation>
273        </xs:annotation>
274        <xs:restriction base="xs:string">
275            <xs:pattern value="([0-9]{1,2}|100),-?[0-9]+"/>
276        </xs:restriction>
277    </xs:simpleType>
278
279
280    <xs:simpleType name="streamsCsv">
281        <xs:list>
282            <xs:simpleType>
283                <xs:restriction base="stream">
284                </xs:restriction>
285            </xs:simpleType>
286        </xs:list>
287    </xs:simpleType>
288
289    <!-- Enum values of audio_stream_type_t in audio-base.h
290         TODO: avoid manual sync. -->
291    <xs:simpleType name="stream">
292        <xs:restriction base="xs:NMTOKEN">
293            <!--xs:pattern value="\c+(,\c+)*"/-->
294            <xs:enumeration value="AUDIO_STREAM_DEFAULT"/>
295            <xs:enumeration value="AUDIO_STREAM_VOICE_CALL"/>
296            <xs:enumeration value="AUDIO_STREAM_SYSTEM"/>
297            <xs:enumeration value="AUDIO_STREAM_RING"/>
298            <xs:enumeration value="AUDIO_STREAM_MUSIC"/>
299            <xs:enumeration value="AUDIO_STREAM_ALARM"/>
300            <xs:enumeration value="AUDIO_STREAM_NOTIFICATION"/>
301            <xs:enumeration value="AUDIO_STREAM_BLUETOOTH_SCO"/>
302            <xs:enumeration value="AUDIO_STREAM_ENFORCED_AUDIBLE"/>
303            <xs:enumeration value="AUDIO_STREAM_DTMF"/>
304            <xs:enumeration value="AUDIO_STREAM_TTS"/>
305            <xs:enumeration value="AUDIO_STREAM_ACCESSIBILITY"/>
306            <xs:enumeration value="AUDIO_STREAM_ASSISTANT"/>
307        </xs:restriction>
308    </xs:simpleType>
309
310    <xs:simpleType name="deviceCategory">
311        <xs:restriction base="xs:string">
312            <xs:enumeration value="DEVICE_CATEGORY_HEADSET"/>
313            <xs:enumeration value="DEVICE_CATEGORY_SPEAKER"/>
314            <xs:enumeration value="DEVICE_CATEGORY_EARPIECE"/>
315            <xs:enumeration value="DEVICE_CATEGORY_EXT_MEDIA"/>
316            <xs:enumeration value="DEVICE_CATEGORY_HEARING_AID"/>
317        </xs:restriction>
318    </xs:simpleType>
319
320    <xs:simpleType name="contentType">
321        <xs:restriction base="xs:string">
322            <xs:enumeration value="AUDIO_CONTENT_TYPE_UNKNOWN"/>
323            <xs:enumeration value="AUDIO_CONTENT_TYPE_SPEECH"/>
324            <xs:enumeration value="AUDIO_CONTENT_TYPE_MUSIC"/>
325            <xs:enumeration value="AUDIO_CONTENT_TYPE_MOVIE"/>
326            <xs:enumeration value="AUDIO_CONTENT_TYPE_SONIFICATION"/>
327        </xs:restriction>
328    </xs:simpleType>
329
330    <xs:simpleType name="usageEnumType">
331        <xs:restriction base="xs:string">
332            <xs:enumeration value="AUDIO_USAGE_UNKNOWN"/>
333            <xs:enumeration value="AUDIO_USAGE_MEDIA"/>
334            <xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION"/>
335            <xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING"/>
336            <xs:enumeration value="AUDIO_USAGE_ALARM"/>
337            <xs:enumeration value="AUDIO_USAGE_NOTIFICATION"/>
338            <xs:enumeration value="AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE"/>
339            <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY"/>
340            <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE"/>
341            <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_SONIFICATION"/>
342            <xs:enumeration value="AUDIO_USAGE_GAME"/>
343            <xs:enumeration value="AUDIO_USAGE_VIRTUAL_SOURCE"/>
344            <xs:enumeration value="AUDIO_USAGE_ASSISTANT"/>
345            <xs:enumeration value="AUDIO_USAGE_CALL_ASSISTANT"/>
346        </xs:restriction>
347    </xs:simpleType>
348
349    <xs:simpleType name="flagsEnumType">
350        <xs:list>
351            <xs:simpleType>
352                <xs:restriction base="flagType">
353                </xs:restriction>
354            </xs:simpleType>
355        </xs:list>
356    </xs:simpleType>
357
358    <xs:simpleType name="flagType">
359        <xs:restriction base="xs:NMTOKEN">
360            <xs:enumeration value="AUDIO_FLAG_NONE"/>
361            <xs:enumeration value="AUDIO_FLAG_AUDIBILITY_ENFORCED"/>
362            <xs:enumeration value="AUDIO_FLAG_SECURE"/>
363            <xs:enumeration value="AUDIO_FLAG_SCO"/>
364            <xs:enumeration value="AUDIO_FLAG_BEACON"/>
365            <xs:enumeration value="AUDIO_FLAG_HW_AV_SYNC"/>
366            <xs:enumeration value="AUDIO_FLAG_HW_HOTWORD"/>
367            <xs:enumeration value="AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY"/>
368            <xs:enumeration value="AUDIO_FLAG_BYPASS_MUTE"/>
369            <xs:enumeration value="AUDIO_FLAG_LOW_LATENCY"/>
370            <xs:enumeration value="AUDIO_FLAG_DEEP_BUFFER"/>
371            <xs:enumeration value="AUDIO_FLAG_NO_MEDIA_PROJECTION"/>
372            <xs:enumeration value="AUDIO_FLAG_MUTE_HAPTIC"/>
373            <xs:enumeration value="AUDIO_FLAG_NO_SYSTEM_CAPTURE"/>
374            <xs:enumeration value="AUDIO_FLAG_CAPTURE_PRIVATE"/>
375        </xs:restriction>
376    </xs:simpleType>
377
378    <xs:simpleType name="sourceEnumType">
379        <xs:restriction base="xs:string">
380            <xs:enumeration value="AUDIO_SOURCE_DEFAULT"/>
381            <xs:enumeration value="AUDIO_SOURCE_MIC"/>
382            <xs:enumeration value="AUDIO_SOURCE_VOICE_UPLINK"/>
383            <xs:enumeration value="AUDIO_SOURCE_VOICE_DOWNLINK"/>
384            <xs:enumeration value="AUDIO_SOURCE_VOICE_CALL"/>
385            <xs:enumeration value="AUDIO_SOURCE_CAMCORDER"/>
386            <xs:enumeration value="AUDIO_SOURCE_VOICE_RECOGNITION"/>
387            <xs:enumeration value="AUDIO_SOURCE_VOICE_COMMUNICATION"/>
388            <xs:enumeration value="AUDIO_SOURCE_REMOTE_SUBMIX"/>
389            <xs:enumeration value="AUDIO_SOURCE_UNPROCESSED"/>
390            <xs:enumeration value="AUDIO_SOURCE_VOICE_PERFORMANCE"/>
391            <xs:enumeration value="AUDIO_SOURCE_ECHO_REFERENCE"/>
392            <xs:enumeration value="AUDIO_SOURCE_FM_TUNER"/>
393        </xs:restriction>
394    </xs:simpleType>
395
396    <xs:simpleType name="pfwCriterionTypeEnum">
397        <xs:restriction base="xs:string">
398            <xs:enumeration value="inclusive"/>
399            <xs:enumeration value="exclusive"/>
400        </xs:restriction>
401    </xs:simpleType>
402</xs:schema>
403