Class PccReleaseHandle<T extends AntPluginPcc>

java.lang.Object
com.dsi.ant.plugins.antplus.pccbase.PccReleaseHandle<T>
Type Parameters:
T - The device type this release handle is associated with.
Direct Known Subclasses:
AntPluginPcc.StandardReleaseHandle

public abstract class PccReleaseHandle<T extends AntPluginPcc> extends Object
This class is a handle that can be used to close a device, or cancel the access request for the device. Using this handle is the safest way to make sure everything is cleaned up properly for a device.
  • Field Details

    • isClosed

      protected volatile boolean isClosed
      Indicates if the request object has had close called.
    • resultSent

      protected boolean resultSent
      Indicates whether a result has been sent to the receiver yet.
    • stateLock

      protected final Object stateLock
      Lock object used to protect access to all state.
    • resultSink

      protected final AntPluginPcc.IPluginAccessResultReceiver<T extends AntPluginPcc> resultSink
      This is our internal handler for the access result.
    • stateSink

      protected final AntPluginPcc.IDeviceStateChangeReceiver stateSink
  • Constructor Details

    • PccReleaseHandle

      protected PccReleaseHandle(AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver)
      Constructs a new access request object. The receivers passed in here should be the receivers where result and state would normally be sent. The creator of this object should now forward these events to resultSink and stateSink instead.
      Parameters:
      resultReceiver - The app's result receiver.
      stateReceiver - The app's state receiver.
  • Method Details

    • close

      public void close()
      Cancels the request for device access. If access to the device has already been received, the device will be automatically closed. If access has not been received this will cause a USER_CANCELLED result to be sent to the AntPluginPcc.IPluginAccessResultReceiver. If the access request was made on an AsyncScanController then the controller is guaranteed to be properly closed, ie. you will not have to worry about calling AsyncScanController.closeScanController().
    • isActive

      protected boolean isActive()
      Used to check of the device is in an active state, that is the app has received a result and has not called close on the device.
    • requestCancelled

      protected abstract void requestCancelled()
      This method indicates to the lower layer that the request has been cancelled. This is so far used by the AsyncScanController so that it knows to close itself if the result was a search timeout. The request itself does not need to be cancelled at the lower layers, the device will be released if needed when the result is received.