<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-->
  <xs:simpleType name="showType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="permissionType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="allowed"/>
      <xs:enumeration value="ask"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="opType">
    <xs:restriction base="xs:string">
        <xs:enumeration value= "android:coarse_location"/>
        <xs:enumeration value= "android:fine_location"/>
        <xs:enumeration value= "android:gps"/>
        <xs:enumeration value= "android:vibrate"/>
        <xs:enumeration value= "android:read_contacts"/>
        <xs:enumeration value= "android:write_contacts"/>
        <xs:enumeration value= "android:read_call_log"/>
        <xs:enumeration value= "android:write_call_log"/>
        <xs:enumeration value= "android:read_calendar"/>
        <xs:enumeration value= "android:write_calendar"/>
        <xs:enumeration value= "android:wifi_scan"/>
        <xs:enumeration value= "android:post_notification"/>
        <xs:enumeration value= "android:neighboring_cells"/>
        <xs:enumeration value= "android:call_phone"/>
        <xs:enumeration value= "android:read_sms"/>
        <xs:enumeration value= "android:write_sms"/>
        <xs:enumeration value= "android:receive_sms"/>
        <xs:enumeration value= "android:receive_emergecy_sms"/>
        <xs:enumeration value= "android:receive_mms"/>
        <xs:enumeration value= "android:receive_wap_push"/>
        <xs:enumeration value= "android:send_sms"/>
        <xs:enumeration value= "android:read_icc_sms"/>
        <xs:enumeration value= "android:write_icc_sms"/>
        <xs:enumeration value= "android:write_settings"/>
        <xs:enumeration value= "android:system_alert_window"/>
        <xs:enumeration value= "android:access_notifications"/>
        <xs:enumeration value= "android:camera"/>
        <xs:enumeration value= "android:record_audio"/>
        <xs:enumeration value= "android:play_audio"/>
        <xs:enumeration value= "android:read_clipboard"/>
        <xs:enumeration value= "android:write_clipboard"/>
        <xs:enumeration value= "android:take_media_buttons"/>
        <xs:enumeration value= "android:take_audio_focus"/>
        <xs:enumeration value= "android:audio_master_volume"/>
        <xs:enumeration value= "android:audio_voice_volume"/>
        <xs:enumeration value= "android:audio_ring_volume"/>
        <xs:enumeration value= "android:audio_media_volume"/>
        <xs:enumeration value= "android:audio_alarm_volume"/>
        <xs:enumeration value= "android:audio_notification_volume"/>
        <xs:enumeration value= "android:audio_bluetooth_volume"/>
        <xs:enumeration value= "android:wake_lock"/>
        <xs:enumeration value= "android:monitor_location"/>
        <xs:enumeration value= "android:monitor_high_power_location"/>
        <xs:enumeration value= "android:wifi_change"/>
        <xs:enumeration value= "android:bluetooth_change"/>
        <xs:enumeration value= "android:data_connect_change"/>
        <xs:enumeration value= "android:send_mms"/>
        <xs:enumeration value= "android:read_mms"/>
        <xs:enumeration value= "android:write_mms"/>
        <xs:enumeration value= "android:boot_completed"/>
        <xs:enumeration value= "android:nfc_change"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="appType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="system-app"/>
      <xs:enumeration value="user-app"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="appops-policy">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="user-app">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute type="permissionType" name="permission" use="required"/>
                <xs:attribute type="showType" name="show" use="required"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>

        <xs:element name="system-app">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute type="permissionType" name="permission" use="required"/>
                <xs:attribute type="showType" name="show" use="required"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>

        <xs:element name="application">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="pkg" maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="op" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute type="opType" name="name" use="required"/>
                            <xs:attribute type="permissionType" name="permission" use="required"/>
                            <xs:attribute type="showType" name="show" use="required"/>
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute type="xs:string" name="name" use="required"/>
                  <xs:attribute type="appType" name="type" use="required"/>
                  <xs:attribute type="permissionType" name="permission" use="optional"/>
                  <xs:attribute type="showType" name="show" use="optional"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

      </xs:sequence>
      <xs:attribute type="xs:byte" name="version"/>
    </xs:complexType>
  </xs:element>
</xs:schema>
