Control

public final class Control
extends Object implements Parcelable

java.lang.Object
   ↳ 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.DeviceType. 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

class Control.StatefulBuilder

Builder class for Control that contains state information. 

class Control.StatelessBuilder

Builder class for Control

Constants

int STATUS_DISABLED

The Control is currently disabled.

int STATUS_ERROR

The device corresponding to the Control is in an error state.

int STATUS_NOT_FOUND

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

int STATUS_OK

The device corresponding to the Control is responding correctly.

int STATUS_UNKNOWN

Inherited constants

Fields

public static final Creator<Control> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

PendingIntent getAppIntent()
String getControlId()
ControlTemplate getControlTemplate()
ColorStateList getCustomColor()

Optional color to be shown with the Control.

Icon getCustomIcon()

Optional icon to be shown with the Control.

int getDeviceType()
int getStatus()
CharSequence getStatusText()
CharSequence getStructure()

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

CharSequence getSubtitle()
CharSequence getTitle()
CharSequence getZone()

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

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

STATUS_DISABLED

public static final int STATUS_DISABLED

The Control is currently disabled.

Constant Value: 4 (0x00000004)

STATUS_ERROR

public static final int STATUS_ERROR

The device corresponding to the Control is in an error state.

Constant Value: 3 (0x00000003)

STATUS_NOT_FOUND

public static final int STATUS_NOT_FOUND

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

Constant Value: 2 (0x00000002)

STATUS_OK

public static final int STATUS_OK

The device corresponding to the Control is responding correctly.

Constant Value: 1 (0x00000001)

STATUS_UNKNOWN

public static final int STATUS_UNKNOWN

Constant Value: 0 (0x00000000)

Fields

CREATOR

public static final Creator<Control> CREATOR

Public methods

describeContents

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getAppIntent

public PendingIntent getAppIntent ()

Returns
PendingIntent a PendingIntent linking to an Activity for the Control This value cannot be null.

getControlId

public String getControlId ()

Returns
String the identifier for the Control This value cannot be null.

getControlTemplate

public ControlTemplate getControlTemplate ()

Returns
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

public ColorStateList getCustomColor ()

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.

Returns
ColorStateList background color to use This value may be null.

getCustomIcon

public Icon getCustomIcon ()

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.

Returns
Icon icon to show This value may be null.

getDeviceType

public int getDeviceType ()

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

getStatus

public int getStatus ()

Returns
int status of the Control, used to convey information about the attempt to fetch the current state Value is STATUS_UNKNOWN, STATUS_OK, STATUS_NOT_FOUND, STATUS_ERROR, or STATUS_DISABLED

getStatusText

public CharSequence getStatusText ()

Returns
CharSequence user-facing text description of the Control's status, describing its current state This value cannot be null.

getStructure

public CharSequence getStructure ()

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.

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

getSubtitle

public CharSequence getSubtitle ()

Returns
CharSequence additional information about the Control, to appear underneath the title This value cannot be null.

getTitle

public CharSequence getTitle ()

Returns
CharSequence the user facing name of the Control This value cannot be null.

getZone

public CharSequence getZone ()

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

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

writeToParcel

public void writeToParcel (Parcel dest, 
                int flags)

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.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES