summaryrefslogtreecommitdiff
path: root/src/FLoc_LocationManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/FLoc_LocationManager.h')
-rw-r--r--src/FLoc_LocationManager.h188
1 files changed, 141 insertions, 47 deletions
diff --git a/src/FLoc_LocationManager.h b/src/FLoc_LocationManager.h
index 4194035..04de9d6 100644
--- a/src/FLoc_LocationManager.h
+++ b/src/FLoc_LocationManager.h
@@ -29,14 +29,15 @@
#include <alarm.h>
#include <location/locations.h>
#include <FBaseColAllElementsDeleter.h>
+#include <FBaseDateTime.h>
#include <FBaseRtEventDrivenThread.h>
#include <FLocLocation.h>
+#include <FSysISettingEventListener.h>
#include "FLoc_ILocationManagerListener.h"
#include "FLoc_Types.h"
namespace Tizen { namespace Locations
{
-
class _AlarmRequestInfo;
class _LocationMonitor;
class _LocationRequestInfo;
@@ -45,6 +46,7 @@ class _SyncLocationRequestInfo;
class _LocationManager
: public Tizen::Base::Runtime::EventDrivenThread
, public Tizen::Base::Runtime::ITimerEventListener
+ , public Tizen::System::ISettingEventListener
{
public:
// This method adds the location request into the list of requests and requests for location updates from core location provider.
@@ -162,29 +164,29 @@ private:
//
void RemoveFromAlarmRequestInfoList(RequestId reqId);
- // The method restarts both GPS and WPS native location providers.
+ // The method updates the minimum accuracy required.
//
- // @since 2.0
+ // @since 2.2
//
- void RestartLocationUpdates(void);
+ void UpdateMinimunAccuracy(void);
- // The method restarts the update timer after calculating the GCD of the timeout values requested by each location provider.
+ // The method starts the core location provider when the location is requested during Location manager idle state.
//
- // @since 2.0
+ // @since 2.2
//
- void RestartUpdateTimer(void);
+ void InitiateLocationRequest(void);
- // The method is called everytime the sync retrieval timer is expired.
+ // The method restarts the callback timer after calculating the GCD of the timeout values requested by each location provider.
//
- // @since 2.0
+ // @since 2.2
//
- void HandleSyncRetrievalTimerExpiry(_SyncLocationRequestInfo& syncLocRequestInfo);
+ void RestartCallbackTimer(void);
- // The method is called everytime the Async update timer is expired to set the location information.
+ // The method is called everytime the sync retrieval timer is expired.
//
// @since 2.0
//
- result SetLocationInformation(double latitude, double longitude, double altitude, time_t timestamp, location_method_e locMethod, Location* pLocation);
+ void HandleSyncRetrievalTimerExpiry(_SyncLocationRequestInfo& syncLocRequestInfo);
// The method is called to send back the callbacks in case of async location updates.
//
@@ -226,7 +228,7 @@ private:
//
// @since 2.0
//
- void UpdateLocRequestInfoList(RequestId reqId, int interval);
+ void UpdateLocRequestInterval(RequestId reqId, int interval);
// This method gets the better location among the three location providers.
//
@@ -240,22 +242,73 @@ private:
//
result GetLocation(location_method_e nativeLocMethod);
- // This method Covert error code for native error.
+ // This method handles the location information obtained from core location provider/s when the location manager state is LOC_MGR_STATE_BOTH_GPS_WPS.
//
- // @since 2.1
+ // @since 2.2
//
- inline double ConvertToNativeFormat(double value)
- {
- return value < 0.0 ? Tizen::Locations::NaN : value;
- }
+ void HandleBothGpsWpsState(void);
+
+ // This method handles the location information obtained from core GPS location provider when the location manager state is LOC_MGR_STATE_GPS_ONLY.
+ //
+ // @since 2.2
+ //
+ void HandleGpsOnlyState(void);
+
+ // This method handles the location information obtained from core WPS location provider when the location manager state is LOC_MGR_STATE_WPS_ONLY.
+ //
+ // @since 2.2
+ //
+ void HandleWpsOnlyState(void);
+
+ // This method checks the validity of location updated by GPS core provider is valid or not.
+ //
+ // @since 2.2
+ //
+ void IsGpsLocationUpdated(bool& isTimeUpdated, bool& isAccMet);
+
+ // This method checks the validity of location updated by WPS core provider is valid or not.
+ //
+ // @since 2.2
+ //
+ void IsWpsLocationUpdated(bool& isTimeUpdated, bool& isAccMet);
+
+ // This method converts the LocationAccuracy enum variable to corresponding double value.
+ //
+ // @since 2.2
+ //
+ double ConvertLocationAccuracyToDouble(LocationAccuracy locAcc);
+
+ // This method stops if timer is running and starts the sub state timer for the given interval.
+ //
+ // @since 2.2
+ //
+ result RestartSubStateTimer(int timeout);
+
+ // This method stops the sub state timer if it is running.
+ //
+ // @since 2.2
+ //
+ void StopSubStateTimer(void);
- // This method Covert error code for native altitude error.
+ // This method handles the expiry of the sub state.
+ //
+ // @since 2.2
+ //
+ void HandleSubStateTimerExpiry(void);
+
+ // This method handles the expiry of the location check timer.
+ //
+ // @since 2.2
+ //
+ void HandleLocationCheckTimerExpiry(void);
+
+ // This method Covert error code for native error.
//
// @since 2.1
//
- inline double ConvertToNativeFormatAltitude(double value)
+ inline double ConvertToNativeFormat(double value)
{
- return value == -1.0 ? Tizen::Locations::NaN : value;
+ return value < 0.0 ? Tizen::Locations::NaN : value;
}
// @see @ref Tizen::Base::Runtime::EventDrivenThread::OnStart()
@@ -282,6 +335,12 @@ private:
//
virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+ // @see @ref Tizen::System::ISettingEventListener::OnSettingChanged()
+ //
+ // @since 2.1
+ //
+ virtual void OnSettingChanged(Tizen::Base::String& key);
+
// This callback is recieved from native location manager for satellite information.
//
// @since 2.0
@@ -321,31 +380,37 @@ private:
private:
const static RequestId REQ_ID_START_LOC_UPDATES = 1;
const static RequestId REQ_ID_STOP_LOC_UPDATES = 2;
- const static RequestId REQ_ID_RESTART_LOC_UPDATES = 3;
- const static RequestId REQ_ID_SUSTAIN_GPS = 4;
- const static RequestId REQ_ID_SUSTAIN_WPS = 5;
- const static RequestId REQ_ID_SYNC_LOC_RETRIEVAL = 6;
- const static RequestId REQ_ID_GET_LAST_LOCATION = 7;
- const static RequestId REQ_ID_UPDATE_INTERVAL = 8;
- const static RequestId REQ_ID_START_ALARM = 9;
- const static RequestId REQ_ID_STOP_ALARM = 10;
-
- enum _LocationMethodRequested
- {
- LOC_METHOD_REQUESTED_NONE,
- LOC_METHOD_REQUESTED_GPS,
- LOC_METHOD_REQUESTED_WPS,
- LOC_METHOD_REQUESTED_ALL,
- }
- __locMethodRequested;
+ const static RequestId REQ_ID_SYNC_LOC_RETRIEVAL = 3;
+ const static RequestId REQ_ID_GET_LAST_LOCATION = 4;
+ const static RequestId REQ_ID_UPDATE_INTERVAL = 5;
+ const static RequestId REQ_ID_START_ALARM = 6;
+ const static RequestId REQ_ID_STOP_ALARM = 7;
enum _LocationManagerState
{
LOC_MGR_STATE_IDLE,
- LOC_MGR_STATE_FAST_SENSING,
- LOC_MGR_STATE_FAST_SENSING_SETTLED
- }
- __locationMgrState;
+ LOC_MGR_STATE_PASSIVE_IDLE,
+ LOC_MGR_STATE_BOTH_GPS_WPS,
+ LOC_MGR_STATE_GPS_ONLY,
+ LOC_MGR_STATE_WPS_ONLY
+ };
+
+ enum _LocationManagerSubState
+ {
+ LM_SS_IDLE,
+ LM_SS_SETTLED,
+ LM_SS_SENSING,
+ LM_SS_NO_FIX,
+ LM_SS_BOTH_SENSING,
+ LM_SS_BOTH_SETTLED_WAITING,
+ LM_SS_GPS_ONLY_SETTLED,
+ LM_SS_GPS_ONLY_SENSING,
+ LM_SS_GPS_ONLY_NO_FIX,
+ LM_SS_WPS_ONLY_LESS_ACC_SENSING,
+ LM_SS_WPS_ONLY_FINE_ACC_SENSING,
+ LM_SS_WPS_ONLY_SENSING,
+ LM_SS_WPS_ONLY_NO_FIX
+ };
class _LocationManagerHandle
{
@@ -355,6 +420,7 @@ private:
, handle(null)
, pLocation(null)
{
+ oldTimeStamp.SetValue(1970, 1, 1);
}
~_LocationManagerHandle(void)
@@ -364,20 +430,48 @@ private:
public:
location_service_state_e serviceState;
location_manager_h handle;
+ Tizen::Base::DateTime oldTimeStamp;
std::unique_ptr< Tizen::Locations::Location > pLocation;
};
+ class _LocationManagerStatus
+ {
+ public:
+ _LocationManagerStatus(void)
+ : isSubStateTimerStarted(false)
+ , locMgrState(LOC_MGR_STATE_IDLE)
+ , locMgrSubState(LM_SS_IDLE)
+ , gpsFailCount(0)
+ {
+ }
+ ~_LocationManagerStatus(void)
+ {
+ }
+
+ public:
+ bool isSubStateTimerStarted;
+ _LocationManagerState locMgrState;
+ _LocationManagerSubState locMgrSubState;
+ int gpsFailCount;
+ Tizen::Base::DateTime gpsTimeAtSubstateTimerStart;
+ std::unique_ptr< Tizen::Base::Runtime::Timer > pLocMgrSubStateTimer;
+ _LocationManagerHandle gpsHandler;
+ _LocationManagerHandle wpsHandler;
+ };
+
+ bool __gpsEnabled;
+ bool __wpsEnabled;
+ _LocationManagerStatus __locMgrStatus;
LocationAccuracy __minRequestedAccuracy;
int __timerInterval;
int __timerTicks;
- _LocationManagerHandle __gpsHandler;
- _LocationManagerHandle __wpsHandler;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pLocRequestInfoList;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pSyncLocRequestInfoList;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pAlarmRequestInfoList;
- std::unique_ptr< Tizen::Base::Runtime::Timer > __pLocUpdateTimer;
- static _LocationManager* __pUniqueInstance;
+ std::unique_ptr< Tizen::Base::Runtime::Timer > __pLocCallbackTimer;
+ std::unique_ptr< Tizen::Base::Runtime::Timer > __pLocCheckTimer;
Tizen::Base::Runtime::Monitor* __pInitMonitor;
+ static _LocationManager* __pUniqueInstance;
friend class std::default_delete< _LocationManager >;
}; // class _LocationManager