de.unikassel.android.sdcframework.devices
Class AbstractSensorDevice

Package class diagram package AbstractSensorDevice
java.lang.Object
  extended by de.unikassel.android.sdcframework.devices.AbstractSensorDevice
All Implemented Interfaces:
SensorDevice, VisitableDevice
Direct Known Subclasses:
ScannerStateAwareSensorDevice, SystemBroadcastReceivingDevice, VirtualSensorDevice

public abstract class AbstractSensorDevice
extends Object
implements SensorDevice

Base class for any sensor device type.


Field Summary
private  SensorDeviceConfiguration configuration
          The sensor device configuration
private  SensorDeviceIdentifier deviceIdentifier
          The sensor device deviceIdentifier
private  SensorDeviceScanner scanner
          The scanner for the sensor device
 
Constructor Summary
private AbstractSensorDevice()
          Default constructor ( it's private with purpose )
  AbstractSensorDevice(SensorDeviceIdentifier deviceId)
          Constructor for devices with an Android sub type
 
Method Summary
 boolean accept(SensorDeviceVisitor visitor)
          Method to accept a visitor
 void doHandleDeviceDisabledBySystem(Context context)
          Default handler for the fact, the system device state is changing from enabled to disabled.
 void doHandleDeviceEnabledBySystem(Context context)
          Default handler for the fact, the system device state is changing from disabled to enabled.
protected abstract  void doSignalDeviceNotEnabledInSystem(Context applicationContext)
          Method to signal the user that the device is disabled in the system and needed by this service.
 boolean enableDeviceScanning(boolean enabled, Context context)
          Setter for device scanning enabled state
 SensorDeviceConfiguration getConfiguration()
          Getter for the sensor device configuration
 SensorDeviceIdentifier getDeviceIdentifier()
          Getter for the sensors device identifier
 SensorDeviceScanner getScanner()
          Getter for the scanner
 boolean isAirplaneModeOn(Context applicationContext)
          Getter for the state of the airplaine mode
 boolean isDeviceScanningEnabled()
          Getter for device scanning enabled state in the framework
protected abstract  void onConfigurationChanged()
          Callback to signal configuration of device has changed
 void onCreate(Context context)
          Is called when this device is created
 void onDestroy(Context context)
          Is called when the owner destroys this device
private  void setConfiguration(SensorDeviceConfiguration configuration)
          Setter for the configuration
protected  void setDeviceIdentifier(SensorDeviceIdentifier deviceIdentifier)
          Setter for the device identifier
 void setScanner(SensorDeviceScanner scanner, Context context)
          Setter for the scanner
 void updateConfiguration(SensorDeviceConfiguration configuration, Context context)
          Update method for the device configuration settings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unikassel.android.sdcframework.devices.facade.SensorDevice
isDeviceInSystemEnabled
 

Field Detail

deviceIdentifier

private SensorDeviceIdentifier deviceIdentifier
The sensor device deviceIdentifier


configuration

private SensorDeviceConfiguration configuration
The sensor device configuration


scanner

private SensorDeviceScanner scanner
The scanner for the sensor device

Constructor Detail

AbstractSensorDevice

private AbstractSensorDevice()
Default constructor ( it's private with purpose )


AbstractSensorDevice

public AbstractSensorDevice(SensorDeviceIdentifier deviceId)
Constructor for devices with an Android sub type

Parameters:
deviceId - the device identifier
Method Detail

accept

public final boolean accept(SensorDeviceVisitor visitor)
Description copied from interface: VisitableDevice
Method to accept a visitor

Specified by:
accept in interface VisitableDevice
Parameters:
visitor - the visitor to accept
Returns:
true if visitation has to continue, false otherwise

getDeviceIdentifier

public final SensorDeviceIdentifier getDeviceIdentifier()
Description copied from interface: SensorDevice
Getter for the sensors device identifier

Specified by:
getDeviceIdentifier in interface SensorDevice
Returns:
the sensor device identifier

setDeviceIdentifier

protected final void setDeviceIdentifier(SensorDeviceIdentifier deviceIdentifier)
Setter for the device identifier

Parameters:
deviceIdentifier - the device identifier to set

isDeviceScanningEnabled

public final boolean isDeviceScanningEnabled()
Description copied from interface: SensorDevice
Getter for device scanning enabled state in the framework

Specified by:
isDeviceScanningEnabled in interface SensorDevice
Returns:
true if the device scanning is enabled, false otherwise

enableDeviceScanning

public boolean enableDeviceScanning(boolean enabled,
                                    Context context)
Description copied from interface: SensorDevice
Setter for device scanning enabled state

Specified by:
enableDeviceScanning in interface SensorDevice
Parameters:
enabled - true to enable device scanning, false to disable it
context - the application context
Returns:
true if successful enabled, false otherwise

setConfiguration

private final void setConfiguration(SensorDeviceConfiguration configuration)
Setter for the configuration

Parameters:
configuration - the configuration to set

getConfiguration

public final SensorDeviceConfiguration getConfiguration()
Description copied from interface: SensorDevice
Getter for the sensor device configuration

Specified by:
getConfiguration in interface SensorDevice
Returns:
the sensor device configuration

setScanner

public final void setScanner(SensorDeviceScanner scanner,
                             Context context)
Description copied from interface: SensorDevice
Setter for the scanner

Specified by:
setScanner in interface SensorDevice
Parameters:
scanner - the scanner to set
context - the application context

getScanner

public final SensorDeviceScanner getScanner()
Description copied from interface: SensorDevice
Getter for the scanner

Specified by:
getScanner in interface SensorDevice
Returns:
the scanner

updateConfiguration

public final void updateConfiguration(SensorDeviceConfiguration configuration,
                                      Context context)
Description copied from interface: SensorDevice
Update method for the device configuration settings

Specified by:
updateConfiguration in interface SensorDevice
Parameters:
configuration - the device configuration
context - the application context

onConfigurationChanged

protected abstract void onConfigurationChanged()
Callback to signal configuration of device has changed


onCreate

public void onCreate(Context context)
Description copied from interface: SensorDevice
Is called when this device is created

Specified by:
onCreate in interface SensorDevice
Parameters:
context - the application context

onDestroy

public void onDestroy(Context context)
Description copied from interface: SensorDevice
Is called when the owner destroys this device

Specified by:
onDestroy in interface SensorDevice
Parameters:
context - the application context

isAirplaneModeOn

public boolean isAirplaneModeOn(Context applicationContext)
Getter for the state of the airplaine mode

Parameters:
applicationContext - the application contex
Returns:
true if enabled, false otherwise

doHandleDeviceDisabledBySystem

public final void doHandleDeviceDisabledBySystem(Context context)
Description copied from interface: SensorDevice
Default handler for the fact, the system device state is changing from enabled to disabled.
If the device is enabled in the framework and we are not in airplane mode, than this handler is signaling the user that the device is needed but disabled in the system. If the device scanner was running, it will be stopped.
A sensor device can call this method to proper handle the device is disabled case.

Specified by:
doHandleDeviceDisabledBySystem in interface SensorDevice
Parameters:
context - the application context

doHandleDeviceEnabledBySystem

public final void doHandleDeviceEnabledBySystem(Context context)
Description copied from interface: SensorDevice
Default handler for the fact, the system device state is changing from disabled to enabled.
If the device is enabled in the framework than the device scanner will be started.
A sensor device can call this method to proper handle the device is enabled case.

Specified by:
doHandleDeviceEnabledBySystem in interface SensorDevice
Parameters:
context - the application context

doSignalDeviceNotEnabledInSystem

protected abstract void doSignalDeviceNotEnabledInSystem(Context applicationContext)
Method to signal the user that the device is disabled in the system and needed by this service.
This method is called from the handler doHandleDeviceDisabledBySystem(android.content.Context) to react on system state changes from enabled to disabled.
The implementation depends on the concrete device.

Parameters:
applicationContext - the application context