Device

public final class Device extends Object
implements Parcelable

Representation of an integrated device (such as a phone or a wearable) that can hold sensors. Each sensor is exposed as a DataSource.

The main purpose of the Device information contained in this class is to identify the hardware of a particular data source. This can be useful in different ways, including:

  • distinguishing two similar sensors on different devices (the step counter on two nexus 5 phones, for instance)
  • display the source of data to the user (by using the device make / model)
  • treat data differently depending on sensor type (accelerometers on a watch may give different patterns than those on a phone)
  • build different analysis models for each device/version.

Constant Summary

int TYPE_CHEST_STRAP Constant indicating the device is a chest strap.
int TYPE_HEAD_MOUNTED Constant indicating the device is a headset, pair of glasses, or other head-mounted device
int TYPE_PHONE Constant indicating the device is an Android phone.
int TYPE_SCALE Constant indicating the device is a scale or similar device the user steps on.
int TYPE_TABLET Constant indicating the device is an Android tablet.
int TYPE_UNKNOWN Constant indicating the device type is not known.
int TYPE_WATCH Constant indicating the device is a watch or other wrist-mounted band.

Inherited Constant Summary

Public Constructor Summary

Device(String manufacturer, String model, String uid, int type)
Creates a new device.

Public Method Summary

boolean
equals(Object other)
static Device
getLocalDevice(Context context)
Returns the Device representation of the local device, which can be used when defining local data sources.
String
getManufacturer()
Returns the manufacturer of the product/hardware.
String
getModel()
Returns the end-user-visible model name for the device.
int
getType()
Returns the constant representing the type of the device.
String
getUid()
Returns the serial number or other unique ID for the hardware.
int
String
void
writeToParcel(Parcel parcel, int flags)

Inherited Method Summary

Constants

public static final int TYPE_CHEST_STRAP

Constant indicating the device is a chest strap.

Constant Value: 4

public static final int TYPE_HEAD_MOUNTED

Constant indicating the device is a headset, pair of glasses, or other head-mounted device

Constant Value: 6

public static final int TYPE_PHONE

Constant indicating the device is an Android phone.

Constant Value: 1

public static final int TYPE_SCALE

Constant indicating the device is a scale or similar device the user steps on.

Constant Value: 5

public static final int TYPE_TABLET

Constant indicating the device is an Android tablet.

Constant Value: 2

public static final int TYPE_UNKNOWN

Constant indicating the device type is not known.

Constant Value: 0

public static final int TYPE_WATCH

Constant indicating the device is a watch or other wrist-mounted band.

Constant Value: 3

Public Constructors

public Device (String manufacturer, String model, String uid, int type)

Creates a new device.

Parameters
manufacturer The manufacturer of the product/hardware.
model The end-user-visible name for the end product.
uid A serial number or other unique identifier for the particular device hardware.
type The type of device. One of the type constants.

Public Methods

public boolean equals (Object other)

public static Device getLocalDevice (Context context)

Returns the Device representation of the local device, which can be used when defining local data sources.

In general, this won't match the Device returned from data sources created by the platform for recording. This is for two reasons:

  • As described, device UIDs are obfuscated for the calling package,
  • Since Android O, device UIDs are not the same when accessed from different Android packages.
The second point prevents the Device returned by this method from being used to query for local data because it won't match that used by the platform.

public String getManufacturer ()

Returns the manufacturer of the product/hardware.

public String getModel ()

Returns the end-user-visible model name for the device.

public int getType ()

Returns the constant representing the type of the device. This will usually be one of the values from the type constants in this class, but it's not required to be. Any other value should be treated as TYPE_UNKNOWN.

public String getUid ()

Returns the serial number or other unique ID for the hardware.

Device UIDs are obfuscated based on the calling application's package name. Different applications will see different UIDs for the same Device. If two Device instances have the same underlying UID, they'll also have the same obfuscated UID within each app (but not across apps).

public int hashCode ()

public String toString ()

public void writeToParcel (Parcel parcel, int flags)