Class AntPluginPcc

java.lang.Object
com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
Direct Known Subclasses:
AntPlusBaseControllableDevicePcc, AntPlusBloodPressurePcc, AntPlusCommonPcc, AntPlusGeocachePcc, AntPlusLegacyCommonPcc, AntPlusWatchDownloaderPcc

public abstract class AntPluginPcc extends Object
Defines the base interface and common routines to all PCCs.
  • Field Details

    • PATH_ANTPLUS_PLUGINS_PKG

      public static final String PATH_ANTPLUS_PLUGINS_PKG
      The official ANT+ plugins package name
      See Also:
    • reportedServiceVersion

      protected int reportedServiceVersion
    • supportsRssiEvent

      protected boolean supportsRssiEvent
    • mStateChangeReceiver

      protected AntPluginPcc.IDeviceStateChangeReceiver mStateChangeReceiver
    • mReleaseHandle

      protected volatile PccReleaseHandle<?> mReleaseHandle
  • Constructor Details

    • AntPluginPcc

      public AntPluginPcc()
  • Method Details

    • getServiceBindIntent

      protected abstract android.content.Intent getServiceBindIntent()
    • getRequiredServiceVersionForBind

      protected abstract int getRequiredServiceVersionForBind()
    • handlePluginEvent

      protected abstract void handlePluginEvent(android.os.Message eventMsg)
    • getPluginPrintableName

      protected abstract String getPluginPrintableName()
    • getInstalledPluginsVersionNumber

      public static int getInstalledPluginsVersionNumber(android.content.Context currentContext)
      Returns the version code of the installed plugins package or -1 if not installed or -2 if disabled.
      Parameters:
      currentContext - A valid context (to access the Android package manager)
      Returns:
      The version code of the installed plugins package or -1 if not installed or -2 if disabled.
    • getInstalledPluginsVersionString

      public static String getInstalledPluginsVersionString(android.content.Context currentContext)
      Returns the version string of the installed plugins package or null if not installed.
      Parameters:
      currentContext - A valid context (to access the Android package manager)
      Returns:
      The version string of the installed plugins package or null if not installed.
    • startPluginManagerActivity

      public static boolean startPluginManagerActivity(android.app.Activity activity)
      Launches the ANT+ Plugin Manager. The ANT+ Plugin Manager provides access to view and modify devices saved in the plugin device database and control default plugin settings. It is also available as a stand alone application, but the ability to launch it from your own application is useful in situations where a user wants extra convenience or doesn't already have the stand alone launcher installed. For example, you could place this launch command in your application's own settings menu.
      Parameters:
      activity - The activity to launch the plugin manager activity from.
      Returns:
      True if ANT+ Plugins is installed and enabled and the activity will successfully start. False if ANT+ Plugins is not installed or not enabled and the activity will fail to start.
    • getMissingDependencyPackageName

      public static String getMissingDependencyPackageName()
      Retrieves the package name of the last reported missing dependency. When the result of requesting access is RequestAccessResult.DEPENDENCY_NOT_INSTALLED, 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

      public static String getMissingDependencyName()
      Retrieves the display name of the last reported missing dependency. When the result of requesting access is RequestAccessResult.DEPENDENCY_NOT_INSTALLED, 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.
    • requestAccess_Helper_SearchActivity

      protected static <T extends AntPluginPcc> PccReleaseHandle<T> requestAccess_Helper_SearchActivity(android.app.Activity foregroundActivity, android.content.Context bindingContext, boolean skipPreferredSearch, int searchProximityThreshold, T retPccObject, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver)
      This overload requests the plugin to show UI showing the connection progress and handling interacting with the user
      Type Parameters:
      T - The type of the PCC being requested.
      Parameters:
      foregroundActivity - The current foreground activity that an activity can be launched from.
      bindingContext - The context to which the plugin will be bound. Used for plugin lifecycle management.
      skipPreferredSearch - True = Don't automatically connect to user's preferred device, but always go to search for other devices.
      searchProximityThreshold - This value represents the signal strength 'proximity' requirement on finding matches during searching, if a device does not meet the requirements it will not show up in the search at all. The value is a generic signal strength threshold from 1-10 where 1 is the strongest (ie: closest) and 10 is the lowest(ie: farthest away). 0 = don't use proximity search and -1 = use plugin user-specified default.
      retPccObject - The potential PCC to be returned, needed to hook up the plugin IPC before the result is returned.
      resultReceiver - The receiver to receive the results of the request.
      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.
    • requestAccess_Helper_AsyncSearchByDevNumber

      protected static <T extends AntPluginPcc> PccReleaseHandle<T> requestAccess_Helper_AsyncSearchByDevNumber(android.content.Context bindingContext, int antDeviceNumber, int searchProximityThreshold, T retPccObject, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver)
      This overload requests connecting to a specific deviceNumber. If the deviceNumber is 0, this request is for the first available/found device.
      Type Parameters:
      T - The type of the PCC being requested.
      Parameters:
      bindingContext - The context to which the plugin will be bound. Used for plugin lifecycle management.
      antDeviceNumber - The device ID of the device to search for.
      searchProximityThreshold - This value represents the signal strength 'proximity' requirement on finding matches during searching, if a device does not meet the requirements it will not show up in the search at all. The value is a generic signal strength threshold from 1-10 where 1 is the strongest (ie: closest) and 10 is the lowest(ie: farthest away). 0 = don't use proximity search.
      retPccObject - The potential PCC to be returned, needed to hook up the plugin IPC before the result is returned.
      resultReceiver - The receiver to receive the results of the request.
      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.
    • requestAccess_Helper_AsyncScanController

      protected static <T extends AntPluginPcc> AsyncScanController<T> requestAccess_Helper_AsyncScanController(android.content.Context bindingContext, int searchProximityThreshold, T retPccObject, AsyncScanController.IAsyncScanResultReceiver scanResultReceiver)
    • requestAccess_Helper_Main

      protected static <T extends AntPluginPcc> PccReleaseHandle<T> requestAccess_Helper_Main(android.content.Context bindingContext, android.os.Bundle reqParams, T retPccObject, AntPluginPcc.RequestAccessResultHandler<T> reqAccessResultHandler, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver)
      Sends the request to the plugin service activity to give us access to a device
      Type Parameters:
      T - The type of the PCC being requested.
      Parameters:
      bindingContext - The context to which the plugin will be bound. Used for plugin lifecycle management.
      reqParams - The bundle containing the access specific parameters. The default parameters will be added to this bundle and sent as the request.
      retPccObject - The potential PCC to be returned, needed to hook up the plugin IPC before the result is returned.
      reqAccessResultHandler - The access result handler implementation to handle the responses from the plugin.
      resultReceiver - The receiver to receive the results of the request.
      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.
    • requestAsyncScan_Helper_SubMain

      protected static <T extends AntPluginPcc> AsyncScanController<T> requestAsyncScan_Helper_SubMain(android.content.Context bindingContext, int searchProximityThreshold, android.os.Bundle reqParams, T retPccObject, AsyncScanController<T> controller)
    • requestAccess_Helper_SubMain

      protected static <T extends AntPluginPcc> void requestAccess_Helper_SubMain(android.content.Context bindingContext, android.os.Bundle reqParams, T retPccObject, android.os.Handler resultHandler)
    • bindAndRequest

      protected void bindAndRequest(android.content.Context bindingContext, android.os.Bundle b, android.os.Handler resultHandler)
    • handleNonCmdPluginMessage

      protected void handleNonCmdPluginMessage(android.os.Message msg)
    • getDeviceName

      public String getDeviceName()
      Retrieves a display friendly name for the device accessed by this PCC. This name is the user's saved name if this device is saved in the user's device database, or a generated name if it isn't.
      Returns:
      The name of the device this PCC is accessing.
    • getAntDeviceNumber

      public int getAntDeviceNumber()
      Retrieves the deviceNumber of the device accessed by this PCC.
      Returns:
      The ANT channel deviceNumber of the device this PCC is accessing. If the value is negative it means the plugin does not support this function.
    • isUserRecognizedDevice

      public boolean isUserRecognizedDevice()
      Returns a value indicating if this device has been saved to the user's device database.
      Returns:
      True if the device is saved in the user's device database.
    • isUserPreferredDeviceForPlugin

      public boolean isUserPreferredDeviceForPlugin()
      Returns a value indicating if this device is set as the preferred device for this plugin type in the user's device database.
      Returns:
      True if the device is set as the preferred device for this plugin.
    • getCurrentDeviceState

      public DeviceState getCurrentDeviceState()
      Retrieves the current device state.
      Returns:
      The DeviceState of the current device state.
    • createCmdMsg

      protected android.os.Message createCmdMsg(int cmdCode, android.os.Bundle msgData)
    • sendPluginCommand

      protected android.os.Message sendPluginCommand(int cmdCode, android.os.Bundle msgData)
    • sendPluginCommand

      protected android.os.Message sendPluginCommand(android.os.Message cmdMsg)
    • subscribeToEvent

      protected boolean subscribeToEvent(int eventCode)
    • unsubscribeFromEvent

      protected void unsubscribeFromEvent(int eventCode)
    • releaseAccess

      public void releaseAccess()
      Signals plugin to release our access to the device and shuts down this PCC. This function should be called to close every PCC obtained in a successful access request when an application is done using the PCC or the application is closing. Note: This is equivalent to calling PccReleaseHandle.close()
    • closePluginConnection

      protected void closePluginConnection()
      Aborts connection with Plugin Service: quits the Message and Event Handler Threads, and unbinds from the service