HeadlessWatchFaceClient


interface HeadlessWatchFaceClient : 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 companion functions

HeadlessWatchFaceClient

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

Public functions

Unit

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

open UserStyleFlavors

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

open ByteArray

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

Boolean

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

Unit

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

Bitmap?
@RequiresApi(value = 27)
renderComplicationToBitmap(
    complicationSlotId: Int,
    renderParameters: RenderParameters,
    instant: Instant,
    complicationData: ComplicationData,
    userStyle: UserStyle?
)

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

Bitmap
@RequiresApi(value = 27)
renderWatchFaceToBitmap(
    renderParameters: RenderParameters,
    instant: Instant,
    userStyle: UserStyle?,
    slotIdToComplicationData: Map<IntComplicationData>?
)

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

Bundle

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

Public properties

Map<IntComplicationSlotState>

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

open Boolean

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

Instant

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

UserStyleSchema

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

Inherited functions

From java.lang.AutoCloseable
Unit

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

Public companion functions

createFromBundle

Added in 1.0.0
Deprecated in 1.3.0-alpha06
fun createFromBundle(bundle: Bundle): HeadlessWatchFaceClient

Public functions

addClientDisconnectListener

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@AnyThread
fun addClientDisconnectListener(
    listener: HeadlessWatchFaceClient.ClientDisconnectListener,
    executor: Executor
): Unit

Registers a ClientDisconnectListener.

getUserStyleFlavors

Added in 1.2.0
Deprecated in 1.3.0-alpha06
open fun getUserStyleFlavors(): UserStyleFlavors

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.

getUserStyleSchemaDigestHash

Added in 1.1.0
Deprecated in 1.3.0-alpha06
open fun getUserStyleSchemaDigestHash(): ByteArray

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
fun isConnectionAlive(): Boolean

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

removeClientDisconnectListener

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@AnyThread
fun removeClientDisconnectListener(
    listener: HeadlessWatchFaceClient.ClientDisconnectListener
): Unit

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

renderComplicationToBitmap

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@RequiresApi(value = 27)
fun renderComplicationToBitmap(
    complicationSlotId: Int,
    renderParameters: RenderParameters,
    instant: Instant,
    complicationData: ComplicationData,
    userStyle: UserStyle?
): Bitmap?

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
complicationSlotId: Int

The id of the complication to render

renderParameters: RenderParameters

The RenderParameters to draw with

instant: Instant

The Instant to render with

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)
fun renderWatchFaceToBitmap(
    renderParameters: RenderParameters,
    instant: Instant,
    userStyle: UserStyle?,
    slotIdToComplicationData: Map<IntComplicationData>?
): Bitmap

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

Parameters
renderParameters: RenderParameters

The RenderParameters to draw with.

instant: Instant

The Instant to render with

userStyle: UserStyle?

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

slotIdToComplicationData: Map<IntComplicationData>?

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

Returns
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
fun toBundle(): Bundle

Stores the underlying connection in a Bundle.

Public properties

complicationSlotsState

Added in 1.0.0
Deprecated in 1.3.0-alpha06
val complicationSlotsStateMap<IntComplicationSlotState>

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.

isRenderWatchFaceToSurfaceSupported

Added in 1.2.0
Deprecated in 1.3.0-alpha06
open val isRenderWatchFaceToSurfaceSupportedBoolean

Whether or not the watch face supports renderWatchFaceToSurface.

previewReferenceInstant

Added in 1.0.0
Deprecated in 1.3.0-alpha06
val previewReferenceInstantInstant

The Instant to use when rendering previews.

userStyleSchema

Added in 1.0.0
Deprecated in 1.3.0-alpha06
val userStyleSchemaUserStyleSchema

The watch face's UserStyleSchema.