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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Indicates if the request object has had close called.protected boolean
Indicates whether a result has been sent to the receiver yet.protected final AntPluginPcc.IPluginAccessResultReceiver<T>
This is our internal handler for the access result.protected final Object
Lock object used to protect access to all state.protected final AntPluginPcc.IDeviceStateChangeReceiver
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PccReleaseHandle
(AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) Constructs a new access request object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Cancels the request for device access.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.protected abstract void
This method indicates to the lower layer that the request has been cancelled.
-
Field Details
-
isClosed
protected volatile boolean isClosedIndicates if the request object has had close called. -
resultSent
protected boolean resultSentIndicates whether a result has been sent to the receiver yet. -
stateLock
Lock object used to protect access to all state. -
resultSink
This is our internal handler for the access result. -
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 toresultSink
andstateSink
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 aUSER_CANCELLED
result to be sent to theAntPluginPcc.IPluginAccessResultReceiver
. If the access request was made on anAsyncScanController
then the controller is guaranteed to be properly closed, ie. you will not have to worry about callingAsyncScanController.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 theAsyncScanController
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.
-