# PlatformEventSources

Artifact: [androidx.wear.protolayout:protolayout-expression](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/expression/PlatformEventSources.kt+class:androidx.wear.protolayout.expression.PlatformEventSources) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

*** ** * ** ***


```
object PlatformEventSources
```

<br />

*** ** * ** ***

Dynamic types for platform events

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources.DynamicLayoutUpdateStatus : https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInt32` Dynamic layout update status value. |
| `object https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources.Keys` Data sources keys for platform event. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#LAYOUT_UPDATE_IDLE() = 0` There are no pending layout updates. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#LAYOUT_UPDATE_IDLE_ERROR() = 2` A new layout has been requested, but there was an error. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#LAYOUT_UPDATE_WAITING() = 1` A new layout has been requested. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool` | `@https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 600) https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#isInAmbientMode()()` Returns a `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool` which receives the current ambient mode status from platform. |
| `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool` | `@https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 500) https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#isLayoutVisible()()` Returns a `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool` which receives the current visibility status from platform. |
| `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources.DynamicLayoutUpdateStatus` | `@https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 600) https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#layoutUpdateStatus()()` Returns a `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources.DynamicLayoutUpdateStatus` representing the current status of the layout update. |

## Constants

### LAYOUT_UPDATE_IDLE

Added in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
const val LAYOUT_UPDATE_IDLE = 0: Int
```

There are no pending layout updates.

### LAYOUT_UPDATE_IDLE_ERROR

Added in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
const val LAYOUT_UPDATE_IDLE_ERROR = 2: Int
```

A new layout has been requested, but there was an error. The system will retry the update.

### LAYOUT_UPDATE_WAITING

Added in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
const val LAYOUT_UPDATE_WAITING = 1: Int
```

A new layout has been requested.

## Public functions

### isInAmbientMode

Added in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
@RequiresSchemaVersion(major = 1, minor = 600)
fun isInAmbientMode(): DynamicBuilders.DynamicBool
```

Returns a `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool` which receives the current ambient mode status from platform.

The ambient status value is `true` if the device is in ambient mode and `false` otherwise.

### isLayoutVisible

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
@RequiresSchemaVersion(major = 1, minor = 500)
fun isLayoutVisible(): DynamicBuilders.DynamicBool
```

Returns a `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool` which receives the current visibility status from platform.

The visibility status value is `true` when layout is visible, and `false` when invisible.

### layoutUpdateStatus

Added in [1.4.2](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.4.2)

```
@RequiresSchemaVersion(major = 1, minor = 600)
fun layoutUpdateStatus(): PlatformEventSources.DynamicLayoutUpdateStatus
```

Returns a `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources.DynamicLayoutUpdateStatus` representing the current status of the layout update.

The platform requests a new layout when explicitly requested by the tile provider, or when the current layout becomes invalidated.

The layout update status can be one of the following:

- `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#LAYOUT_UPDATE_WAITING()`: The layout update is pending, starting from when a new layout is requested until it is successfully received and inflated.

- `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#LAYOUT_UPDATE_IDLE_ERROR()`: The latest layout request failed.

- `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformEventSources#LAYOUT_UPDATE_IDLE()`: All other times, indicating no pending or failed layout update.