com.vodafone360.people.service
Class RemoteService

java.lang.Object
  extended by Service
      extended by com.vodafone360.people.service.RemoteService
All Implemented Interfaces:
IConnectionManagerInterface, IWorkerThreadControl

public class RemoteService
extends Service
implements IWorkerThreadControl, IConnectionManagerInterface

Implementation of People client's Service class. Loads properties from SettingsManager. Creates NetworkAgent. Connects to ConnectionManager enabling transport layer. Activates service's worker thread when required.


Field Summary
static java.lang.String ACTION_AUTHENTICATOR_INTENT
          Action for an Authenticator.
static java.lang.String ACTION_SYNC_ADAPTER_INTENT
          Sync Adapter System intent action received on Bind.
static java.lang.String ALARM_KEY
          Intent received when service is started is tested against the value stored in this key to determine if the service has been started because of an alarm.
private  NativeAccountObjectsHolder mAccountsObjectsHolder
           
private  Handler mHandler
          Handler for remotely calling the kickWorkerThread() method.
private  IPeopleServiceImpl mIPeopleServiceImpl
          The following object contains the implementation of the IPeopleService interface.
private  boolean mIsConnected
          Stores the previous network connection state (true = connected)
private  boolean mIsStarted
          true when the service has been fully initialised
private  NetworkAgent mNetworkAgent
          Main reference to network agent
private  IWakeupListener mWakeListener
          Used by comms when waking up the CPI at regular intervals and sending a heartbeat is necessary
private  WorkerThread mWorkerThread
          Worker thread reference
 
Constructor Summary
RemoteService()
           
 
Method Summary
 NetworkAgent getNetworkAgent()
          Return handle to NetworkAgent
 void kickWorkerThread()
          Ensures that the WorkerThread runs at least once.
 IBinder onBind(Intent intent)
          Service binding is not used internally by this Application, but called externally by the system when it needs an Authenticator or Sync Adapter.
 void onCreate()
          Creation of RemoteService.
 void onDestroy()
          Destroy RemoteService Close WorkerThread, destroy EngineManger and NetworkAgent.
 void onStart(Intent intent, int startId)
          Called on start of RemoteService.
 void registerCpuWakeupListener(IWakeupListener wakeListener)
           Registers a listener (e.g. the HeartbeatSender for TCP) that will be notified whenever an intent for a new alarm is received.
 void setAlarm(boolean set, long realTime)
          Set an Alarm with the AlarmManager to trigger the next update check.
 void signalConnectionManager(boolean connected)
          Called by NetworkAgent to notify whether device has become connected or disconnected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALARM_KEY

public static final java.lang.String ALARM_KEY
Intent received when service is started is tested against the value stored in this key to determine if the service has been started because of an alarm.

See Also:
Constant Field Values

ACTION_AUTHENTICATOR_INTENT

public static final java.lang.String ACTION_AUTHENTICATOR_INTENT
Action for an Authenticator. Straight copy from AccountManager.ACTION_AUTHENTICATOR_INTENT in 2.X platform

See Also:
Constant Field Values

ACTION_SYNC_ADAPTER_INTENT

public static final java.lang.String ACTION_SYNC_ADAPTER_INTENT
Sync Adapter System intent action received on Bind.

See Also:
Constant Field Values

mNetworkAgent

private NetworkAgent mNetworkAgent
Main reference to network agent

See Also:
NetworkAgent

mWorkerThread

private WorkerThread mWorkerThread
Worker thread reference

See Also:
WorkerThread

mIPeopleServiceImpl

private IPeopleServiceImpl mIPeopleServiceImpl
The following object contains the implementation of the IPeopleService interface.


mWakeListener

private IWakeupListener mWakeListener
Used by comms when waking up the CPI at regular intervals and sending a heartbeat is necessary


mIsStarted

private boolean mIsStarted
true when the service has been fully initialised


mIsConnected

private boolean mIsConnected
Stores the previous network connection state (true = connected)


mAccountsObjectsHolder

private NativeAccountObjectsHolder mAccountsObjectsHolder

mHandler

private final Handler mHandler
Handler for remotely calling the kickWorkerThread() method.

Constructor Detail

RemoteService

public RemoteService()
Method Detail

onCreate

public void onCreate()
Creation of RemoteService. Loads properties (i.e. supported features, server URLs etc) from SettingsManager. Creates IPeopleServiceImpl, NetworkAgent. Connects ConnectionManager creating Connection thread(s) and DecoderThread 'Kicks' worker thread.


onStart

public void onStart(Intent intent,
                    int startId)
Called on start of RemoteService. Check if we need to kick the worker thread or 'wake' the TCP connection thread.


onDestroy

public void onDestroy()
Destroy RemoteService Close WorkerThread, destroy EngineManger and NetworkAgent.


onBind

public IBinder onBind(Intent intent)
Service binding is not used internally by this Application, but called externally by the system when it needs an Authenticator or Sync Adapter. This method will throw an InvalidParameterException if it is not called with the expected intent (or called on a 1.x platform).


kickWorkerThread

public void kickWorkerThread()
Ensures that the WorkerThread runs at least once.

Specified by:
kickWorkerThread in interface IWorkerThreadControl

signalConnectionManager

public void signalConnectionManager(boolean connected)
Called by NetworkAgent to notify whether device has become connected or disconnected. The ConnectionManager connects or disconnects appropriately. We kick the worker thread if our internal connection state is changed.

Specified by:
signalConnectionManager in interface IConnectionManagerInterface
Parameters:
connected - true if device has become connected, false if device is disconnected.

registerCpuWakeupListener

public void registerCpuWakeupListener(IWakeupListener wakeListener)

Registers a listener (e.g. the HeartbeatSender for TCP) that will be notified whenever an intent for a new alarm is received.

This is desperately needed as the CPU of Android devices will halt when the user turns off the screen and all CPU related activity is suspended for that time. The wake up alarm is one simple way of achieving the CPU to wake up and send out data (e.g. the heartbeat sender).


getNetworkAgent

public NetworkAgent getNetworkAgent()
Return handle to NetworkAgent

Returns:
handle to NetworkAgent

setAlarm

public void setAlarm(boolean set,
                     long realTime)
Set an Alarm with the AlarmManager to trigger the next update check.

Parameters:
set - Set or cancel the Alarm
realTime - Time when the Alarm should be triggered


JavaDoc