1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3  ~ Copyright (C) 2021 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<!-- This file contains comments that define constraints that cannot be covered by the XSD language -->
18<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
19            version="1.0">
20
21    <xsd:element name="safety-center-config" type="safety-center-config"/>
22
23    <xsd:complexType name="safety-center-config">
24        <xsd:sequence>
25            <xsd:element name="safety-sources-config" type="safety-sources-config"/>
26        </xsd:sequence>
27    </xsd:complexType>
28
29    <xsd:complexType name="safety-sources-config">
30        <xsd:sequence>
31            <xsd:element
32                name="safety-sources-group" type="safety-sources-group"
33                minOccurs="1" maxOccurs="unbounded"/>
34        </xsd:sequence>
35    </xsd:complexType>
36
37    <xsd:complexType name="safety-sources-group">
38        <xsd:choice minOccurs="1" maxOccurs="unbounded">
39            <xsd:element name="dynamic-safety-source" type="dynamic-safety-source"/>
40            <xsd:element name="static-safety-source" type="static-safety-source"/>
41            <xsd:element name="issue-only-safety-source" type="issue-only-safety-source"/>
42        </xsd:choice>
43        <!-- id must be unique among safety sources groups -->
44        <xsd:attribute name="id" type="idOrStringResourceName" use="required"/>
45        <!-- title is required unless the group contains issue only and/or internal sources -->
46        <xsd:attribute name="title" type="runtimeStringResourceName"/>
47        <xsd:attribute name="summary" type="runtimeStringResourceName"/>
48        <xsd:attribute name="statelessIconType" type="statelessIconTypeOrStringResourceName"
49                       default="none"/>
50    </xsd:complexType>
51
52    <xsd:complexType name="dynamic-safety-source">
53        <!-- id must be unique among safety sources -->
54        <xsd:attribute name="id" type="idOrStringResourceName" use="required"/>
55        <xsd:attribute name="packageName" type="stringOrStringResourceName" use="required"/>
56        <!-- title is required if initialDisplayState is not set to hidden or if searchTerms are provided -->
57        <xsd:attribute name="title" type="runtimeStringResourceName"/>
58        <!-- titleForWork is required if profile is set to all_profiles, and initialDisplayState is not set to hidden or if searchTerms are provided -->
59        <!-- titleForWork is prohibited if profile is set to primary_profile_only -->
60        <xsd:attribute name="titleForWork" type="runtimeStringResourceName"/>
61        <!-- summary is required if initialDisplayState is not set to hidden -->
62        <xsd:attribute name="summary" type="runtimeStringResourceName"/>
63        <!-- intentAction is required if initialDisplayState is set to enabled -->
64        <xsd:attribute name="intentAction" type="stringOrStringResourceName"/>
65        <xsd:attribute name="profile" type="profile" use="required"/>
66        <xsd:attribute name="initialDisplayState" type="initialDisplayStateOrStringResourceName"
67                       default="enabled"/>
68        <xsd:attribute name="maxSeverityLevel" type="intOrStringResourceName" default="2147483647"/>
69        <xsd:attribute name="searchTerms" type="runtimeStringResourceName"/>
70        <xsd:attribute name="loggingAllowed" type="booleanOrStringResourceName" default="true"/>
71        <xsd:attribute name="refreshOnPageOpenAllowed" type="booleanOrStringResourceName"
72                       default="false"/>
73    </xsd:complexType>
74
75    <xsd:complexType name="issue-only-safety-source">
76        <!-- id must be unique among safety sources -->
77        <xsd:attribute name="id" type="idOrStringResourceName" use="required"/>
78        <xsd:attribute name="packageName" type="stringOrStringResourceName" use="required"/>
79        <xsd:attribute name="profile" type="profileOrStringResourceName" use="required"/>
80        <xsd:attribute name="maxSeverityLevel" type="intOrStringResourceName" default="2147483647"/>
81        <xsd:attribute name="loggingAllowed" type="booleanOrStringResourceName" default="true"/>
82        <xsd:attribute name="refreshOnPageOpenAllowed" type="booleanOrStringResourceName"
83                       default="false"/>
84    </xsd:complexType>
85
86    <xsd:complexType name="static-safety-source">
87        <!-- id must be unique among safety sources -->
88        <xsd:attribute name="id" type="idOrStringResourceName" use="required"/>
89        <xsd:attribute name="title" type="runtimeStringResourceName" use="required"/>
90        <!-- titleForWork is required if profile is set to all_profiles -->
91        <!-- titleForWork is prohibited if profile is set to primary_profile_only -->
92        <xsd:attribute name="titleForWork" type="runtimeStringResourceName"/>
93        <xsd:attribute name="summary" type="runtimeStringResourceName"/>
94        <xsd:attribute name="intentAction" type="stringOrStringResourceName" use="required"/>
95        <xsd:attribute name="profile" type="profileOrStringResourceName" use="required"/>
96        <xsd:attribute name="searchTerms" type="runtimeStringResourceName"/>
97    </xsd:complexType>
98
99    <xsd:simpleType name="intOrStringResourceName">
100        <!-- String resource names will be resolved only once at parse time. -->
101        <!-- Locale changes and device config changes will be ignored. -->
102        <!-- The value of the string resource must be of type xsd:int. -->
103        <xsd:union memberTypes="stringResourceName xsd:int"/>
104    </xsd:simpleType>
105
106    <xsd:simpleType name="booleanOrStringResourceName">
107        <!-- String resource names will be resolved only once at parse time. -->
108        <!-- Locale changes and device config changes will be ignored. -->
109        <!-- The value of the string resource must be of type xsd:boolean. -->
110        <xsd:union memberTypes="stringResourceName xsd:boolean"/>
111    </xsd:simpleType>
112
113    <xsd:simpleType name="stringOrStringResourceName">
114        <!-- String resource names will be resolved only once at parse time. -->
115        <!-- Locale changes and device config changes will be ignored. -->
116        <!-- The value of the string resource must be of type xsd:string. -->
117        <xsd:union memberTypes="stringResourceName xsd:string"/>
118    </xsd:simpleType>
119
120    <xsd:simpleType name="idOrStringResourceName">
121        <!-- String resource names will be resolved only once at parse time. -->
122        <!-- Locale changes and device config changes will be ignored. -->
123        <!-- The value of the string resource must be of type xsd:string. -->
124        <xsd:union memberTypes="stringResourceName id"/>
125    </xsd:simpleType>
126
127    <xsd:simpleType name="id">
128        <xsd:restriction base="xsd:string">
129            <xsd:pattern value="[0-9a-zA-Z_-]+"/>
130        </xsd:restriction>
131    </xsd:simpleType>
132
133    <xsd:simpleType name="statelessIconTypeOrStringResourceName">
134        <!-- String resource names will be resolved only once at parse time. -->
135        <!-- Locale changes and device config changes will be ignored. -->
136        <!-- The value of the string resource must be of type statelessIconType. -->
137        <xsd:union memberTypes="stringResourceName statelessIconType"/>
138    </xsd:simpleType>
139
140    <xsd:simpleType name="statelessIconType">
141        <xsd:restriction base="xsd:string">
142            <xsd:enumeration value="none"/>
143            <xsd:enumeration value="privacy"/>
144        </xsd:restriction>
145    </xsd:simpleType>
146
147    <xsd:simpleType name="profileOrStringResourceName">
148        <!-- String resource names will be resolved only once at parse time. -->
149        <!-- Locale changes and device config changes will be ignored. -->
150        <!-- The value of the string resource must be of type profile. -->
151        <xsd:union memberTypes="stringResourceName profile"/>
152    </xsd:simpleType>
153
154    <xsd:simpleType name="profile">
155        <xsd:restriction base="xsd:string">
156            <xsd:enumeration value="primary_profile_only"/>
157            <xsd:enumeration value="all_profiles"/>
158        </xsd:restriction>
159    </xsd:simpleType>
160
161    <xsd:simpleType name="initialDisplayStateOrStringResourceName">
162        <!-- String resource names will be resolved only once at parse time. -->
163        <!-- Locale changes and device config changes will be ignored. -->
164        <!-- The value of the string resource must be of type initialDisplayState. -->
165        <xsd:union memberTypes="stringResourceName initialDisplayState"/>
166    </xsd:simpleType>
167
168    <xsd:simpleType name="initialDisplayState">
169        <xsd:restriction base="xsd:string">
170            <xsd:enumeration value="enabled"/>
171            <xsd:enumeration value="disabled"/>
172            <xsd:enumeration value="hidden"/>
173        </xsd:restriction>
174    </xsd:simpleType>
175
176    <xsd:simpleType name="runtimeStringResourceName">
177        <!-- String resource names will be resolved at runtime whenever the string value is used. -->
178        <xsd:union memberTypes="stringResourceName"/>
179    </xsd:simpleType>
180
181    <!-- String resource names will be ignored for any attribute not directly or indirectly marked as stringResourceName. -->
182    <!-- A stringResourceName is a fully qualified resource name of the form "@package:string/entry". Package is required. -->
183    <xsd:simpleType name="stringResourceName">
184        <xsd:restriction base="xsd:string">
185            <xsd:pattern value="@([a-z]+\.)*[a-z]+:string/.+"/>
186        </xsd:restriction>
187    </xsd:simpleType>
188
189</xsd:schema>
190