de.unikassel.android.sdcframework.devices
Class GSMDevice

Package class diagram package GSMDevice
java.lang.Object
  extended by de.unikassel.android.sdcframework.devices.AbstractSensorDevice
      extended by de.unikassel.android.sdcframework.devices.ScannerStateAwareSensorDevice
          extended by de.unikassel.android.sdcframework.devices.GSMDevice
All Implemented Interfaces:
SampleProvidingSensorDevice, SensorDevice, VisitableDevice

public final class GSMDevice
extends ScannerStateAwareSensorDevice
implements SampleProvidingSensorDevice

Implementation of the GSM sensor device as active device providing sensor data for the scanner.


Nested Class Summary
private  class GSMDevice.GSMPhoneStateListener
          Private class implementing a phone state listener for GSM devices.
 
Field Summary
private  Context context
          The context
private  GSMSampleData currentSampleData
          The GSM sample holding the current device state
private static int eventsDisabled
          The events to listen for in enabled state
private static int eventsEnabled
          The events to listen for in enabled state
private  AtomicInteger lastServiceState
          The last signaled service state
private  PhoneStateListener phoneStateListener
          The phone state listener to tack cell or signal strength changes
private  TelephonyManager telephoyManager
          The telephony manager reference
 
Constructor Summary
GSMDevice(Context context)
          Constructor
 
Method Summary
private  void doReactOnStateChange(ServiceState serviceState)
          Handler for service state changes
 void doSignalDeviceNotEnabledInSystem(Context applicationContext)
          Method to signal the user that the device is disabled in the system and needed by this service.
private  Context getContext()
          Getter for the context
 int getLastServiceState()
          Getter for the last service state
 Sample getSample()
          Getter for a device sample
 boolean hasSample()
          Test method for a sample available
 boolean isDeviceInSystemEnabled(Context context)
          Test method for the system wide enabled state of the device
 void onCreate(Context context)
          Is called when this device is created
 void onDestroy(Context context)
          Is called when the owner destroys this device
protected  void onScannerRunningStateChange(boolean isRunning, Context context)
          Handler to react on scanner state changes.
private  boolean registerListener(int events)
          Registration of listener for the given events
private static String serviceStateToString(int serviceState)
          Does create a human readable string representation of the service state
private  void setContext(Context context)
          Setter for the context
private  void setLastServiceState(int lastServiceState)
          Setter for the last service state
 void updateCellLocation(int cellId, int locationAreaCode)
          Updater for the current cell location
private  void updateNeighborCells()
          Method to update neighbor cell information
 void updateOperatorName(String operatorName)
          Updater for the operator name
 void updateSignalStrength(int signalStrength)
          Updater for the current signal strength
 
Methods inherited from class de.unikassel.android.sdcframework.devices.ScannerStateAwareSensorDevice
enableDeviceScanning, onConfigurationChanged
 
Methods inherited from class de.unikassel.android.sdcframework.devices.AbstractSensorDevice
accept, doHandleDeviceDisabledBySystem, doHandleDeviceEnabledBySystem, getConfiguration, getDeviceIdentifier, getScanner, isAirplaneModeOn, isDeviceScanningEnabled, setDeviceIdentifier, setScanner, updateConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventsEnabled

private static final int eventsEnabled
The events to listen for in enabled state

See Also:
Constant Field Values

eventsDisabled

private static final int eventsDisabled
The events to listen for in enabled state

See Also:
Constant Field Values

context

private Context context
The context


lastServiceState

private final AtomicInteger lastServiceState
The last signaled service state


telephoyManager

private final TelephonyManager telephoyManager
The telephony manager reference


phoneStateListener

private final PhoneStateListener phoneStateListener
The phone state listener to tack cell or signal strength changes


currentSampleData

private final GSMSampleData currentSampleData
The GSM sample holding the current device state

Constructor Detail

GSMDevice

public GSMDevice(Context context)
Constructor

Parameters:
context - the context
Method Detail

getLastServiceState

public final int getLastServiceState()
Getter for the last service state

Returns:
the last service state

setLastServiceState

private final void setLastServiceState(int lastServiceState)
Setter for the last service state

Parameters:
lastServiceState - the last service state to set

setContext

private final void setContext(Context context)
Setter for the context

Parameters:
context - the context to set

getContext

private final Context getContext()
Getter for the context

Returns:
the context

registerListener

private final boolean registerListener(int events)
Registration of listener for the given events

Returns:
true if successful, false otherwise

doSignalDeviceNotEnabledInSystem

public final void doSignalDeviceNotEnabledInSystem(Context applicationContext)
Description copied from class: AbstractSensorDevice
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 AbstractSensorDevice.doHandleDeviceDisabledBySystem(android.content.Context) to react on system state changes from enabled to disabled.
The implementation depends on the concrete device.

Specified by:
doSignalDeviceNotEnabledInSystem in class AbstractSensorDevice
Parameters:
applicationContext - the application context

isDeviceInSystemEnabled

public final boolean isDeviceInSystemEnabled(Context context)
Description copied from interface: SensorDevice
Test method for the system wide enabled state of the device

Specified by:
isDeviceInSystemEnabled in interface SensorDevice
Parameters:
context - the application context
Returns:
true if device is enabled in system, false otherwise

updateSignalStrength

public final void updateSignalStrength(int signalStrength)
Updater for the current signal strength

Parameters:
signalStrength - the current signal strengt

updateCellLocation

public final void updateCellLocation(int cellId,
                                     int locationAreaCode)
Updater for the current cell location

Parameters:
cellId - the cell id
locationAreaCode - the location area code

updateNeighborCells

private final void updateNeighborCells()
Method to update neighbor cell information


updateOperatorName

public final void updateOperatorName(String operatorName)
Updater for the operator name

Parameters:
operatorName - the operator name

doReactOnStateChange

private final void doReactOnStateChange(ServiceState serviceState)
Handler for service state changes

Parameters:
serviceState - the current service state

onScannerRunningStateChange

protected final void onScannerRunningStateChange(boolean isRunning,
                                                 Context context)
Description copied from class: ScannerStateAwareSensorDevice
Handler to react on scanner state changes. It is called after each state change and signals the new running state

Specified by:
onScannerRunningStateChange in class ScannerStateAwareSensorDevice
Parameters:
isRunning - the current scanner state after state change
context - the context

serviceStateToString

private static final String serviceStateToString(int serviceState)
Does create a human readable string representation of the service state

Parameters:
serviceState - the service state
Returns:
the string representation of the service state

onDestroy

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

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

getSample

public final Sample getSample()
Description copied from interface: SampleProvidingSensorDevice
Getter for a device sample

Specified by:
getSample in interface SampleProvidingSensorDevice
Returns:
a sample of the device

onCreate

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

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

hasSample

public boolean hasSample()
Description copied from interface: SampleProvidingSensorDevice
Test method for a sample available

Specified by:
hasSample in interface SampleProvidingSensorDevice
Returns:
true if a sample is available