UserSensor.Builder
  public
  static
  
  
  class
  UserSensor.Builder
  
    extends Object
  
  
  
  
  
  
  
    
    | java.lang.Object | 
  
  
    
      | ↳ | com.google.android.things.userdriver.sensor.UserSensor.Builder | 
  
  
    
  Builder to allow for flexible UserSensor construction.
 
Most parameters are given default values and can be skipped if not needed. The only
 required calls are setDriver(UserSensorDriver) and either setType(int) or setCustomType(int, String, int).
 
See the 
 Sensor HAL documentation for details on how each parameter is used.
 
Example usage:
 
 UserSensor sensor = new UserSensor.Builder()
         .setName("ABC123 Accelerometer")
         .setType(Sensor.TYPE_ACCELEROMETER)
         .setDriver(myDriverObject)
         .build();
 
Summary
| Inherited methods | 
|---|
|  From
class 
  
    java.lang.Object
  
  
   
    
      
  
  
  
  
    | 
        
        
        
        
        
        Object | 
      clone()
      Creates and returns a copy of this object.
        
    
 |  
  
  
    | 
        
        
        
        
        
        boolean | 
      equals(Object obj)
      Indicates whether some other object is "equal to" this one.
        
    
 |  
  
  
    | 
        
        
        
        
        
        void | 
      finalize()
      Called by the garbage collector on an object when garbage collection
 determines that there are no more references to the object.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        Class<?> | 
      getClass()
      Returns the runtime class of this Object. |  
  
  
    | 
        
        
        
        
        
        int | 
      hashCode()
      Returns a hash code value for the object.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        void | 
      notify()
      Wakes up a single thread that is waiting on this object's
 monitor.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        void | 
      notifyAll()
      Wakes up all threads that are waiting on this object's monitor.
        
    
 |  
  
  
    | 
        
        
        
        
        
        String | 
      toString()
      Returns a string representation of the object.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        void | 
      wait(long millis, int nanos)
      Causes the current thread to wait until another thread invokes the
 notify()method or thenotifyAll()method for this object, or
 some other thread interrupts the current thread, or a certain
 amount of real time has elapsed. |  
  
  
    | 
        
        
        
        final
        
        void | 
      wait(long millis)
      Causes the current thread to wait until either another thread invokes the
 notify()method or thenotifyAll()method for this object, or a
 specified amount of time has elapsed. |  
  
  
    | 
        
        
        
        final
        
        void | 
      wait()
      Causes the current thread to wait until another thread invokes the
 notify()method or thenotifyAll()method for this object. |  | 
Public constructors
    UserSensor.Builder
    
UserSensor.Builder ()
    
    
    
  
 
Public methods
    build
    
UserSensor build ()
    
    
    
  Returns a new UserSensor with the configured parameters.
    
      
  
 
    setCustomType
    
UserSensor.Builder setCustomType (int type, 
                String stringType, 
                int reportingMode)
    
    
    
  Sets a custom driver type and reporting mode.
 
This can be used to install a custom driver type that is not currently defined as an
 Android sensor, e.g. a radiation detector. It's up to the sensor to define what the
 returned float array represents and the user to interpret these values correctly.
    
    | Parameters | 
|---|
      
        | type | int: sensor type int value, must be greater than or equal toandroid.hardware.Sensor.TYPE_DEVICE_PRIVATE_BASE | 
      
        | stringType | String: sensor type description in reverse-domain format e.g.com.companyname.radiationdetector | 
      
        | reportingMode | int:android.hardware.Sensor.REPORTING_MODE_*constant | 
    
    
      
  
 
    setMaxDelay
    
UserSensor.Builder setMaxDelay (int maxDelay)
    
    
    
  Sets the maximum allowed delay between sensor reads in microseconds.
    
    
      
  
 
    setMaxRange
    
UserSensor.Builder setMaxRange (float maxRange)
    
    
    
  Sets the max sensor range.
 
The sensor should be able to report values without saturating within
 [-maxRange, maxRange] in the sensor's reporting units.
    
    | Parameters | 
|---|
      
        | maxRange | float: maximum sensor range in the sensor's reporting units | 
    
    
      
  
  
 
    setMinDelay
    
UserSensor.Builder setMinDelay (int minDelay)
    
    
    
  Sets the minimum allowed delay between sensor reads in microseconds.
 
Should not be called for one shot sensors ie Sensor.REPORTING_MODE_ONE_SHOT
    
    
      
  
 
    setName
    
UserSensor.Builder setName (String name)
    
    
    
  Sets the sensor name.
 Usually contains the part name and sensor type, e.g. "ABC001 Accelerometer".
    
    
      
  
 
    setPower
    
UserSensor.Builder setPower (float power)
    
    
    
  Sets the power cost in milliAmps of enabling the sensor.
    
    
      
  
 
    setResolution
    
UserSensor.Builder setResolution (float resolution)
    
    
    
  Sets the sensor resolution.
 
Sensor resolution is the smallest discernable difference the sensor can measure.
 Usually calculated based on max range and the number of bits available.
    
    | Parameters | 
|---|
      
        | resolution | float: sensor resolution in the sensor's reporting units | 
    
    
      
  
  
 
    setType
    
UserSensor.Builder setType (int type)
    
    
    
  Sets the driver type.
 
Use this to set the driver to be a known Android sensor type. For custom sensor
 types, use setCustomType(int, String, int) instead.
    
    | Parameters | 
|---|
      
        | type | int:android.hardware.Sensortype | 
    
    
      
  
 
    setUuid
    
UserSensor.Builder setUuid (UUID uuid)
    
    
    
  Sets a UUID to identify this sensor.
 
This is only useful when multiple sensors of the exact same type are connected, to be
 able to distinguish between them. Normally this can be left at the default 0.
 
Apps will not see this value directly, but can use android.hardware.Sensor.getId() to distinguish between sensors with non-zero UUIDs.
    
    | Parameters | 
|---|
      
        | uuid | UUID: UUID to assign this sensor, or null for 0 |