HeadlessWatchFaceClient


public interface HeadlessWatchFaceClient extends AutoCloseable


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.

use Watch Face Format instead

Summary

Nested types

This interface is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public methods

abstract void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

default static final @NonNull HeadlessWatchFaceClient

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract @NonNull Map<@NonNull Integer, @NonNull ComplicationSlotState>

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract @NonNull Instant

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

default @NonNull UserStyleFlavors

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract @NonNull UserStyleSchema

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

default @NonNull byte[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

default boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

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

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

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

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract @NonNull Bundle

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Inherited methods

From java.lang.AutoCloseable
abstract void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public methods

addClientDisconnectListener

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@AnyThread
abstract void addClientDisconnectListener(
    @NonNull HeadlessWatchFaceClient.ClientDisconnectListener listener,
    @NonNull Executor executor
)

Registers a ClientDisconnectListener.

createFromBundle

Added in 1.0.0
Deprecated in 1.3.0-alpha06
default static final @NonNull HeadlessWatchFaceClient createFromBundle(@NonNull Bundle bundle)

getComplicationSlotsState

Added in 1.0.0
Deprecated in 1.3.0-alpha06
abstract @NonNull Map<@NonNull Integer, @NonNull ComplicationSlotStategetComplicationSlotsState()

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.

getPreviewReferenceInstant

Added in 1.0.0
Deprecated in 1.3.0-alpha06
abstract @NonNull Instant getPreviewReferenceInstant()

The Instant to use when rendering previews.

getUserStyleFlavors

Added in 1.2.0
Deprecated in 1.3.0-alpha06
default @NonNull UserStyleFlavors getUserStyleFlavors()

Returns the watch face's UserStyleFlavors if any.

Throws
kotlin.RuntimeException

if the watch face threw an exception while trying to service the request or there was a communication problem with watch face process.

getUserStyleSchema

Added in 1.0.0
Deprecated in 1.3.0-alpha06
abstract @NonNull UserStyleSchema getUserStyleSchema()

The watch face's UserStyleSchema.

getUserStyleSchemaDigestHash

Added in 1.1.0
Deprecated in 1.3.0-alpha06
default @NonNull byte[] getUserStyleSchemaDigestHash()

A SHA-1 MessageDigest hash of the UserStyleSchema. Note that for performance reasons where possible the resource id or url for Icons in the schema are used rather than the image bytes. This means that this hash should be considered insensitive to changes to the contents of icons between APK versions, which the user should account for accordingly.

This gives the same result as calling UserStyleSchema.computeDigestHash on userStyleSchema but is slightly faster since less data is passed over AIDL.

isConnectionAlive

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@AnyThread
abstract boolean isConnectionAlive()

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

isRenderWatchFaceToSurfaceSupported

Added in 1.2.0
Deprecated in 1.3.0-alpha06
default boolean isRenderWatchFaceToSurfaceSupported()

Whether or not the watch face supports renderWatchFaceToSurface.

removeClientDisconnectListener

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@AnyThread
abstract void removeClientDisconnectListener(
    @NonNull HeadlessWatchFaceClient.ClientDisconnectListener listener
)

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

renderComplicationToBitmap

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@RequiresApi(value = 27)
abstract Bitmap renderComplicationToBitmap(
    int complicationSlotId,
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    @NonNull ComplicationData complicationData,
    UserStyle userStyle
)

Renders the androidx.wear.watchface.ComplicationSlot to a shared memory backed Bitmap with the given settings. The complication will be rendered at the same scale as it would be when the watch face is full screen.

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

UserStyle userStyle

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

Returns
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)
abstract @NonNull Bitmap renderWatchFaceToBitmap(
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    UserStyle userStyle,
    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

UserStyle userStyle

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

Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData

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

Returns
@NonNull Bitmap

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

toBundle

Added in 1.0.0
Deprecated in 1.3.0-alpha06
abstract @NonNull Bundle toBundle()

Stores the underlying connection in a Bundle.