Google is committed to advancing racial equity for Black communities. See how.

InteractiveWatchFaceWcsClient

interface InteractiveWatchFaceWcsClient : AutoCloseable
androidx.wear.watchface.client.InteractiveWatchFaceWcsClient

Controls a stateful remote interactive watch face with an interface tailored for WCS the WearOS system server responsible for watch face management. Typically this will be used for the current active watch face.

Note clients should call close when finished.

Summary

Public methods
abstract IBinder

Returns the associated IBinder.

abstract Unit

Requests the specified complication is highlighted for a short period to bring attention to it.

open Int?
getComplicationIdAt(@Px x: Int, @Px y: Int)

Returns the ID of the complication at the given coordinates or null if there isn't one.

abstract Unit
setUserStyle(userStyle: UserStyle)

Sets the watch face's current UserStyle.

abstract Unit
setUserStyle(userStyle: Map<String, String>)

Sets the watch face's current UserStyle represented as a Map<String, String>.

abstract Bitmap
takeWatchFaceScreenshot(renderParameters: RenderParameters, @IntRange(0, 100) compressionQuality: Int, calendarTimeMillis: Long, userStyle: UserStyle?, idAndComplicationData: Map<Int, ComplicationData>?)

Requests for a WebP compressed shared memory backed Bitmap containing a screenshot of the watch face with the given settings.

abstract Unit
updateComplicationData(idToComplicationData: Map<Int, ComplicationData>)

Sends new ComplicationData to the watch face.

Companion functions
InteractiveWatchFaceWcsClient

Constructs an InteractiveWatchFaceWcsClient from the IBinder returned by asBinder.

Properties
abstract Map<Int, ComplicationState>

Map of complication ids to ComplicationState for each complication slot.

abstract String

Returns the ID of this watch face instance.

abstract Long

The UTC reference preview time for this watch face in milliseconds since the epoch.

abstract UserStyleSchema

The watch face's UserStyleSchema.

Public methods

asBinder

abstract fun asBinder(): IBinder

Returns the associated IBinder. Allows this interface to be passed over AIDL.

bringAttentionToComplication

abstract fun bringAttentionToComplication(complicationId: Int): Unit

Requests the specified complication is highlighted for a short period to bring attention to it.

getComplicationIdAt

open fun getComplicationIdAt(
    @Px x: Int,
    @Px y: Int
): Int?

Returns the ID of the complication at the given coordinates or null if there isn't one.

setUserStyle

abstract fun setUserStyle(userStyle: UserStyle): Unit

Sets the watch face's current UserStyle. Note this may alter complicationState.

setUserStyle

abstract fun setUserStyle(userStyle: Map<String, String>): Unit

Sets the watch face's current UserStyle represented as a Map<String, String>. This can be helpful to avoid having to construct a UserStyle which requires the UserStyleSchema which is an additional IPC. Note this may alter complicationState.

takeWatchFaceScreenshot

@RequiresApi(27) abstract fun takeWatchFaceScreenshot(
    renderParameters: RenderParameters,
    @IntRange(0, 100) compressionQuality: Int,
    calendarTimeMillis: Long,
    userStyle: UserStyle?,
    idAndComplicationData: Map<Int, ComplicationData>?
): Bitmap

Requests for a WebP compressed shared memory backed Bitmap containing a screenshot of the watch face with the given settings.

Parameters
renderParameters: RenderParameters The RenderParameters to draw with.
compressionQuality: Int The WebP compression quality, 100 = loss less.
calendarTimeMillis: Long The UTC time in milliseconds since the epoch to render with.
userStyle: UserStyle? Optional UserStyle to render with, if null the current style is used.
idAndComplicationData: Map<Int, ComplicationData>? Map of complication ids to ComplicationData to render with, or if null then the existing complication data if any is used.
Return
A WebP compressed shared memory backed Bitmap containing a screenshot of the watch face with the given settings.

updateComplicationData

abstract fun updateComplicationData(idToComplicationData: Map<Int, ComplicationData>): Unit

Sends new ComplicationData to the watch face. Note this doesn't have to be a full update, it's possible to update just one complication at a time, but doing so may result in a less visually clean transition.

Properties

complicationState

abstract val complicationState: Map<Int, ComplicationState>

Map of complication ids to ComplicationState for each complication slot. Note this can change, typically in response to styling.

instanceId

abstract val instanceId: String

Returns the ID of this watch face instance.

previewReferenceTimeMillis

abstract val previewReferenceTimeMillis: Long

The UTC reference preview time for this watch face in milliseconds since the epoch.

userStyleSchema

abstract val userStyleSchema: UserStyleSchema

The watch face's UserStyleSchema.

Companion functions

createFromBinder

@JvmStatic fun createFromBinder(binder: IBinder): InteractiveWatchFaceWcsClient

Constructs an InteractiveWatchFaceWcsClient from the IBinder returned by asBinder.