com.taztag.peripheralmanagement
Class PeripheralManager

java.lang.Object
  extended by com.taztag.peripheralmanagement.PeripheralManager

public abstract class PeripheralManager
extends java.lang.Object

The PeripheralManager abstract class is used to activate or deactivate power of peripherals on theperipheral. This class is a client for the Device Manager service, which manages the power of the peripherals.

To set power on a peripheral, use the following steps:

  1. Implements an instance of PeripheralManager from PeripheralManager(Context context).
     PeripheralManager peripheralManager = new PeripheralManager(this) {
            public void onPeripheralManagerUnavailable() {
          (...)
            }
            public void onPeripheralManagerReady() {
          (...)
            }
    
    }
     
  2. after callback onPeripheralManagerReady() is called, use #setPower(String peripheral, boolean state) to power on a peripheral.
            public void onPeripheralManagerReady() {
                 peripheralManager.setPower(PeripheralManager.FINGERPRINT, true);
            }
     
     


    Field Summary
    static java.lang.String ACTION_PERIPHMNGMT_SETTINGS
              Activity Action: Show Peripherals Management settings.
    static java.lang.String CARD_READER
              Used to manage card reader power
    static java.lang.String CRADLE
              Used to manage USB cradle power
    static java.lang.String EXTRA_PERIPH_NAME
               
    static java.lang.String EXTRA_PERIPH_STATE
               
    static java.lang.String FINGERPRINT
              Used to manage fingerprint power
    static java.lang.String MSRREADER
              Used to manage msr power
    static java.lang.String OCRREADER
              Used to manage ocr power
    static java.lang.String PERIPH_STATE_CHANGED
               
    static java.lang.String SECMODULE
               
    static int STATE_OFF
               
    static int STATE_ON
              Describes the peripheral state returned by "getPeripheralState" in the TazTagPowerService Possible values are: STATE_OFF, STATE_TURNING_ON, STATE_ON, STATE_TURNING_OFF,
    static int STATE_TURNING_OFF
               
    static int STATE_TURNING_ON
               
    static java.lang.String USB_HOST
              Used to manage USB host power
     
    Constructor Summary
    PeripheralManager(android.content.Context context)
              Gets a PeripheralManager instance.
     
    Method Summary
     void disconnectPeripheralManager()
               Release the PeripheralManager instance.
     java.lang.String[] getAllPeripheralNames()
               
     boolean getPeriphConnectedState(java.lang.String peripheral)
               
     int getPeripheralState(java.lang.String periph)
               
     boolean getPeriphPowerState(java.lang.String peripheral)
               
    abstract  void onPeripheralManagerReady()
               Callback called after PeripheralManager(Context context) is called to notify that power service is ready.
    abstract  void onPeripheralManagerUnavailable()
               Callback called after PeripheralManager() is called to notify that power service is not available.
     boolean setPeriphPowerState(java.lang.String peripheral, boolean state)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    USB_HOST

    public static final java.lang.String USB_HOST
    Used to manage USB host power

    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    CRADLE

    public static final java.lang.String CRADLE
    Used to manage USB cradle power

    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    FINGERPRINT

    public static final java.lang.String FINGERPRINT
    Used to manage fingerprint power

    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    CARD_READER

    public static final java.lang.String CARD_READER
    Used to manage card reader power

    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    SECMODULE

    public static final java.lang.String SECMODULE
    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    OCRREADER

    public static final java.lang.String OCRREADER
    Used to manage ocr power

    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    MSRREADER

    public static final java.lang.String MSRREADER
    Used to manage msr power

    See Also:
    #setPower(String peripheral, boolean state), #getPower(String periph), #onResult(String peripheral, boolean status), Constant Field Values

    STATE_ON

    public static final int STATE_ON
    Describes the peripheral state returned by "getPeripheralState" in the TazTagPowerService Possible values are: STATE_OFF, STATE_TURNING_ON, STATE_ON, STATE_TURNING_OFF,

    See Also:
    Constant Field Values

    STATE_OFF

    public static final int STATE_OFF
    See Also:
    Constant Field Values

    STATE_TURNING_ON

    public static final int STATE_TURNING_ON
    See Also:
    Constant Field Values

    STATE_TURNING_OFF

    public static final int STATE_TURNING_OFF
    See Also:
    Constant Field Values

    PERIPH_STATE_CHANGED

    public static final java.lang.String PERIPH_STATE_CHANGED
    See Also:
    Constant Field Values

    EXTRA_PERIPH_NAME

    public static final java.lang.String EXTRA_PERIPH_NAME
    See Also:
    Constant Field Values

    EXTRA_PERIPH_STATE

    public static final java.lang.String EXTRA_PERIPH_STATE
    See Also:
    Constant Field Values

    ACTION_PERIPHMNGMT_SETTINGS

    public static final java.lang.String ACTION_PERIPHMNGMT_SETTINGS
    Activity Action: Show Peripherals Management settings.

    This shows UI that allows the (internal and external) peripherals to be turned on or off.

    In some cases, a matching Activity may not exist, so ensure you safeguard against this.

    Input: Nothing.

    Output: Nothing

    See Also:
    Constant Field Values
    Constructor Detail

    PeripheralManager

    public PeripheralManager(android.content.Context context)

    Gets a PeripheralManager instance. Once PeripheralManager service is connected, a callback is called (@see #onPeripheralManagerReady() ) Otherwise @see #onPeripheralManagerUnavailable() is called.

    Parameters:
    context - the calling application's context
    Method Detail

    disconnectPeripheralManager

    public void disconnectPeripheralManager()

    Release the PeripheralManager instance. This function should be called only if PeripheralManager instance is no more called.


    setPeriphPowerState

    public boolean setPeriphPowerState(java.lang.String peripheral,
                                       boolean state)
    Parameters:
    state - true means peripheral is powered on, false means peripheral is powered off
    Returns:
    true if command has been sent correctly to PeripheralManager service
    false if the service connection failed (service not connected or remote exception) this function will always returns false.

    getPeriphPowerState

    public boolean getPeriphPowerState(java.lang.String peripheral)
    Parameters:
    status - the status of the last command
    Returns:
    false if the service connection failed (service not connected or remote exception) this function will always returns false.

    getPeriphConnectedState

    public boolean getPeriphConnectedState(java.lang.String peripheral)

    getPeripheralState

    public int getPeripheralState(java.lang.String periph)
    Parameters:
    periph - :
    Returns:

    getAllPeripheralNames

    public java.lang.String[] getAllPeripheralNames()

    onPeripheralManagerReady

    public abstract void onPeripheralManagerReady()

    Callback called after PeripheralManager(Context context) is called to notify that power service is ready. After this call, setPower() and getPower() functions are available.

    See Also:
    PeripheralManager(Context context)

    onPeripheralManagerUnavailable

    public abstract void onPeripheralManagerUnavailable()

    Callback called after PeripheralManager() is called to notify that power service is not available.