<?xml version="1.0" encoding="utf-8"?>

<!--
This XML allows OEMs to configure a driving state to UX restrictions.  There are 2 major classes
of configuration:
1. Restriction Mapping as defined by the <RestrictionMapping> tag.
2. Restriction Parameters for restrictions that can be parametrized as defined by
   <RestrictionParameters> tag.

Note:
   The tags and attributes are declared in
   packages/services/Car/service/src/com/android/car/CarUxRestrictionsConfigurationXmlParser.java
   Supported tags and attribute for each tag -
       - UxRestrictions (Starting tag, defines the UX restrictions to be imposed for different
       driving states of a vehicle)
       - RestrictionMapping (Tag 1. UX restriction Mapping from a driving state of the vehicle)
             - physicalPort (Attribute. Physical port that connects
             to a display. Restrictions defined will apply to the display that connects to this
             port. Only the lowest byte in the integer value is used. The value should be
             interpreted as an signed int, namely the supported range is [-128, 127].
             Optional field. 'physicalPort' is one way of specifying a display in the context of
             UX restrictions. The combination of 'occupantZoneId' and 'displayType' is another way
             of identifying a display. When 'physicalPort' is specified, 'occupantZoneId and
             'displayType' should not be specified. If neither 'physicalPort' nor the combination
             of 'occupantZoneId' and 'displayType' is specified, it defaults to the driver main
             display. )
             - occupantZoneId (Attribute. The id of the car occupant zone this display is in.
             Optional field. The combination of 'occupantZoneId and 'displayType' is another way of
             identifying a display. When 'occupantZoneId' is specified, 'displayType' should also
             be specified while 'physicalPort' should not be specified. )
             - displayType (Attribute. The type of the display in the occupant zone specified by
             'occupantZoneId'. The integer values are defined in
             packages/services/Car/car-lib/src/android/car/CarOccupantZoneManager.java.
             Optional field. The combination of 'occupantZoneId and 'displayType' is another way of
             identifying a display. When 'displayType' is specified, 'occupantZoneId' should also
             be specified while 'physicalPort' should not be specified. )
       - DrivingState (Tag 1.a. Driving states supported)
             - state (Attribute. The driving states defined there should align with driving states
             (@CarDrivingState) defined in
             packages/services/Car/car-lib/src/android/car/drivingstate/CarDrivingStateEvent.java
             Supported driving states attribute values - "parked", "idling" and "moving"
             - minSpeed (Attribute)
             - maxSpeed (Attribute. Minimum and Maximum speed attributes
             useful to provide different restrictions for different speed ranges)
       - Restrictions (Tag 1.b. UX restriction types)
             - requiresDistractionOptimization (Attribute. This corresponds to what
             CarUxRestrictions#mRequiresDistractionOptimization needs to be set to. This means that
             apps will have to follow the general baseline distraction optimization rules defined in
             the Driver Distraction Guidelines. )
             - uxr (Attribute. These are the additional UX restrictions that OEMs can configure in
             addition to the baseline restrictions defined in the above
             requiresDistractionOptimization. The values here have to align with the UX
              Restrictions defined in
              packages/services/Car/car-lib/src/android/car/drivingstate/CarUxRestrictions.java.
              Supported values are -"baseline", "no_dialpad", "no_filtering", "limit_string_length",
              "no_keyboard", "no_video", "limit_content", "no_setup", "no_text_message",
              "no_voice_transcription", "fully_restricted". )
             - mode (Attribute. Supported attribute for Restrictions. UX restrictions service
             supports returning different sets of UX restrictions for the same driving state,
             through configurations for each "mode". These modes can be specified by any string
             name, for example, "passenger". "baseline" is the default value. Note: "passenger"
             mode can be generically supported by specifying UxR for passenger displays using
             'physicalPort' or the combination of 'occupantZoneId' and 'displayType'. Mode attribute
             supports multiple values separated by "|", thus a single restriction can be used in
             different modes, and these restrictions apply to all mode values separated by "|".
       - RestrictionParameters (Tag 2. Some of UX restrictions can be parameterized)
             - the restriction parameters can be local or global to all the UX restrictions. A local
             restriction parameters tag is within a <RestrictionMapping> container which is applied
             to all the driving states in that container. A global restriction parameters tag is
             within a <UxRestrictions> tag which is applied to all the <RestrictionMapping>
             containers which do not have a local <RestrictionParameters> tag associated with them.
             If the local <RestrictionParameters> tag is not defined for any RestrictionMapping, the
             global <RestrictionParameters> is applied.
       - StringRestrictions (Tag 2.a. Parameters to express displayed String related restrictions)
             - maxLength (Attribute. Max allowed length of general purpose strings when
             limit_string_length is imposed)
       - ContentRestrictions (Tag 2.b. Parameters to express content related restrictions)
             - maxCumulativeItems (Attribute. Max number of cumulative content items allowed to be
             displayed when (limit_content is imposed)
             - maxDepth (Attribute. Maximum levels deep that the user can navigate to when
             limit_content is imposed)
-->

<UxRestrictions xmlns:car="http://schemas.android.com/apk/res-auto">
    <!-- Map the driving states to UX restrictions here -->
    <!-- Note - The platform takes a fully restricted approach when there is no information or if
    the information is malformed.  As a result,
    1. Default values for requiresDistractionOptimization is true, and uxr is fully_restricted.
    2. If uxr != baseline, then requiresDistractionOptimization is automatically promoted to true,
    even if it is declared as false.  Because it doesn't make sense to have an non baseline UX
    restriction without requiresDistractionOptimization set to true.
    So if we don't want any restrictions, requiresDistractionOptimization should be explicitly
    marked as false and uxr should be explicitly set to baseline. -->

    <RestrictionMapping>
        <DrivingState state="parked">
            <Restrictions requiresDistractionOptimization="false" uxr="baseline"/>
        </DrivingState>

        <DrivingState state="idling">
            <Restrictions requiresDistractionOptimization="true" uxr="no_video" mode="baseline"/>
        </DrivingState>

        <!-- This is to illustrate how to add multiple speed ranges.  The restrictions here
        are the same for both the speed ranges, but could be configured to be different.
        NOTE:
        1. The speed units is in meters per second to be in accordance with the
        PERF_VEHICLE SPEED definition in hardware/interfaces/automotive/vehicle/2.0/types.hal
        2. The speed ranges should be non overlapping, i.e. one speed value cannot be in more
        than one range.  It is denoted in a left closed, right open interval [minSpeed, maxSpeed).
        For ex: [0,5) indicates speed >= 0 && speed < 5.0m/s.
        3. For a speed range with no high limit, maxSpeed is not filled.  For ex., if the speed
        range is anything >=5m/s, only the minSpeed is filled with a value of 5m/s.  There cannot be
        a range higher than this, which will violate the 2nd condition above.
        4. If the above conditions are not met, mapping behavior is undefined. -->
        <!-- This is restrictions for moving and speed [0,5m/s) -->
        <DrivingState state="moving" minSpeed="0" maxSpeed="5.0">
            <Restrictions requiresDistractionOptimization="true" uxr="no_dialpad|no_filtering|limit_string_length|no_keyboard|no_video|limit_content|no_setup|no_text_message"/>
        </DrivingState>

        <!-- Restrictions for speed >=5 -->
        <DrivingState state="moving" minSpeed="5.0">
            <Restrictions requiresDistractionOptimization="true" uxr="no_dialpad|no_filtering|limit_string_length|no_keyboard|no_video|limit_content|no_setup|no_text_message"/>
        </DrivingState>

    </RestrictionMapping>

    <!-- Configure restriction parameters here-->
    <RestrictionParameters>
        <!-- Parameters to express displayed String related restrictions -->
        <!-- Max allowed length of general purpose strings when limit_string_length is imposed-->
        <StringRestrictions maxLength="120"/>
        <!-- Parameters to express content related restrictions -->
        <!-- Max number of cumulative content items allowed to be displayed when
        limit_content is imposed. -->
        <!-- Maximum levels deep that the user can navigate to when limit_content is imposed. -->
        <ContentRestrictions maxCumulativeItems="21" maxDepth="3"/>
    </RestrictionParameters>

</UxRestrictions>
