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") @Nullable Bitmap
renderComplicationToBitmap(
    int complicationSlotId,
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    @NonNull ComplicationData complicationData,
    @Nullable 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(
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    @Nullable UserStyle userStyle,
    @Nullable Map<@NonNull Integer, @NonNull ComplicationData> 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

@NonNull
public 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

@NonNull
public abstract @NonNull Instant previewReferenceInstant

The Instant to use when rendering previews.

userStyleSchema

@NonNull
public abstract @NonNull UserStyleSchema userStyleSchema

The watch face's UserStyleSchema.

Public methods

addClientDisconnectListener

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

Registers a ClientDisconnectListener.

isConnectionAlive

@AnyThread
@NonNull
public abstract @AnyThread boolean isConnectionAlive()

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

removeClientDisconnectListener

@AnyThread
@NonNull
public abstract @AnyThread void removeClientDisconnectListener(
    @NonNull HeadlessWatchFaceClient.ClientDisconnectListener listener
)

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

renderComplicationToBitmap

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

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

Parameters
int complicationSlotId

The id of the complication to render

@NonNull RenderParameters renderParameters

The RenderParameters to draw with

@NonNull Instant instant

The Instant to render with

@NonNull ComplicationData complicationData

the ComplicationData to render with

@Nullable UserStyle userStyle

Optional UserStyle to render with, if null the default style is used

Returns
@RequiresApi(value = "27") Bitmap

A shared memory backed Bitmap containing a screenshot of the watch face with the given settings, or null if complicationSlotId is unrecognized.

renderWatchFaceToBitmap

@RequiresApi(value = "27")
@NonNull
public abstract @RequiresApi(value = "27") Bitmap renderWatchFaceToBitmap(
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    @Nullable UserStyle userStyle,
    @Nullable Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData
)

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

Parameters
@NonNull RenderParameters renderParameters

The RenderParameters to draw with.

@NonNull Instant instant

The Instant to render with

@Nullable UserStyle userStyle

Optional UserStyle to render with, if null the default style is used.

@Nullable Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData

Map of androidx.wear.watchface.ComplicationSlot ids to ComplicationData to render with, or if nullandroidx.wear.watchface.ComplicationSlot are not rendered.

Returns
@RequiresApi(value = "27") Bitmap

A shared memory backed Bitmap containing a screenshot of the watch face with the given settings.

toBundle

@NonNull
public abstract Bundle toBundle()

Stores the underlying connection in a Bundle.