Class AsyncScanController<T extends AntPluginPcc>
java.lang.Object
com.dsi.ant.plugins.antplus.pccbase.AsyncScanController<T>
- Type Parameters:
T
- The type of plugin PCC the scan is attempting to connect to.
- Direct Known Subclasses:
AntPlusBaseRemoteControlPcc.RemoteControlAsyncScanController
,AntPlusBikeSpdCadCommonPcc.BikeSpdCadAsyncScanController
Controls a scan for devices available to connect to, and requesting access to one of those available devices.
The scan is not closed until a device is connected or a failure occurs.
If you have an open async scan controller you must ensure it is closed;
you can know the scan is closed if any of the following happen:
- You call
closeScanController()
- Your
AsyncScanController.IAsyncScanResultReceiver.onSearchStopped(com.dsi.ant.plugins.antplus.pcc.defines.RequestAccessResult)
callback is called - You successfully request access to a device using
requestDeviceAccess(AsyncScanResultDeviceInfo, IPluginAccessResultReceiver, IDeviceStateChangeReceiver)
- You call
PccReleaseHandle.close()
on the release handle received after requesting access
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Contains the data describing a device detected by the scan.static interface
Receives results and failures of an async scan. -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes the current scan and any pending access request.static String
Retrieves the display name of the last reported missing dependency.static String
Retrieves the package name of the last reported missing dependency.protected android.os.Handler
protected void
handleReqAccSuccess
(android.os.Message msg, T retPccObject, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver) protected PccReleaseHandle<T>
requestDeviceAccess
(AsyncScanController.AsyncScanResultDeviceInfo deviceToConnectTo, android.os.Bundle customParams, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) requestDeviceAccess
(AsyncScanController.AsyncScanResultDeviceInfo deviceToConnectTo, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) Sends a request to access the selected device and receive a live PCC instance.protected void
sendFailureToReceiver
(RequestAccessResult requestAccessResult) protected void
sendResultToReceiver
(android.os.Bundle result)
-
Field Details
-
scanResultReceiver
-
-
Constructor Details
-
AsyncScanController
-
-
Method Details
-
closeScanController
public void closeScanController()Closes the current scan and any pending access request. This will trigger an event on yourAsyncScanController.IAsyncScanResultReceiver.onSearchStopped(com.dsi.ant.plugins.antplus.pcc.defines.RequestAccessResult)
with the codeRequestAccessResult.USER_CANCELLED
. Additionally, if you have a pending access request it will return a failure on the result callback. If the result is already received this will not close the device. Use thePccReleaseHandle.close()
instead if that is the desired behavior. It is safe for an application to call both close methods. -
sendFailureToReceiver
-
sendResultToReceiver
protected void sendResultToReceiver(android.os.Bundle result) -
handleReqAccSuccess
protected void handleReqAccSuccess(android.os.Message msg, T retPccObject, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver) -
requestDeviceAccess
public PccReleaseHandle<T> requestDeviceAccess(AsyncScanController.AsyncScanResultDeviceInfo deviceToConnectTo, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) Sends a request to access the selected device and receive a live PCC instance. This will pause the scan and start an asynchronous search for the device and return the result on the provided result receiver. The search will timeout after 10s, after which the async scan will resume and you can retry if you wish.- Parameters:
deviceToConnectTo
- The device to attempt to connect to.resultReceiver
- The receiver to receive the results of the request. Possible returns include:stateReceiver
- The receiver to receive the state updates of the accessed device, assuming the request is successful. This receiver will receive notifications of all state changes to the device that occur subsequent to the initial state returned in the result receiver.- Returns:
- A release handle for the device. This can be used to guarantee the device is properly shutdown and cleaned up, even before the device is actually received through the result receiver. Calling close on the release handle will additionally stop the asnc scan regardless of the access request result.
-
requestDeviceAccess
protected PccReleaseHandle<T> requestDeviceAccess(AsyncScanController.AsyncScanResultDeviceInfo deviceToConnectTo, android.os.Bundle customParams, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) -
getScanResultHandler
protected android.os.Handler getScanResultHandler() -
getMissingDependencyPackageName
Retrieves the package name of the last reported missing dependency. When the scan is stopped due to anRequestAccessResult.DEPENDENCY_NOT_INSTALLED
error, this function can be used to retrieve the package name of the missing required package. This package name can be used to acquire the required package from the Play Store or elsewhere.- Returns:
- The package name of the last reported missing dependency.
-
getMissingDependencyName
Retrieves the display name of the last reported missing dependency. When the scan is stopped due to anRequestAccessResult.DEPENDENCY_NOT_INSTALLED
error, this function can be used to retrieve the display name of the missing required package. This name can be used to display to the user the missing dependency.- Returns:
- The display name of the last reported missing dependency.
-