HeadlessWatchFaceClient

interface HeadlessWatchFaceClient


Controls a stateless remote headless watch face. This is mostly intended for use by watch face editor UIs which need to generate screenshots for various styling configurations without affecting the current watchface.

Note clients should call close when finished.

Summary

Nested types

HeadlessWatchFaceClient.ClientDisconnectListener

Callback that observes when the client disconnects.

HeadlessWatchFaceClient.Companion

Public methods

abstract @AnyThread void

Registers a ClientDisconnectListener.

abstract @AnyThread boolean

Returns true if the connection to the server side is alive.

abstract @AnyThread void

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

abstract @RequiresApi(value = 27) Bitmap
renderComplicationToBitmap(
    int complicationSlotId,
    RenderParameters renderParameters,
    Instant instant,
    ComplicationData complicationData,
    UserStyle userStyle
)

c Renders the androidx.wear.watchface.ComplicationSlot to a shared memory backed Bitmap with the given settings.

abstract @RequiresApi(value = 27) @NonNull Bitmap
renderWatchFaceToBitmap(
    RenderParameters renderParameters,
    Instant instant,
    UserStyle userStyle,
    Map<IntegerComplicationData> slotIdToComplicationData
)

Renders the watchface to a shared memory backed Bitmap with the given settings.

abstract @NonNull Bundle

Stores the underlying connection in a Bundle.

Inherited methods

From class AutoCloseable
abstract void

Public fields

complicationSlotsState

abstract @NonNull Map<@NonNull Integer, @NonNull ComplicationSlotStatecomplicationSlotsState

Map of androidx.wear.watchface.ComplicationSlot ids to ComplicationSlotState for each ComplicationSlot registered with the watch face's ComplicationSlotsManager. The ComplicationSlotState is based on the initial state of each androidx.wear.watchface.ComplicationSlot plus any overrides from the default style's ComplicationSlotsUserStyleSetting. Because the style can't change, ComplicationSlotState is immutable for a headless watch face.

previewReferenceInstant

abstract @NonNull Instant previewReferenceInstant

The Instant to use when rendering previews.

userStyleSchema

abstract @NonNull UserStyleSchema userStyleSchema

The watch face's UserStyleSchema.

Public methods

addClientDisconnectListener

@AnyThread
abstract void addClientDisconnectListener(
    HeadlessWatchFaceClient.ClientDisconnectListener listener,
    Executor executor
)

Registers a ClientDisconnectListener.

isConnectionAlive

@AnyThread
abstract boolean isConnectionAlive()

Returns true if the connection to the server side is alive.

removeClientDisconnectListener

@AnyThread
abstract void removeClientDisconnectListener(
    HeadlessWatchFaceClient.ClientDisconnectListener listener
)

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

renderComplicationToBitmap

@RequiresApi(value = 27)
abstract Bitmap renderComplicationToBitmap(
    int complicationSlotId,
    RenderParameters renderParameters,
    Instant instant,
    ComplicationData complicationData,
    UserStyle userStyle
)

c Renders the