// // Open Service Platform // Copyright (c) 2012 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /** * @file FLoc_LocationManager.h * @brief This is the header file for the %_LocationManager class. * * This header file contains the declarations of the %_LocationManager class methods. */ #ifndef _FLOC_INTERNAL_LOCATION_MANAGER_H_ #define _FLOC_INTERNAL_LOCATION_MANAGER_H_ #include #include #include #include #include #include #include "FLoc_ILocationManagerListener.h" #include "FLoc_Types.h" namespace Tizen { namespace Locations { class _AlarmRequestInfo; class _LocationMonitor; class _LocationRequestInfo; class _SyncLocationRequestInfo; class _LocationManager : public Tizen::Base::Runtime::EventDrivenThread , public Tizen::Base::Runtime::ITimerEventListener { public: // This method adds the location request into the list of requests and requests for location updates from core location provider. // // @since 2.0 // result StartLocationUpdates(LocationAccuracy accuracy, int interval, _ILocationManagerListener* pListener, RequestId& reqId); // This method removes the location request wrt to the reqId provided. If the list entries is zero, then stops the core location provider. // // @since 2.0 // result StopLocationUpdates(RequestId reqId); // This method updates the requested interval from the location provider. // // @since 2.0 // result ChangeUpdateInterval(RequestId reqId, int interval); // This method initiates the synchronous location retrieval. The location monitor instance provided is used to intimate back the location. // // @since 2.0 // result RegisterLocationMonitor(_LocationMonitor* pLocationMonitor); // This method adds the alarm request into the list of requests and requests for alarm from the core alarm manager. // // @since 2.0 // result RequestStartAlarm(int interval, _ILocationManagerListener* pListener, RequestId reqId); // This method removes the alarm request from the list of requests and requests the removal of alarm from the core alarm manager. // // @since 2.0 // result RequestStopAlarm(RequestId reqId); // This method returns the stored location. // // @since 2.0 // Location GetLastKnownLocation(void); // This method converts the horizontal accuracy in meters to the LocationAccuracy enum type. // // @since 2.0 // LocationAccuracy GetAccuracyLevel(double horAcc) const; // This method returns the single instance of the location maanger. // // @since 2.0 // static _LocationManager* GetInstance(void); private: // This default constructor is intentionally declared as private to implement the Singleton semantic. // // @since 2.0 // _LocationManager(void); // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. // // @since 2.0 // _LocationManager(const _LocationManager& value); // This destructor is intentionally declared as private to implement the Singleton semantic. // // @since 2.0 // ~_LocationManager(void); // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. // // @since 2.0 // _LocationManager& operator =(const _LocationManager& rhs); // The method adds the _LocationRequestInfo instance to the array list. // // @since 2.0 // void AddToLocRequestInfoList(const _LocationRequestInfo* pLocRequestInfo); // The method removes the _LocationRequestInfo instance corresponding to a reqId from the array list. // // @since 2.0 // void RemoveFromLocRequestInfoList(RequestId reqId); // The method adds the _SyncLocationRequestInfo instance to the array list. // // @since 2.0 // void AddToSyncLocationRequestInfoList(_SyncLocationRequestInfo& syncLocRequestInfo); // The method removes the _SyncLocationRequestInfo instance from the list. // // @since 2.0 // void RemoveSyncLocRetrievalRequest(_SyncLocationRequestInfo& syncLocRequestInfo); // The method adds the _AlarmRequestInfo instance corresponding to a reqId from the array list. // // @since 2.0 // void AddToAlarmRequestInfoList(_AlarmRequestInfo& alarmRequestInfo); // The method removes the _AlarmRequestInfo instance from the list. // // @since 2.0 // void RemoveFromAlarmRequestInfoList(RequestId reqId); // The method restarts both GPS and WPS native location providers. // // @since 2.0 // void RestartLocationUpdates(void); // The method restarts the update timer after calculating the GCD of the timeout values requested by each location provider. // // @since 2.0 // void RestartUpdateTimer(void); // The method is called everytime the sync retrieval timer is expired. // // @since 2.0 // void HandleSyncRetrievalTimerExpiry(_SyncLocationRequestInfo& syncLocRequestInfo); // The method is called everytime the Async update timer is expired to set the location information. // // @since 2.0 // result SetLocationInformation(double latitude, double longitude, double altitude, time_t timestamp, location_method_e locMethod, Location* pLocation); // The method is called to send back the callbacks in case of async location updates. // // @since 2.0 // void SendLocationCallbacks(void); // This method resets the member variables. // // @since 2.0 // void Reset(void); // The method is wait for OnStart method. // // @since 2.0 // result WaitUntilThreadStart(); // The method calls the construct method of the event driven thread. // // @since 2.0 // result Construct(void); // This method is gets the last known location from Native side for the given method. // // @since 2.0 // Location GetLastKnownLocation(location_method_e nativeLocMethod); // This method returns the most recent location among available last known locations. // // @since 2.0 // Location GetRecentLocationAvailable(void); // This method updates the timer interval for a particular request Id. // // @since 2.0 // void UpdateLocRequestInfoList(RequestId reqId, int interval); // This method gets the better location among the three location providers. // // @since 2.0 // const Location* FindBestLocation(void); // This method gets the location from the native side depending on the location handle. // // @since 2.0 // result GetLocation(location_method_e nativeLocMethod); // This method Covert error code for native error. // // @since 2.1 // inline double ConvertToNativeFormat(double value) { return value < 0.0 ? Tizen::Locations::NaN : value; } // This method Covert error code for native altitude error. // // @since 2.1 // inline double ConvertToNativeFormatAltitude(double value) { return value == -1.0 ? Tizen::Locations::NaN : value; } // @see @ref Tizen::Base::Runtime::EventDrivenThread::OnStart() // // @since 2.0 // virtual bool OnStart(void); // @see @ref Tizen::Base::Runtime::EventDrivenThread::OnStop() // // @since 2.0 // virtual void OnStop(void); // @see @ref Tizen::Base::Runtime::EventDrivenThread::OnUserEventReceivedN() // // @since 2.0 // virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); // @see @ref Tizen::Base::Runtime::ITimerEventListener::OnTimerExpired() // // @since 2.0 // virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); // This callback is recieved from native location manager for satellite information. // // @since 2.0 // static bool SatelliteInfoUpdated(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_active, void* user_data); // This method is called by the native location provider when the service state of GPS method is changed. // // @since 2.0 // static void GpsServiceUpdateCallback(location_service_state_e state, void* user_data); // This method is called by the native location provider when the service state of WPS method is changed. // // @since 2.0 // static void WpsServiceUpdateCallback(location_service_state_e state, void* user_data); // This method is called by the core alarm manager when the requested alarm is expired. // // @since 2.0 // static int AlarmExpiryCallback(alarm_id_t alarm_id, void* user_param); // This method initializes the single instance of the location manager. // // @since 2.0 // static void InitLocationManager(void); // This method is called when the location manager thread is destroyed. // // @since 2.0 // static void DestroyLocationManager(void); 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; enum _LocationManagerState { LOC_MGR_STATE_IDLE, LOC_MGR_STATE_FAST_SENSING, LOC_MGR_STATE_FAST_SENSING_SETTLED } __locationMgrState; class _LocationManagerHandle { public: _LocationManagerHandle(void) : serviceState(LOCATIONS_SERVICE_DISABLED) , handle(null) , pLocation(null) { } ~_LocationManagerHandle(void) { } public: location_service_state_e serviceState; location_manager_h handle; std::unique_ptr< Tizen::Locations::Location > pLocation; }; 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; Tizen::Base::Runtime::Monitor* __pInitMonitor; friend class std::default_delete< _LocationManager >; }; // class _LocationManager }} // Tizen::Locations #endif // _FLOC_INTERNAL_LOCATION_MANAGER_H_