Added in API level 30

Control


class Control : Parcelable
kotlin.Any
   ↳ android.service.controls.Control

Represents a physical object that can be represented by a ControlTemplate and whose properties may be modified through a ControlAction. The information is provided by a ControlsProviderService and represents static information (not current status) about the device.

Each control needs a unique (per provider) identifier that is persistent across reboots of the system.

Each Control will have a name, a subtitle and will optionally belong to a structure and zone. Some of these values are defined by the user and/or the ControlsProviderService and will be used to display the control as well as group them for management.

Each object will have an associated DeviceTypes. This will determine the icons and colors used to display it.

An Intent linking to the provider Activity that expands on this Control and allows for further actions should be provided.

Summary

Nested classes

Builder class for Control that contains state information.

Builder class for Control.

Constants
static Int

The Control is currently disabled.

static Int

Used to indicate that there was a temporary error while loading the device state.

static Int

The device corresponding to the Control cannot be found or was removed.

static Int

Used to indicate that the state of the device was successfully retrieved.

static Int

Reserved for use with the StatelessBuilder, and while loading.

Inherited constants
Public methods
Int

PendingIntent

String

ControlTemplate

ColorStateList?

Optional color to be shown with the Control.

Icon?

Optional icon to be shown with the Control.

Int

Int

CharSequence

CharSequence?

Optional top-level group to help define the Control's location, visible to the user.

CharSequence

CharSequence

CharSequence?

Optional group name to help define the Control's location within a structure, visible to the user.

Boolean

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<Control!>

Constants

STATUS_DISABLED

Added in API level 30
static val STATUS_DISABLED: Int

The Control is currently disabled. A default error message will be displayed in place of any custom text that was set through StatefulBuilder.setStatusText.

Value: 4

STATUS_ERROR

Added in API level 30
static val STATUS_ERROR: Int

Used to indicate that there was a temporary error while loading the device state. A default error message will be displayed in place of any custom text that was set through StatefulBuilder.setStatusText.

Value: 3

STATUS_NOT_FOUND

Added in API level 30
static val STATUS_NOT_FOUND: Int

The device corresponding to the Control cannot be found or was removed. The user will be alerted and directed to the application to resolve.

Value: 2

STATUS_OK

Added in API level 30
static val STATUS_OK: Int

Used to indicate that the state of the device was successfully retrieved. This includes all scenarios where the device may have a warning for the user, such as "Lock jammed", or "Vacuum stuck". Any information for the user should be set through StatefulBuilder.setStatusText.

Value: 1

STATUS_UNKNOWN

Added in API level 30
static val STATUS_UNKNOWN: Int

Reserved for use with the StatelessBuilder, and while loading. When state is requested via ControlsProviderService.createPublisherFor, use other status codes to indicate the proper device state.

Value: 0

Public methods

describeContents

Added in API level 30
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getAppIntent

Added in API level 30
fun getAppIntent(): PendingIntent
Return
PendingIntent a PendingIntent linking to an Activity for the Control This value cannot be null.

getControlId

Added in API level 30
fun getControlId(): String
Return
String the identifier for the Control This value cannot be null.

getControlTemplate

Added in API level 30
fun getControlTemplate(): ControlTemplate
Return
ControlTemplate instance of ControlTemplate, that defines how the Control will behave and what interactions are available to the user This value cannot be null.

getCustomColor

Added in API level 30
fun getCustomColor(): ColorStateList?

Optional color to be shown with the Control. It is highly recommended to let the system default the color unless the default is not suitable for the application.

Return
ColorStateList? background color to use This value may be null.

getCustomIcon

Added in API level 30
fun getCustomIcon(): Icon?

Optional icon to be shown with the Control. It is highly recommended to let the system default the icon unless the default icon is not suitable.

Return
Icon? icon to show This value may be null.

getDeviceType

