# CarUxRestrictions

Summary:[Nested Classes](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#nestedclasses)\|[Constants](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#constants)\|[Inherited Constants](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#inhconstants)\|[Fields](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#lfields)\|[Ctors](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#pubctors)\|[Methods](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#inhmethods)  

# CarUxRestrictions

`
public

final

class
CarUxRestrictions
`  
`

extends Object


``


implements

Parcelable


`

|---|--------------------------------------------|
| java.lang.Object                              ||
| ↳ | android.car.drivingstate.CarUxRestrictions |

<br />

*** ** * ** ***

Car UX Restrictions event. This contains information on the set of UX restrictions that is in place due to the car's driving state.

The restriction information is organized as follows:

- When there are no restrictions in place, for example when the car is parked,
  - [isRequiresDistractionOptimization()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())returns false. Apps can display activities that are not distraction optimized.
  - When[isRequiresDistractionOptimization()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())returns false, apps don't have to call[getActiveRestrictions()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getActiveRestrictions()), since there is no distraction optimization required.
- When the driving state changes, causing the UX restrictions to come in effect,
  - [isRequiresDistractionOptimization()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())returns true. Apps can only display activities that are distraction optimized. Distraction optimized activities must follow the base design guidelines to ensure a distraction free driving experience for the user.
  - When[isRequiresDistractionOptimization()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())returns true, apps must call[getActiveRestrictions()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getActiveRestrictions()), to get the currently active UX restrictions to adhere to.[getActiveRestrictions()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getActiveRestrictions())provides additional information on the set of UX restrictions that are in place for the current driving state.

    The UX restrictions returned by[getActiveRestrictions()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getActiveRestrictions()), for the same driving state of the vehicle, could vary depending on the OEM and the market. For example, when the car is idling, the set of active UX restrictions will depend on the car maker and the safety standards of the market that the vehicle is deployed in.

Apps that intend to be run when the car is being driven need to

- Comply with the general distraction optimization guidelines.
- Listen and react to the UX restrictions changes as detailed above. Since the restrictions could vary depending on the market, apps are expected to react to the restriction information and not to the absolute driving state.

<br />

## Summary

|                                                                                                                     ### Nested classes                                                                                                                     ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [CarUxRestrictions.Builder](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions.Builder) Builder class for[CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions) |

|                                                                                                                                                                                                           ### Constants                                                                                                                                                                                                            ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [UX_RESTRICTIONS_BASELINE](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_BASELINE) No specific restrictions in place, but baseline distraction optimization guidelines need to be adhered to when[isRequiresDistractionOptimization()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())is true. |
| `int` | [UX_RESTRICTIONS_FULLY_RESTRICTED](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_FULLY_RESTRICTED) All restrictions are in effect.                                                                                                                                                                                                                                     |
| `int` | [UX_RESTRICTIONS_LIMIT_CONTENT](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT) Limit the number of items user can browse through in total in a single task.                                                                                                                                                                                              |
| `int` | [UX_RESTRICTIONS_LIMIT_STRING_LENGTH](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH) General purpose strings length cannot exceed the character limit provided by[getMaxRestrictedStringLength()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxRestrictedStringLength())                               |
| `int` | [UX_RESTRICTIONS_NO_DIALPAD](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_DIALPAD) No dialpad for the purpose of initiating a phone call.                                                                                                                                                                                                                          |
| `int` | [UX_RESTRICTIONS_NO_FILTERING](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_FILTERING) No filtering a list with alpha-numeric character via the use of a character entry method.                                                                                                                                                                                   |
| `int` | [UX_RESTRICTIONS_NO_KEYBOARD](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_KEYBOARD) No text entry for the purpose of searching or other manual text string entry actvities.                                                                                                                                                                                       |
| `int` | [UX_RESTRICTIONS_NO_SETUP](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_SETUP) No setup that requires form entry or interaction with external devices.                                                                                                                                                                                                             |
| `int` | [UX_RESTRICTIONS_NO_TEXT_MESSAGE](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_TEXT_MESSAGE) No Text Message (SMS, email, conversational, etc.)                                                                                                                                                                                                                    |
| `int` | [UX_RESTRICTIONS_NO_VIDEO](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_VIDEO) No video - no animated frames \> 1fps.                                                                                                                                                                                                                                              |
| `int` | [UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION) No text transcription (live or leave behind) of voice can be shown.                                                                                                                                                                                     |

|                                                                                                                                                                 ### Inherited constants                                                                                                                                                                 |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface`android.os.Parcelable` |-------|----------------------------------------| | `int` | `CONTENTS_FILE_DESCRIPTOR` <br />      | | `int` | `PARCELABLE_ELIDE_DUPLICATES` <br />   | | `int` | `PARCELABLE_STABILITY_LOCAL` <br />    | | `int` | `PARCELABLE_STABILITY_VINTF` <br />    | | `int` | `PARCELABLE_WRITE_RETURN_VALUE` <br /> | |

|                                                                                                                       ### Fields                                                                                                                        ||
|-------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| ` public static final Creator<`[CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions)`>` | [CREATOR](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#CREATOR) <br /> |

|                                                                                                                                         ### Public constructors                                                                                                                                          ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#CarUxRestrictions(android.car.drivingstate.CarUxRestrictions))`(`[CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions)` uxRestrictions) ` |

|                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                         ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int`     | ` `[describeContents](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#describeContents())`() `                                                                                                                                                                                                                                                                                                                                                      |
| ` int`     | ` `[getActiveRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getActiveRestrictions())`() ` A combination of the Car UX Restrictions that is active for the current state of driving.                                                                                                                                                                                                                                                  |
| ` int`     | ` `[getMaxContentDepth](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxContentDepth())`() ` Get the maximum allowable number of content depth levels or view traversals through any one path in a single task.                                                                                                                                                                                                                               |
| ` int`     | ` `[getMaxCumulativeContentItems](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxCumulativeContentItems())`() ` Get the maximum allowable number of content items that can be displayed to a user during traversal through any one path in a single task, when[CarUxRestrictions.UX_RESTRICTIONS_LIMIT_CONTENT](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT)is imposed. |
| ` int`     | ` `[getMaxRestrictedStringLength](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxRestrictedStringLength())`() ` Get the maximum length of general purpose strings that can be displayed when[CarUxRestrictions.UX_RESTRICTIONS_LIMIT_STRING_LENGTH](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH)is imposed.                                                       |
| ` boolean` | ` `[isRequiresDistractionOptimization](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())`() ` Conveys if the foreground activity needs to be distraction optimized.                                                                                                                                                                                                                                              |
| ` boolean` | ` `[isSameRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isSameRestrictions(android.car.drivingstate.CarUxRestrictions))`(`[CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions)` other) ` Compares if the restrictions are the same.                                                                                                                                              |
| ` String`  | ` `[toString](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#toString())`() `                                                                                                                                                                                                                                                                                                                                                                      |
| ` void`    | ` `[writeToParcel](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#writeToParcel(android.os.Parcel,%20int))`(Parcel dest, int flags) `                                                                                                                                                                                                                                                                                                              |

| ### Inherited methods |
|-----------------------|---|
| From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||
| From interface` android.os.Parcelable ` |------------------|------------------------------------------| | ` abstract int`  | ` describeContents() `                   | | ` default int`   | ` getStability() `                       | | ` abstract void` | ` writeToParcel(Parcel arg0, int arg1) ` | ||

## Constants

### UX_RESTRICTIONS_BASELINE

```
public static final int UX_RESTRICTIONS_BASELINE
```

No specific restrictions in place, but baseline distraction optimization guidelines need to be adhered to when[isRequiresDistractionOptimization()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#isRequiresDistractionOptimization())is true.

<br />

Constant Value: 0 (0x00000000)  

### UX_RESTRICTIONS_FULLY_RESTRICTED

```
public static final int UX_RESTRICTIONS_FULLY_RESTRICTED
```

All restrictions are in effect.

<br />

Constant Value: 511 (0x000001ff)  

### UX_RESTRICTIONS_LIMIT_CONTENT

```
public static final int UX_RESTRICTIONS_LIMIT_CONTENT
```

Limit the number of items user can browse through in total in a single task.

Refer to[getMaxCumulativeContentItems()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxCumulativeContentItems())and[getMaxContentDepth()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxContentDepth())for the upper bounds on content serving.

<br />

Constant Value: 32 (0x00000020)  

### UX_RESTRICTIONS_LIMIT_STRING_LENGTH

```
public static final int UX_RESTRICTIONS_LIMIT_STRING_LENGTH
```

General purpose strings length cannot exceed the character limit provided by[getMaxRestrictedStringLength()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxRestrictedStringLength())

<br />

Constant Value: 4 (0x00000004)  

### UX_RESTRICTIONS_NO_DIALPAD

```
public static final int UX_RESTRICTIONS_NO_DIALPAD
```

No dialpad for the purpose of initiating a phone call.

<br />

Constant Value: 1 (0x00000001)  

### UX_RESTRICTIONS_NO_FILTERING

```
public static final int UX_RESTRICTIONS_NO_FILTERING
```

No filtering a list with alpha-numeric character via the use of a character entry method. For example, do not allow entering a letter to filter the content of a list down to items only containing that letter.

<br />

Constant Value: 2 (0x00000002)  

### UX_RESTRICTIONS_NO_KEYBOARD

```
public static final int UX_RESTRICTIONS_NO_KEYBOARD
```

No text entry for the purpose of searching or other manual text string entry actvities.

<br />

Constant Value: 8 (0x00000008)  

### UX_RESTRICTIONS_NO_SETUP

```
public static final int UX_RESTRICTIONS_NO_SETUP
```

No setup that requires form entry or interaction with external devices.

<br />

Constant Value: 64 (0x00000040)  

### UX_RESTRICTIONS_NO_TEXT_MESSAGE

```
public static final int UX_RESTRICTIONS_NO_TEXT_MESSAGE
```

No Text Message (SMS, email, conversational, etc.)

<br />

Constant Value: 128 (0x00000080)  

### UX_RESTRICTIONS_NO_VIDEO

```
public static final int UX_RESTRICTIONS_NO_VIDEO
```

No video - no animated frames \> 1fps.

<br />

Constant Value: 16 (0x00000010)  

### UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION

```
public static final int UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION
```

No text transcription (live or leave behind) of voice can be shown.

<br />

Constant Value: 256 (0x00000100)

## Fields

### CREATOR

```
public static final Creator<CarUxRestrictions> CREATOR
```

<br />

<br />

## Public constructors

### CarUxRestrictions

```
public CarUxRestrictions (CarUxRestrictions uxRestrictions)
```

<br />

<br />

|                  Parameters                  ||
|------------------|----------------------------|
| `uxRestrictions` | `CarUxRestrictions` <br /> |

## Public methods

### describeContents

```
public int describeContents ()
```

<br />

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getActiveRestrictions

```
public int getActiveRestrictions ()
```

A combination of the Car UX Restrictions that is active for the current state of driving.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Returns                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | A combination of the above`@CarUxRestrictionsInfo`Value is either`0`or a combination of[UX_RESTRICTIONS_BASELINE](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_BASELINE),[UX_RESTRICTIONS_NO_DIALPAD](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_DIALPAD),[UX_RESTRICTIONS_NO_FILTERING](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_FILTERING),[UX_RESTRICTIONS_LIMIT_STRING_LENGTH](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH),[UX_RESTRICTIONS_NO_KEYBOARD](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_KEYBOARD),[UX_RESTRICTIONS_NO_VIDEO](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_VIDEO),[UX_RESTRICTIONS_LIMIT_CONTENT](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT),[UX_RESTRICTIONS_NO_SETUP](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_SETUP),[UX_RESTRICTIONS_NO_TEXT_MESSAGE](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_TEXT_MESSAGE), and[UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_NO_VOICE_TRANSCRIPTION) <br /> |

### getMaxContentDepth

```
public int getMaxContentDepth ()
```

Get the maximum allowable number of content depth levels or view traversals through any one path in a single task. This is applicable when[CarUxRestrictions.UX_RESTRICTIONS_LIMIT_CONTENT](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT)is imposed.

For example, if a task involves only selecting an item from a single list on one view, the task's content depth would be considered 1.

However, if the task involves selection of a content item in an originating view that then surfaces a secondary view to the user, the task's content depth would be considered 2.

Specifically, if a task involved browsing a list of countries, selecting a genre within the country, and then viewing the top songs within a country, the task's content depth would be considered 3.

Please refer to this and[getMaxCumulativeContentItems()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxCumulativeContentItems())to know the upper bounds on the content display when the restriction is in place.

<br />

|                             Returns                             ||
|-------|----------------------------------------------------------|
| `int` | maximum levels deep that the user can navigate to <br /> |

### getMaxCumulativeContentItems

```
public int getMaxCumulativeContentItems ()
```

Get the maximum allowable number of content items that can be displayed to a user during traversal through any one path in a single task, when[CarUxRestrictions.UX_RESTRICTIONS_LIMIT_CONTENT](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_CONTENT)is imposed.

For example, if a task involving only one view, this represents the maximum allowable number of content items in this single view.

However, if the task involves selection of a content item in an originating view that then surfaces a secondary view to the user, then this value represents the maximum allowable number of content items between the originating and secondary views combined.

Specifically, if the maximum allowable value was 60 and a task involved browsing a list of countries and then viewing the top songs within a country, it would be acceptable to do either of the following:

- list 10 countries, and then display the top 50 songs after country selection, or
- list 20 countries, and then display the top 40 songs after country selection.

Please refer to this and[getMaxContentDepth()](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#getMaxContentDepth())to know the upper bounds on the content display when the restriction is in place.

<br />

|                                Returns                                 ||
|-------|-----------------------------------------------------------------|
| `int` | maximum number of cumulative items that can be displayed <br /> |

### getMaxRestrictedStringLength

```
public int getMaxRestrictedStringLength ()
```

Get the maximum length of general purpose strings that can be displayed when[CarUxRestrictions.UX_RESTRICTIONS_LIMIT_STRING_LENGTH](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions#UX_RESTRICTIONS_LIMIT_STRING_LENGTH)is imposed.

<br />

|                             Returns                              ||
|-------|-----------------------------------------------------------|
| `int` | the maximum length of string that can be displayed <br /> |

### isRequiresDistractionOptimization

```
public boolean isRequiresDistractionOptimization ()
```

Conveys if the foreground activity needs to be distraction optimized. Activities that can handle distraction optimization need to be tagged as a distraction optimized in the app's manifest.

If the app has a foreground activity that has not been distraction optimized, the app has to switch to another activity that is distraction optimized. Failing that, the system will stop the foreground activity.

<br />

|                                   Returns                                    ||
|-----------|-------------------------------------------------------------------|
| `boolean` | true if distraction optimization is required, false if not <br /> |

### isSameRestrictions

```
public boolean isSameRestrictions (CarUxRestrictions other)
```

Compares if the restrictions are the same. Doesn't compare the timestamps.

<br />

|                               Parameters                                ||
|---------|----------------------------------------------------------------|
| `other` | `CarUxRestrictions`: the other CarUxRestrictions object <br /> |

|                               Returns                                ||
|-----------|-----------------------------------------------------------|
| `boolean` | true if the restrictions are same, false otherwise <br /> |

### toString

```
public String toString ()
```

<br />

<br />

|     Returns      ||
|----------|--------|
| `String` | <br /> |

### writeToParcel

```
public void writeToParcel (Parcel dest, 
                int flags)
```

<br />

<br />

|        Parameters        ||
|---------|-----------------|
| `dest`  | `Parcel` <br /> |
| `flags` | `int` <br />    |