Added in API level 30
fun getDeviceType(): Int
Return
Int type of device represented by this Control, used to determine the default icon and color Value is android.service.controls.DeviceTypes#TYPE_GENERIC_ON_OFF, android.service.controls.DeviceTypes#TYPE_GENERIC_START_STOP, android.service.controls.DeviceTypes#TYPE_GENERIC_OPEN_CLOSE, android.service.controls.DeviceTypes#TYPE_GENERIC_LOCK_UNLOCK, android.service.controls.DeviceTypes#TYPE_GENERIC_ARM_DISARM, android.service.controls.DeviceTypes#TYPE_GENERIC_TEMP_SETTING, android.service.controls.DeviceTypes#TYPE_GENERIC_VIEWSTREAM, android.service.controls.DeviceTypes#TYPE_UNKNOWN, android.service.controls.DeviceTypes#TYPE_AC_HEATER, android.service.controls.DeviceTypes#TYPE_AC_UNIT, android.service.controls.DeviceTypes#TYPE_AIR_FRESHENER, android.service.controls.DeviceTypes#TYPE_AIR_PURIFIER, android.service.controls.DeviceTypes#TYPE_COFFEE_MAKER, android.service.controls.DeviceTypes#TYPE_DEHUMIDIFIER, android.service.controls.DeviceTypes#TYPE_DISPLAY, android.service.controls.DeviceTypes#TYPE_FAN, android.service.controls.DeviceTypes#TYPE_HOOD, android.service.controls.DeviceTypes#TYPE_HUMIDIFIER, android.service.controls.DeviceTypes#TYPE_KETTLE, android.service.controls.DeviceTypes#TYPE_LIGHT, android.service.controls.DeviceTypes#TYPE_MICROWAVE, android.service.controls.DeviceTypes#TYPE_OUTLET, android.service.controls.DeviceTypes#TYPE_RADIATOR, android.service.controls.DeviceTypes#TYPE_REMOTE_CONTROL, android.service.controls.DeviceTypes#TYPE_SET_TOP, android.service.controls.DeviceTypes#TYPE_STANDMIXER, android.service.controls.DeviceTypes#TYPE_STYLER, android.service.controls.DeviceTypes#TYPE_SWITCH, android.service.controls.DeviceTypes#TYPE_TV, android.service.controls.DeviceTypes#TYPE_WATER_HEATER, android.service.controls.DeviceTypes#TYPE_DISHWASHER, android.service.controls.DeviceTypes#TYPE_DRYER, android.service.controls.DeviceTypes#TYPE_MOP, android.service.controls.DeviceTypes#TYPE_MOWER, android.service.controls.DeviceTypes#TYPE_MULTICOOKER, android.service.controls.DeviceTypes#TYPE_SHOWER, android.service.controls.DeviceTypes#TYPE_SPRINKLER, android.service.controls.DeviceTypes#TYPE_WASHER, android.service.controls.DeviceTypes#TYPE_VACUUM, android.service.controls.DeviceTypes#TYPE_AWNING, android.service.controls.DeviceTypes#TYPE_BLINDS, android.service.controls.DeviceTypes#TYPE_CLOSET, android.service.controls.DeviceTypes#TYPE_CURTAIN, android.service.controls.DeviceTypes#TYPE_DOOR, android.service.controls.DeviceTypes#TYPE_DRAWER, android.service.controls.DeviceTypes#TYPE_GARAGE, android.service.controls.DeviceTypes#TYPE_GATE, android.service.controls.DeviceTypes#TYPE_PERGOLA, android.service.controls.DeviceTypes#TYPE_SHUTTER, android.service.controls.DeviceTypes#TYPE_WINDOW, android.service.controls.DeviceTypes#TYPE_VALVE, android.service.controls.DeviceTypes#TYPE_LOCK, android.service.controls.DeviceTypes#TYPE_SECURITY_SYSTEM, android.service.controls.DeviceTypes#TYPE_HEATER, android.service.controls.DeviceTypes#TYPE_REFRIGERATOR, android.service.controls.DeviceTypes#TYPE_THERMOSTAT, android.service.controls.DeviceTypes#TYPE_CAMERA, android.service.controls.DeviceTypes#TYPE_DOORBELL, or android.service.controls.DeviceTypes#TYPE_ROUTINE

getStatusText

Added in API level 30
fun getStatusText(): CharSequence
Return
CharSequence user-facing text description of the Control's status, describing its current state This value cannot be null.

getStructure

Added in API level 30
fun getStructure(): CharSequence?

Optional top-level group to help define the Control's location, visible to the user. If not present, the application name will be used as the top-level group. A structure contains zones which contains controls.

Return
CharSequence? name of the structure containing the control This value may be null.

getSubtitle

Added in API level 30
fun getSubtitle(): CharSequence
Return
CharSequence additional information about the Control, to appear underneath the title This value cannot be null.

getTitle

Added in API level 30
fun getTitle(): CharSequence
Return
CharSequence the user facing name of the Control This value cannot be null.

getZone

Added in API level 30
fun getZone(): CharSequence?

Optional group name to help define the Control's location within a structure, visible to the user. A structure contains zones which contains controls.

Return
CharSequence? name of the zone containing the control This value may be null.

isAuthRequired

Added in API level 33
fun isAuthRequired(): Boolean
Return
Boolean true if the control can not be interacted with until the device is unlocked

writeToParcel

Added in API level 30
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 30
static val CREATOR: Parcelable.Creator<Control!>