diff options
author | Nandan SR <nandan.sr@samsung.com> | 2013-03-19 18:08:22 +0530 |
---|---|---|
committer | Nandan SR <nandan.sr@samsung.com> | 2013-03-19 18:08:22 +0530 |
commit | 82c32c094885555272ecec3ae4f6baccc2446934 (patch) | |
tree | eba47bf11f044f77abb2178a66520f45ebc74bce | |
parent | f52b5366f624919364918f9b0100d41de14e7864 (diff) | |
download | locations-82c32c094885555272ecec3ae4f6baccc2446934.tar.gz locations-82c32c094885555272ecec3ae4f6baccc2446934.tar.bz2 locations-82c32c094885555272ecec3ae4f6baccc2446934.zip |
Removal of CPS method from native locations
Change-Id: I97a0394766c74510cb15b2203855780dbac44e5d
Signed-off-by: Nandan SR <nandan.sr@samsung.com>
-rw-r--r-- | src/FLocCoordinates.cpp | 21 | ||||
-rw-r--r-- | src/FLocLocation.cpp | 5 | ||||
-rw-r--r-- | src/FLocLocationCriteria.cpp | 7 | ||||
-rw-r--r-- | src/FLocLocationProvider.cpp | 9 | ||||
-rw-r--r-- | src/FLoc_LocationImpl.cpp | 15 | ||||
-rw-r--r-- | src/FLoc_LocationManager.cpp | 296 | ||||
-rw-r--r-- | src/FLoc_LocationManager.h | 21 | ||||
-rw-r--r-- | src/FLoc_LocationMonitor.cpp | 4 | ||||
-rw-r--r-- | src/FLoc_LocationProviderImpl.cpp | 64 | ||||
-rw-r--r-- | src/FLoc_MathUtils.cpp | 4 |
10 files changed, 68 insertions, 378 deletions
diff --git a/src/FLocCoordinates.cpp b/src/FLocCoordinates.cpp index f8e71db..226725a 100644 --- a/src/FLocCoordinates.cpp +++ b/src/FLocCoordinates.cpp @@ -61,7 +61,6 @@ bool Coordinates::Equals(const Tizen::Base::Object& rhs) const { const Coordinates* pRhs = dynamic_cast< const Coordinates* >(&rhs); - if (pRhs == null) { return false; @@ -70,7 +69,6 @@ Coordinates::Equals(const Tizen::Base::Object& rhs) const bool latitudeCheck = false; bool longitudeCheck = false; bool altitudeCheck = false; - if (Double::IsNaN(__latitude) || Double::IsNaN(pRhs->__latitude)) { if (Double::IsNaN(__latitude) && Double::IsNaN(pRhs->__latitude)) @@ -115,7 +113,6 @@ Coordinates::Equals(const Tizen::Base::Object& rhs) const { altitudeCheck = true; } - return (latitudeCheck && longitudeCheck && altitudeCheck); } @@ -123,10 +120,8 @@ int Coordinates::GetHashCode(void) const { int hashCode = Double::GetHashCode(__latitude) * 37; - hashCode += Double::GetHashCode(__longitude) * 37; hashCode += Double::GetHashCode(__altitude) * 37; - return hashCode; } @@ -135,14 +130,12 @@ Coordinates::Set(double latitude, double longitude, double altitude) { SysTryReturn(NID_LOC, (MIN_LATITUDE <= latitude) && (latitude <= MAX_LATITUDE), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The latitude(%lf) must be in the range [-90.0, 90.0].", latitude); - SysTryReturn(NID_LOC, (MIN_LONGITUDE <= longitude) && (longitude <= MAX_LONGITUDE), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The longitude(%lf) must be in the range [-180.0, 180.0].", longitude); __latitude = latitude; __longitude = longitude; __altitude = altitude; - return E_SUCCESS; } @@ -151,7 +144,6 @@ Coordinates::SetLatitude(double latitude) { SysTryReturn(NID_LOC, (MIN_LATITUDE <= latitude) && (latitude <= MAX_LATITUDE), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The latitude(%lf) must be in the range [-90.0, 90.0].", latitude); - __latitude = latitude; return E_SUCCESS; } @@ -161,7 +153,6 @@ Coordinates::SetLongitude(double longitude) { SysTryReturn(NID_LOC, (MIN_LONGITUDE <= longitude) && (longitude <= MAX_LONGITUDE), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The longitude(%lf) must be in the range [-180.0, 180.0].", longitude); - __longitude = longitude; return E_SUCCESS; } @@ -197,24 +188,20 @@ Coordinates::GetAzimuth(const Coordinates& dest) const { return Tizen::Locations::NaN; } - if (Double::Compare(MAX_LATITUDE, GetLatitude()) == 0 && Double::Compare(MAX_LATITUDE, dest.GetLatitude()) != 0) { return 180.0; } - if (Double::Compare(MIN_LATITUDE, GetLatitude()) == 0 && Double::Compare(MIN_LATITUDE, dest.GetLatitude()) != 0) { return 0.0; } - if (Equals(dest) || (Double::Compare(MIN_LATITUDE, GetLatitude()) == 0 && Double::Compare(MIN_LATITUDE, dest.GetLatitude()) == 0) || (Double::Compare(MAX_LATITUDE, GetLatitude()) == 0 && Double::Compare(MAX_LATITUDE, dest.GetLatitude()) == 0)) { return 0.0; } - return _EllipsoidModel::GetAzimuth(GetLatitude(), GetLongitude(), dest.GetLatitude(), dest.GetLongitude()); } @@ -225,7 +212,6 @@ Coordinates::GetDistanceTo(const Coordinates& to) const { return Tizen::Locations::NaN; } - return _EllipsoidModel::GetDistance(GetLatitude(), GetLongitude(), to.GetLatitude(), to.GetLongitude()); } @@ -234,7 +220,6 @@ Coordinates::ToString(double degree, CoordinateFormat format, Tizen::Base::Strin { SysTryReturn(NID_LOC, format == COORDINATE_FORMAT_DEGREE_MINUTE || format == COORDINATE_FORMAT_DEGREE_MINUTE_SECOND, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified format(%x) is not proper.", format); - SysTryReturn(NID_LOC, MIN_LONGITUDE <= degree && degree < MAX_LONGITUDE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The supplied degree(%lf) is out of [-180, 180] range.", degree); @@ -243,7 +228,6 @@ Coordinates::ToString(double degree, CoordinateFormat format, Tizen::Base::Strin fractionalPart = modf(degree, &intPart); int degreeValue = (int) intPart; - if (degree < 0) { fractionalPart *= -1.0; @@ -297,7 +281,6 @@ Coordinates::ToString(double degree, CoordinateFormat format, Tizen::Base::Strin result Coordinates::Parse(const Tizen::Base::String& string, double& degree) { - result r = E_SUCCESS; double ret = 0.0; CoordinateFormat type = COORDINATE_FORMAT_DEGREE_MINUTE; @@ -315,7 +298,7 @@ Coordinates::Parse(const Tizen::Base::String& string, double& degree) int sign = 1; int degreeInt = 0; - r = Integer::Decode(degreeValue, degreeInt); + result r = Integer::Decode(degreeValue, degreeInt); SysTryReturn(NID_LOC, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to decode the degree part."); SysTryReturn(NID_LOC, MIN_LONGITUDE <= degreeInt && degreeInt <= MAX_LONGITUDE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Degree(%d) is out of [-180, 180] range.", degreeInt); @@ -381,11 +364,9 @@ Coordinates::operator =(const Coordinates& rhs) { return *this; } - __latitude = rhs.__latitude; __longitude = rhs.__longitude; __altitude = rhs.__altitude; - return *this; } }} diff --git a/src/FLocLocation.cpp b/src/FLocLocation.cpp index 6e33c17..ca793fd 100644 --- a/src/FLocLocation.cpp +++ b/src/FLocLocation.cpp @@ -31,7 +31,6 @@ Location::Location(void) , __pImpl(null) { __pImpl = new (std::nothrow) _LocationImpl(); - if (__pImpl == null) { SetLastResult(E_OUT_OF_MEMORY); @@ -60,12 +59,10 @@ Location::Equals(const Tizen::Base::Object& rhs) const SysAssertf(__pImpl != null, "The location object is in an invalid state."); const Location* pRhs = dynamic_cast< const Location* >(&rhs); - if (pRhs == null) { return false; } - return __pImpl->Equals(*_LocationImpl::GetInstance(*pRhs)); } @@ -141,9 +138,7 @@ Location::operator =(const Location& rhs) { return *this; } - *__pImpl = *_LocationImpl::GetInstance(rhs); - return *this; } }} diff --git a/src/FLocLocationCriteria.cpp b/src/FLocLocationCriteria.cpp index 5753735..031bb25 100644 --- a/src/FLocLocationCriteria.cpp +++ b/src/FLocLocationCriteria.cpp @@ -47,7 +47,6 @@ bool LocationCriteria::Equals(const Base::Object& rhs) const { const LocationCriteria* pRhs = dynamic_cast< const LocationCriteria* >(&rhs); - if (pRhs == null) { return false; @@ -57,7 +56,6 @@ LocationCriteria::Equals(const Base::Object& rhs) const { return false; } - return true; } @@ -65,9 +63,7 @@ int LocationCriteria::GetHashCode(void) const { int hashCode = 0; - hashCode = __accuracy * 37; - return hashCode; } @@ -76,7 +72,6 @@ LocationCriteria::SetAccuracy(LocationAccuracy accuracy) { SysTryReturn(NID_LOC, accuracy >= LOC_ACCURACY_FINEST && accuracy <= LOC_ACCURACY_ANY, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The accuracy value is out of range."); - __accuracy = accuracy; return E_SUCCESS; } @@ -94,9 +89,7 @@ LocationCriteria::operator =(const LocationCriteria& rhs) { return *this; } - __accuracy = rhs.__accuracy; - return *this; } }} diff --git a/src/FLocLocationProvider.cpp b/src/FLocLocationProvider.cpp index 94ed2ae..bac7c2e 100644 --- a/src/FLocLocationProvider.cpp +++ b/src/FLocLocationProvider.cpp @@ -53,7 +53,6 @@ LocationProvider::Construct(const LocationCriteria& criteria, ILocationProviderL __pImpl = new (std::nothrow) _LocationProviderImpl(); SysTryReturnResult(NID_LOC, __pImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - result r = __pImpl->Construct(criteria, listener); SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to construct location Provider.", GetErrorMessage(r)); @@ -70,7 +69,6 @@ LocationProvider::StartLocationUpdatesByInterval(int interval) { result r = AccessController::CheckPrivilege(_PRV_LOCATION); SysTryReturn(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); r = __pImpl->StartLocationUpdatesByInterval(interval); @@ -84,7 +82,6 @@ LocationProvider::StartLocationUpdatesByDistance(double distance) { result r = AccessController::CheckPrivilege(_PRV_LOCATION); SysTryReturn(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); r = __pImpl->StartLocationUpdatesByDistance(distance); @@ -109,10 +106,8 @@ LocationProvider::KeepLocationUpdateAwake(bool enable) { result r = AccessController::CheckPrivilege(_PRV_LOCATION); SysTryReturn(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - r = AccessController::CheckPrivilege(_PRV_POWER); SysTryReturn(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); __pImpl->KeepLocationUpdateAwake(enable); @@ -124,10 +119,8 @@ LocationProvider::AddMonitoringRegion(const Coordinates& regionCenter, double ra { result r = AccessController::CheckPrivilege(_PRV_LOCATION); SysTryReturn(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - r = AccessController::CheckPrivilege(_PRV_POWER); SysTryReturn(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); - SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); r = __pImpl->AddMonitoringRegion(regionCenter, radius, regionId); @@ -196,6 +189,4 @@ LocationProvider::GetLastKnownLocation(void) return _LocationProviderImpl::GetLastKnownLocation(); } - - }} diff --git a/src/FLoc_LocationImpl.cpp b/src/FLoc_LocationImpl.cpp index 56791ed..c26cede 100644 --- a/src/FLoc_LocationImpl.cpp +++ b/src/FLoc_LocationImpl.cpp @@ -88,7 +88,6 @@ _LocationImpl::GetHashCode(void) const { hashCode *= (-1); } - return hashCode; } @@ -100,9 +99,7 @@ _LocationImpl::GetTimestamp(void) const dateTime.SetValue(1970, 1, 1); dateTime.Add(timespan); - SysLog(NID_LOC, "The location timeStamp is (%ls)", dateTime.ToString().GetPointer()); - return dateTime; } @@ -121,7 +118,6 @@ _LocationImpl::GetExtraInfo(const Tizen::Base::String& key) const } SysLog(NID_LOC, "Requested information is '%ls' for the key '%ls'.", reqValue.GetPointer(), key.GetPointer()); - return reqValue; } @@ -149,18 +145,14 @@ Location _LocationImpl::GetLocationInstance(void) { Location invalidLoc; - return invalidLoc; } result _LocationImpl::SetCoordinates(const Coordinates& coordinate) { - result r = E_SUCCESS; - - r = __coordinate.Set(coordinate.GetLatitude(), coordinate.GetLongitude(), coordinate.GetAltitude()); + result r = __coordinate.Set(coordinate.GetLatitude(), coordinate.GetLongitude(), coordinate.GetAltitude()); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Setting the latitude/longitude value failed.", GetErrorMessage(r)); - return E_SUCCESS; } @@ -206,22 +198,18 @@ _LocationImpl::operator ==(const _LocationImpl& rhs) const { return false; } - if (__timestamp != rhs.__timestamp) { return false; } - if (__locationMethod != rhs.__locationMethod) { return false; } - if (!__satelliteInformation.Equals(rhs.__satelliteInformation)) { return false; } - if (__isLocationValid != rhs.__isLocationValid) { return false; @@ -279,7 +267,6 @@ _LocationImpl::operator ==(const _LocationImpl& rhs) const { verAccCheck = true; } - return (speedCheck && courseCheck && horAccCheck && verAccCheck); } diff --git a/src/FLoc_LocationManager.cpp b/src/FLoc_LocationManager.cpp index cb7d55e..51928cf 100644 --- a/src/FLoc_LocationManager.cpp +++ b/src/FLoc_LocationManager.cpp @@ -77,8 +77,6 @@ result _LocationManager::StartLocationUpdates(LocationAccuracy accuracy, int interval, _ILocationManagerListener* pListener, RequestId& reqId) { static RequestId nextLocRequestId = 1; - - result r = E_SUCCESS; const int ARRAY_LIST_CAPACITY = 1; std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > pArgList(new (std::nothrow) ArrayList()); @@ -87,9 +85,8 @@ _LocationManager::StartLocationUpdates(LocationAccuracy accuracy, int interval, std::unique_ptr< _LocationRequestInfo > pLocRequestInfo(new (std::nothrow) _LocationRequestInfo(accuracy, interval, pListener, nextLocRequestId)); SysTryReturn(NID_LOC, pLocRequestInfo, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pArgList->Construct(ARRAY_LIST_CAPACITY); + result r = pArgList->Construct(ARRAY_LIST_CAPACITY); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Array Construct failed. Propogating.", GetErrorMessage(r)); - r = pArgList->Add(*pLocRequestInfo); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Arraylist addition of an object failed. Propogating", GetErrorMessage(r)); @@ -104,7 +101,6 @@ _LocationManager::StartLocationUpdates(LocationAccuracy accuracy, int interval, pArgList.release(); SysLog(NID_LOC, "Request ID (%ld) is assigned for the location request with accuracy (%d) and interval (%d).", reqId, accuracy, interval); - return E_SUCCESS; } @@ -112,8 +108,6 @@ result _LocationManager::StopLocationUpdates(RequestId reqId) { SysLog(NID_LOC, "Location update stop requested for request ID (%d).", reqId); - - result r = E_SUCCESS; const int ARRAY_LIST_CAPACITY = 1; std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > pArgList(new (std::nothrow) ArrayList()); @@ -122,9 +116,8 @@ _LocationManager::StopLocationUpdates(RequestId reqId) std::unique_ptr< Integer > pReqId(new (std::nothrow) Integer(static_cast< int >(reqId))); SysTryReturn(NID_LOC, pReqId, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pArgList->Construct(ARRAY_LIST_CAPACITY); + result r = pArgList->Construct(ARRAY_LIST_CAPACITY); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Array Construct failed. Propogating.", GetErrorMessage(r)); - r = pArgList->Add(*pReqId); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Arraylist addition of an object failed. Propogating.", GetErrorMessage(r)); @@ -134,7 +127,6 @@ _LocationManager::StopLocationUpdates(RequestId reqId) SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r)); pArgList.release(); - return E_SUCCESS; } @@ -142,14 +134,11 @@ result _LocationManager::ChangeUpdateInterval(RequestId reqId, int interval) { SysLog(NID_LOC, "Interval update requested for request ID (%d).", reqId); - - result r = E_SUCCESS; const int ARRAY_LIST_CAPACITY = 2; std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > pArgList(new (std::nothrow) ArrayList()); SysTryReturn(NID_LOC, pArgList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - r = pArgList->Construct(ARRAY_LIST_CAPACITY); + result r = pArgList->Construct(ARRAY_LIST_CAPACITY); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Array Construct failed. Propogating.", GetErrorMessage(r)); std::unique_ptr< Integer > pReqId(new (std::nothrow) Integer(static_cast< int >(reqId))); @@ -172,7 +161,6 @@ _LocationManager::ChangeUpdateInterval(RequestId reqId, int interval) SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r)); pArgList.release(); - return E_SUCCESS; } @@ -187,13 +175,11 @@ _LocationManager::RegisterLocationMonitor(_LocationMonitor* pLocationMonitor) std::unique_ptr< _SyncLocationRequestInfo > pSyncLocationRequestInfo(new (std::nothrow) _SyncLocationRequestInfo(pLocationMonitor, reqId)); std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > pArgList(new (std::nothrow) ArrayList()); - SysTryCatch(NID_LOC, pSyncLocationRequestInfo != null && pArgList != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pArgList->Construct(ARRAY_LIST_CAPACITY); SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Array Construct failed. Propogating.", GetErrorMessage(r)); - r = pArgList->Add(*pSyncLocationRequestInfo.get()); SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Arraylist addition of an object failed. Propogating.", GetErrorMessage(r)); @@ -203,7 +189,6 @@ _LocationManager::RegisterLocationMonitor(_LocationMonitor* pLocationMonitor) SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r)); pArgList.release(); - return E_SUCCESS; CATCH: @@ -215,7 +200,6 @@ Location _LocationManager::GetLastKnownLocation(void) { Location location = _LocationImpl::GetLocationInstance(); - Monitor synchronizer; result r = synchronizer.Construct(); SysTryReturn(NID_LOC, r == E_SUCCESS, location, r, "[%s] Propogating.", GetErrorMessage(r)); @@ -241,7 +225,6 @@ _LocationManager::GetLastKnownLocation(void) r = synchronizer.Wait(); SysTryCatch(NID_LOC, r == E_SUCCESS, synchronizer.Exit(), r, "[%s] Propogating", GetErrorMessage(r)); synchronizer.Exit(); - SysLog(NID_LOC, "Last location(validity: %x, method: %ls) retrieved.", location.IsValid(), location.GetExtraInfo(L"location_method").GetPointer()); @@ -333,7 +316,6 @@ _LocationManager::GetInstance(void) onceBlock = PTHREAD_ONCE_INIT; } } - return __pUniqueInstance; } @@ -350,7 +332,6 @@ _LocationManager::AddToLocRequestInfoList(const _LocationRequestInfo* pLocReques result r = _PowerManagerImpl::PowerControl(1, 1); SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to keep the CPU in awake state.", GetErrorMessage(r)); } - SysLog(NID_LOC, "Total count of request info is (%d).", __pLocRequestInfoList->GetCount()); RestartLocationUpdates(); RestartUpdateTimer(); @@ -360,7 +341,6 @@ void _LocationManager::RemoveFromLocRequestInfoList(RequestId reqId) { const int LIST_COUNT_ZERO = 0; - int count = __pLocRequestInfoList->GetCount(); for (int i = 0; i < count; i++) @@ -372,9 +352,7 @@ _LocationManager::RemoveFromLocRequestInfoList(RequestId reqId) break; } } - SysLog(NID_LOC, "Total count of request info is (%d).", __pLocRequestInfoList->GetCount()); - if (__pLocRequestInfoList->GetCount() == LIST_COUNT_ZERO) { _PowerManagerImpl::PowerControl(1, 0); @@ -382,7 +360,6 @@ _LocationManager::RemoveFromLocRequestInfoList(RequestId reqId) __pLocUpdateTimer->Cancel(); location_manager_stop(__gpsHandler.handle); location_manager_stop(__wpsHandler.handle); - location_manager_stop(__cpsHandler.handle); Reset(); } @@ -396,10 +373,9 @@ _LocationManager::RemoveFromLocRequestInfoList(RequestId reqId) void _LocationManager::AddToSyncLocationRequestInfoList(_SyncLocationRequestInfo& syncLocRequestInfo) { - result r = E_SUCCESS; static bool hasRetrievalStarted = false; - r = __pSyncLocRequestInfoList->Add(syncLocRequestInfo); + result r = __pSyncLocRequestInfoList->Add(syncLocRequestInfo); SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to add the sync request into the list.", GetErrorMessage(r)); if (hasRetrievalStarted == true) @@ -407,7 +383,6 @@ _LocationManager::AddToSyncLocationRequestInfoList(_SyncLocationRequestInfo& syn SysLog(NID_LOC, "The retrieval under process."); return; } - while (__pSyncLocRequestInfoList->GetCount() != 0) { hasRetrievalStarted = true; @@ -426,9 +401,7 @@ _LocationManager::AddToSyncLocationRequestInfoList(_SyncLocationRequestInfo& syn } } } - hasRetrievalStarted = false; - return; CATCH: @@ -460,12 +433,10 @@ _LocationManager::RestartLocationUpdates(void) isAccuracyChanged = true; } } - if (!isAccuracyChanged) { return; } - SysLog(NID_LOC, "Location updates are restarted and new minimum requested Accuracy is (%d).", __minRequestedAccuracy); switch (__locMethodRequested) @@ -479,45 +450,24 @@ _LocationManager::RestartLocationUpdates(void) result = location_manager_start(__wpsHandler.handle); SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for WPS."); - - result = location_manager_start(__cpsHandler.handle); - SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for CPS."); } break; case LOC_METHOD_REQUESTED_GPS: { - SysLog(NID_LOC, "GPS Running. Start other two."); + SysLog(NID_LOC, "GPS Running. Start WPS."); result = location_manager_start(__wpsHandler.handle); SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for WPS."); - - result = location_manager_start(__cpsHandler.handle); - SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for CPS."); } break; case LOC_METHOD_REQUESTED_WPS: { - SysLog(NID_LOC, "WPS Running. Start other two."); - - result = location_manager_start(__gpsHandler.handle); - SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for GPS."); - - result = location_manager_start(__cpsHandler.handle); - SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for CPS."); - } - break; - - case LOC_METHOD_REQUESTED_CPS: - { - SysLog(NID_LOC, "CPS Running. Start other two."); + SysLog(NID_LOC, "WPS Running. Start GPS."); result = location_manager_start(__gpsHandler.handle); SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for GPS."); - - result = location_manager_start(__wpsHandler.handle); - SysTryLog(NID_LOC, result == 0, "Failed to start the location updates for WPS."); } break; @@ -530,7 +480,6 @@ _LocationManager::RestartLocationUpdates(void) __locationMgrState = LOC_MGR_STATE_FAST_SENSING; __locMethodRequested = LOC_METHOD_REQUESTED_ALL; - } void @@ -538,7 +487,6 @@ _LocationManager::RestartUpdateTimer(void) { int gcd = 1; int count = __pLocRequestInfoList->GetCount(); - result r = E_SUCCESS; __pLocUpdateTimer->Cancel(); @@ -547,12 +495,10 @@ _LocationManager::RestartUpdateTimer(void) const _LocationRequestInfo* pLocRequestInfo = static_cast< _LocationRequestInfo* >(__pLocRequestInfoList->GetAt(0)); gcd = pLocRequestInfo->GetInterval(); - for (int i = 1; i < count; i++) { pLocRequestInfo = static_cast< const _LocationRequestInfo* >(__pLocRequestInfoList->GetAt(i)); int interval = pLocRequestInfo->GetInterval(); - if (gcd != interval) { while (gcd != 0 && interval != 0) @@ -563,13 +509,11 @@ _LocationManager::RestartUpdateTimer(void) } } } - __timerInterval = gcd; __timerTicks = 0; SysLog(NID_LOC, "Updated Timer interval is (%d).", __timerInterval); - - r = __pLocUpdateTimer->Start(__timerInterval * 1000); + result r = __pLocUpdateTimer->Start(__timerInterval * 1000); if (IsFailed(r)) { SysLog(NID_LOC, "Failed to start the Location update timer."); @@ -652,7 +596,6 @@ _LocationManager::SetLocationInformation(double latitude, double longitude, doub time_t time_stamp = 0; RequestId requestId; - Location locationData = _LocationImpl::GetLocationInstance(); _LocationImpl* pLocDataImpl = _LocationImpl::GetInstance(locationData); @@ -687,20 +630,8 @@ _LocationManager::SetLocationInformation(double latitude, double longitude, doub } break; - case LOCATIONS_METHOD_CPS: - { - res = location_manager_get_accuracy(__cpsHandler.handle, &accLevel, &horAcc, &verAcc); - SysLog(NID_LOC, "Get Accuracy: Result (%d), Horizontal Acc (%lf), Vertical Acc (%lf)", res, horAcc, verAcc); - SysTryReturnResult(NID_LOC, res == 0, E_SYSTEM, "Invalid accuracy values from Native Location Provider."); - - pLocDataImpl->SetExtraInfo(L"location_method", L"network"); - requestId = REQ_ID_SUSTAIN_CPS; - } - break; - default: SysTryReturn(NID_LOC, false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The location method is not valid"); - } Coordinates coordinates; @@ -754,7 +685,6 @@ _LocationManager::SetLocationInformation(double latitude, double longitude, doub SysLog(NID_LOC, "State is LOC_MGR_STATE_FAST_SENSING_SETTLED and accuracy is out of range. Restart location updates."); SendUserEvent(REQ_ID_RESTART_LOC_UPDATES, null); } - return E_SUCCESS; } @@ -807,17 +737,19 @@ _LocationManager::GetLastKnownLocation(location_method_e nativeLocMethod) switch (nativeLocMethod) { case LOCATIONS_METHOD_GPS: + { nativeHandle = __gpsHandler.handle; locationMethod = L"gps"; - break; + } + break; + case LOCATIONS_METHOD_WPS: + { nativeHandle = __wpsHandler.handle; locationMethod = L"network"; - break; - case LOCATIONS_METHOD_CPS: - nativeHandle = __cpsHandler.handle; - locationMethod = L"network"; - break; + } + break; + default: break; } @@ -885,7 +817,6 @@ _LocationManager::GetLastKnownLocation(location_method_e nativeLocMethod) pLocationImpl->SetExtraInfo(L"satellite", satInfo); } } - pLocationImpl->SetTimestamp(((long long)timestampPosition) * 1000); // in milliseconds pLocationImpl->SetValidity(true); pLocationImpl->SetExtraInfo(L"location_method", locationMethod); @@ -903,7 +834,6 @@ _LocationManager::GetRecentLocationAvailable(void) { long long gpsTimestamp = 0; long long wpsTimestamp = 0; - long long cpsTimestamp = 0; Location lastGpsLocation = GetLastKnownLocation(LOCATIONS_METHOD_GPS); if (lastGpsLocation.IsValid()) @@ -917,26 +847,14 @@ _LocationManager::GetRecentLocationAvailable(void) wpsTimestamp = _LocationImpl::GetInstance(lastWpsLocation)->GetTimestampInMs(); } - Location lastCpsLocation = GetLastKnownLocation(LOCATIONS_METHOD_CPS); - if (lastCpsLocation.IsValid()) - { - cpsTimestamp = _LocationImpl::GetInstance(lastCpsLocation)->GetTimestampInMs(); - } - - SysLog(NID_LOC, "Compare timestamp(gps: %lld, wps: %lld, cps: %lld) for recent location.", - gpsTimestamp, wpsTimestamp, cpsTimestamp); - - if (gpsTimestamp >= wpsTimestamp && gpsTimestamp >= cpsTimestamp) + SysLog(NID_LOC, "Compare timestamp(gps: %lld, wps: %lld) for recent location.", gpsTimestamp, wpsTimestamp); + if (gpsTimestamp >= wpsTimestamp) { return lastGpsLocation; } - else if (wpsTimestamp > gpsTimestamp && wpsTimestamp > cpsTimestamp) - { - return lastWpsLocation; - } else { - return lastCpsLocation; + return lastWpsLocation; } } @@ -963,27 +881,24 @@ _LocationManager::FindBestLocation(void) switch (__locMethodRequested) { case LOC_METHOD_REQUESTED_GPS: + { SysLog(NID_LOC, "GPS location provider running."); return __gpsHandler.pLocation.get(); - break; + } + break; case LOC_METHOD_REQUESTED_WPS: + { SysLog(NID_LOC, "WPS location provider running."); return __wpsHandler.pLocation.get(); - break; - - case LOC_METHOD_REQUESTED_CPS: - SysLog(NID_LOC, "CPS location provider running."); - return __cpsHandler.pLocation.get(); - break; + } + break; case LOC_METHOD_REQUESTED_ALL: { SysLog(NID_LOC, "All the methods are running. Get the best location among all the providers."); - long long gpsTimestamp = 0; long long wpsTimestamp = 0; - long long cpsTimestamp = 0; if (__gpsHandler.pLocation->IsValid() && !_LocationImpl::GetInstance(*__gpsHandler.pLocation)->IsDenied()) { @@ -993,28 +908,18 @@ _LocationManager::FindBestLocation(void) { wpsTimestamp = _LocationImpl::GetInstance(*__wpsHandler.pLocation)->GetTimestampInMs(); } - if (__cpsHandler.pLocation->IsValid() && !_LocationImpl::GetInstance(*__cpsHandler.pLocation)->IsDenied()) - { - cpsTimestamp = _LocationImpl::GetInstance(*__cpsHandler.pLocation)->GetTimestampInMs(); - } - SysLog(NID_LOC, "Compare timestamp(gps: %lld, wps: %lld, cps: %lld) of different locations.", gpsTimestamp, wpsTimestamp, cpsTimestamp); - - if (gpsTimestamp > wpsTimestamp && gpsTimestamp > cpsTimestamp) + SysLog(NID_LOC, "Compare timestamp(gps: %lld, wps: %lld) of different locations.", gpsTimestamp, wpsTimestamp); + if (gpsTimestamp > wpsTimestamp) { - SysLog(NID_LOC, "GPS time stamp is greater than WPS and CPS."); + SysLog(NID_LOC, "GPS time stamp is greater than WPS."); return __gpsHandler.pLocation.get(); } - else if (wpsTimestamp > gpsTimestamp && wpsTimestamp > cpsTimestamp) + else if (wpsTimestamp > gpsTimestamp) { - SysLog(NID_LOC, "WPS time stamp is greater than GPS and CPS."); + SysLog(NID_LOC, "WPS time stamp is greater than GPS."); return __wpsHandler.pLocation.get(); } - else if (cpsTimestamp > gpsTimestamp && cpsTimestamp > wpsTimestamp) - { - SysLog(NID_LOC, "CPS time stamp is greater than GPS and WPS."); - return __cpsHandler.pLocation.get(); - } else if (gpsTimestamp == wpsTimestamp) { if (__gpsHandler.pLocation->GetHorizontalAccuracy() <= __wpsHandler.pLocation->GetHorizontalAccuracy()) @@ -1024,38 +929,12 @@ _LocationManager::FindBestLocation(void) } else { - SysLog(NID_LOC, "GPS time stamp is equal to WPS but GPS accuracy is worse than WPS."); - return __wpsHandler.pLocation.get(); - } - } - else if (gpsTimestamp == cpsTimestamp) - { - if (__gpsHandler.pLocation->GetHorizontalAccuracy() <= __cpsHandler.pLocation->GetHorizontalAccuracy()) - { - SysLog(NID_LOC, "GPS time stamp is equal to CPS and GPS accuracy is better than CPS."); - return __gpsHandler.pLocation.get(); - } - else - { - SysLog(NID_LOC, "GPS time stamp is equal to CPS but GPS accuracy is worse than CPS."); - return __cpsHandler.pLocation.get(); - } - } - else if (wpsTimestamp == cpsTimestamp) - { - if (__wpsHandler.pLocation->GetHorizontalAccuracy() <= __cpsHandler.pLocation->GetHorizontalAccuracy()) - { - SysLog(NID_LOC, "WPS time stamp is equal to CPS and WPS accuracy is better than CPS."); + SysLog(NID_LOC, "WPS time stamp is equal to GPS but WPS accuracy is better than GPS."); return __wpsHandler.pLocation.get(); } - else - { - SysLog(NID_LOC, "WPS time stamp is equal to CPS but WPS accuracy is worse than CPS."); - return __cpsHandler.pLocation.get(); - } } } - break; + break; case LOC_METHOD_REQUESTED_NONE: // follow through @@ -1072,7 +951,6 @@ result _LocationManager::GetLocation(location_method_e nativeLocMethod) { const int MAX_VALID_TIME_DIFFERENCE = 2000; - result r = E_SUCCESS; double altitude = 0.0; double latitude = 0.0; double longitude = 0.0; @@ -1089,17 +967,19 @@ _LocationManager::GetLocation(location_method_e nativeLocMethod) switch (nativeLocMethod) { case LOCATIONS_METHOD_GPS: + { nativeHandle = __gpsHandler.handle; pLocation = __gpsHandler.pLocation.get(); - break; + } + break; + case LOCATIONS_METHOD_WPS: + { nativeHandle = __wpsHandler.handle; pLocation = __wpsHandler.pLocation.get(); - break; - case LOCATIONS_METHOD_CPS: - nativeHandle = __cpsHandler.handle; - pLocation = __cpsHandler.pLocation.get(); - break; + } + break; + default: break; } @@ -1109,7 +989,7 @@ _LocationManager::GetLocation(location_method_e nativeLocMethod) if (res == 0) { - r = SetLocationInformation(latitude, longitude, altitude, timestamp, nativeLocMethod, pLocation); + result r = SetLocationInformation(latitude, longitude, altitude, timestamp, nativeLocMethod, pLocation); if (r != E_SUCCESS) { SysLog(NID_LOC, "Failed to set the location information"); @@ -1127,10 +1007,8 @@ _LocationManager::GetLocation(location_method_e nativeLocMethod) { res = gps_status_foreach_satellites_in_view(__gpsHandler.handle, SatelliteInfoUpdated, &satInfo); } - satInfo.Trim(); SysLog(NID_LOC, "Result of get satellite is (%d) and satelliteInfo string representation is (%ls)", res, satInfo.GetPointer()); - _LocationImpl::GetInstance(*__gpsHandler.pLocation.get())->SetExtraInfo(L"satellite", satInfo); } } @@ -1142,60 +1020,43 @@ bool _LocationManager::OnStart(void) { int res = -1; - result r = E_SUCCESS; std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pLocInfoRequestList(new (std::nothrow) ArrayList()); SysTryReturn(NID_LOC, pLocInfoRequestList != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - r = pLocInfoRequestList->Construct(); + result r = pLocInfoRequestList->Construct(); SysTryReturn(NID_LOC, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] Failed to construct the Location Request list."); std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pSyncLocInfoRequestList(new (std::nothrow) ArrayList()); SysTryReturn(NID_LOC, pSyncLocInfoRequestList != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pSyncLocInfoRequestList->Construct(); SysTryReturn(NID_LOC, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] Failed to construct the Sync Location Request list."); unique_ptr< Tizen::Locations::Location > pGpsLocation(_LocationImpl::GetLocationInstanceN()); SysTryReturn(NID_LOC, pGpsLocation != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - unique_ptr< Tizen::Locations::Location > pWpsLocation(_LocationImpl::GetLocationInstanceN()); SysTryReturn(NID_LOC, pWpsLocation != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - unique_ptr< Tizen::Locations::Location > pCpsLocation(_LocationImpl::GetLocationInstanceN()); - SysTryReturn(NID_LOC, pCpsLocation != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - std::unique_ptr< Tizen::Base::Runtime::Timer > pLocUpdateTimer(new (std::nothrow) Timer()); r = pLocUpdateTimer->Construct(*this); SysTryReturn(NID_LOC, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] Failed to construct the location timer."); res = location_manager_create(LOCATIONS_METHOD_GPS, &__gpsHandler.handle); SysTryReturn(NID_LOC, res == 0, false, E_SYSTEM, "[E_SYSTEM] Failed to create Native GPS Location provider."); - res = location_manager_set_service_state_changed_cb(__gpsHandler.handle, GpsServiceUpdateCallback, this); SysTryCatch(NID_LOC, res == 0, , E_SYSTEM, "[E_SYSTEM] Failed to register service callback for Native GPS Location provider."); res = location_manager_create(LOCATIONS_METHOD_WPS, &__wpsHandler.handle); SysTryCatch(NID_LOC, res == 0, , E_SYSTEM, "[E_SYSTEM] Failed to create Native WPS Location provider."); - res = location_manager_set_service_state_changed_cb(__wpsHandler.handle, WpsServiceUpdateCallback, this); SysTryCatch(NID_LOC, res == 0, , E_SYSTEM, "[E_SYSTEM] Failed to register service callback for Native WPS Location provider."); - res = location_manager_create(LOCATIONS_METHOD_CPS, &__cpsHandler.handle); - SysTryCatch(NID_LOC, res == 0, , E_SYSTEM, "[E_SYSTEM] Failed to create Native CPS Location provider."); - - res = location_manager_set_service_state_changed_cb(__cpsHandler.handle, CpsServiceUpdateCallback, this); - SysTryCatch(NID_LOC, res == 0, , E_SYSTEM, "[E_SYSTEM] Failed to register service callback for Native CPS Location provider."); - __pLocRequestInfoList = std::move(pLocInfoRequestList); __pSyncLocRequestInfoList = std::move(pSyncLocInfoRequestList); __pLocUpdateTimer = std::move(pLocUpdateTimer); __gpsHandler.pLocation= std::move(pGpsLocation); __wpsHandler.pLocation= std::move(pWpsLocation); - __cpsHandler.pLocation= std::move(pCpsLocation); SysLog(NID_LOC, "All the resources for location manager successfully created."); - return true; CATCH: @@ -1208,11 +1069,6 @@ CATCH: { location_manager_destroy(__wpsHandler.handle); } - - if (__cpsHandler.handle) - { - location_manager_destroy(__cpsHandler.handle); - } return false; } @@ -1223,16 +1079,10 @@ _LocationManager::OnStop(void) { location_manager_destroy(__gpsHandler.handle); } - if (__wpsHandler.handle) { location_manager_destroy(__wpsHandler.handle); } - - if (__cpsHandler.handle) - { - location_manager_destroy(__cpsHandler.handle); - } } void @@ -1279,7 +1129,6 @@ _LocationManager::OnUserEventReceivedN(RequestId requestId, IList* pArgs) { SysLog(NID_LOC, "REQ_ID_SUSTAIN_GPS."); location_manager_stop(__wpsHandler.handle); - location_manager_stop(__cpsHandler.handle); __locMethodRequested = LOC_METHOD_REQUESTED_GPS; } break; @@ -1288,20 +1137,10 @@ _LocationManager::OnUserEventReceivedN(RequestId requestId, IList* pArgs) { SysLog(NID_LOC, "REQ_ID_SUSTAIN_WPS."); location_manager_stop(__gpsHandler.handle); - location_manager_stop(__cpsHandler.handle); __locMethodRequested = LOC_METHOD_REQUESTED_WPS; } break; - case REQ_ID_SUSTAIN_CPS: - { - SysLog(NID_LOC, "REQ_ID_SUSTAIN_CPS."); - location_manager_stop(__gpsHandler.handle); - location_manager_stop(__wpsHandler.handle); - __locMethodRequested = LOC_METHOD_REQUESTED_CPS; - } - break; - case REQ_ID_SYNC_LOC_RETRIEVAL: { SysLog(NID_LOC, "REQ_ID_SYNC_LOC_RETRIEVAL."); @@ -1312,7 +1151,6 @@ _LocationManager::OnUserEventReceivedN(RequestId requestId, IList* pArgs) SysTryCatch(NID_LOC, pSyncLocRequestInfo, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored."); AddToSyncLocationRequestInfoList(*pSyncLocRequestInfo); - pArgs->RemoveAt(0); } break; @@ -1410,46 +1248,29 @@ _LocationManager::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) switch (__locMethodRequested) { case LOC_METHOD_REQUESTED_GPS: + { r = GetLocation(LOCATIONS_METHOD_GPS); SysTryLog(NID_LOC, r == E_SUCCESS, "[E_SYSTEM] Failed to obtain the GPS location information"); - if (IsFailed(r)) { SendUserEvent(REQ_ID_RESTART_LOC_UPDATES, null); } - break; + } + break; case LOC_METHOD_REQUESTED_WPS: + { r = GetLocation(LOCATIONS_METHOD_WPS); SysTryLog(NID_LOC, r == E_SUCCESS, "[E_SYSTEM] Failed to obtain the WPS location information"); - - if (IsFailed(r)) - { - SendUserEvent(REQ_ID_RESTART_LOC_UPDATES, null); - } - break; - - case LOC_METHOD_REQUESTED_CPS: - r = GetLocation(LOCATIONS_METHOD_CPS); - SysTryLog(NID_LOC, r == E_SUCCESS, "[E_SYSTEM] Failed to obtain the CPS location information"); - if (IsFailed(r)) { SendUserEvent(REQ_ID_RESTART_LOC_UPDATES, null); } - break; + } + break; case LOC_METHOD_REQUESTED_ALL: - if (__cpsHandler.serviceState == LOCATIONS_SERVICE_ENABLED) - { - r = GetLocation(LOCATIONS_METHOD_CPS); - SysTryLog(NID_LOC, r == E_SUCCESS, "[E_SYSTEM] Failed to obtain the CPS location information"); - } - else - { - SysLog(NID_LOC, "CPS Location not available at the Native side."); - } - + { if (__wpsHandler.serviceState == LOCATIONS_SERVICE_ENABLED) { r = GetLocation(LOCATIONS_METHOD_WPS); @@ -1469,7 +1290,8 @@ _LocationManager::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) { SysLog(NID_LOC, "GPS Location not available at the Native side."); } - break; + } + break; case LOC_METHOD_REQUESTED_NONE: // follow through @@ -1496,7 +1318,6 @@ _LocationManager::SatelliteInfoUpdated(unsigned int azimuth, unsigned int elevat } String* pSatInfo = static_cast< String* >(user_data); - SysLog(NID_LOC, "GPS Position Satellite Info: SatID (%d), Used (%d), Elevation (%d), Azimuth (%d), Snr (%d).", prn, is_active, elevation, azimuth, snr); pSatInfo->Append(static_cast< int >(prn)); @@ -1542,35 +1363,18 @@ _LocationManager::WpsServiceUpdateCallback(location_service_state_e state, void* } void -_LocationManager::CpsServiceUpdateCallback(location_service_state_e state, void* user_data) -{ - SysLog(NID_LOC, "Updated State is (%d).", state); - if (user_data == null) - { - SysLog(NID_LOC, "User data is null. Return"); - return; - } - - _LocationManager* pThis = static_cast< _LocationManager* >(user_data); - pThis->__cpsHandler.serviceState = state; -} - -void _LocationManager::InitLocationManager(void) { SysLog(NID_LOC, "Creating the first location manager instance."); unique_ptr< _LocationManager > pLocMgr(new (std::nothrow) _LocationManager()); SysTryReturnVoidResult(NID_LOC, pLocMgr, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - result r = pLocMgr->Construct(); SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Falied to construct the Location Manager. Propagating.", GetErrorMessage(r)); - r = pLocMgr->Start(); SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Falied to start the Location Manager. Propagating.", GetErrorMessage(r)); __pUniqueInstance = pLocMgr.release(); - std::atexit(DestroyLocationManager); } diff --git a/src/FLoc_LocationManager.h b/src/FLoc_LocationManager.h index 75c5d97..39e7baa 100644 --- a/src/FLoc_LocationManager.h +++ b/src/FLoc_LocationManager.h @@ -142,7 +142,7 @@ private: // void RemoveSyncLocRetrievalRequest(_SyncLocationRequestInfo& syncLocRequestInfo); - // The method restarts all (GPS, WPS and CPS) the native location providers. + // The method restarts both GPS and WPS native location providers. // // @since 2.0 // @@ -256,12 +256,6 @@ private: // static void WpsServiceUpdateCallback(location_service_state_e state, void* user_data); - // This method is called by the native location provider when the service state of CPS method is changed. - // - // @since 2.0 - // - static void CpsServiceUpdateCallback(location_service_state_e state, void* user_data); - // This method initializes the single instance of the location manager. // // @since 2.0 @@ -287,18 +281,16 @@ private: 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_SUSTAIN_CPS = 6; - const static RequestId REQ_ID_SYNC_LOC_RETRIEVAL = 7; - const static RequestId REQ_ID_GET_APP_ACCESSIBILITY = 8; - const static RequestId REQ_ID_GET_LAST_LOCATION = 9; - const static RequestId REQ_ID_UPDATE_INTERVAL = 10; + const static RequestId REQ_ID_SYNC_LOC_RETRIEVAL = 6; + const static RequestId REQ_ID_GET_APP_ACCESSIBILITY = 7; + const static RequestId REQ_ID_GET_LAST_LOCATION = 8; + const static RequestId REQ_ID_UPDATE_INTERVAL = 9; enum _LocationMethodRequested { LOC_METHOD_REQUESTED_NONE, LOC_METHOD_REQUESTED_GPS, LOC_METHOD_REQUESTED_WPS, - LOC_METHOD_REQUESTED_CPS, LOC_METHOD_REQUESTED_ALL, } __locMethodRequested; @@ -324,7 +316,7 @@ private: ~__LocationManagerHandle(void) { } - + public: location_service_state_e serviceState; location_manager_h handle; @@ -336,7 +328,6 @@ private: int __timerTicks; __LocationManagerHandle __gpsHandler; __LocationManagerHandle __wpsHandler; - __LocationManagerHandle __cpsHandler; 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::Runtime::Timer > __pLocUpdateTimer; diff --git a/src/FLoc_LocationMonitor.cpp b/src/FLoc_LocationMonitor.cpp index 921abfd..7a087f2 100644 --- a/src/FLoc_LocationMonitor.cpp +++ b/src/FLoc_LocationMonitor.cpp @@ -47,15 +47,12 @@ _LocationMonitor::Construct(int timeout, LocationAccuracy accuracy) { unique_ptr< Tizen::Base::Runtime::Monitor > pMonitor(new (std::nothrow) Monitor()); SysTryReturn(NID_LOC, pMonitor, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - result r = pMonitor->Construct(); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Error from Monitor::Construct(). Propagating.", GetErrorMessage(r)); __pMonitor = std::move(pMonitor); - __timeout = timeout; __accuracy = accuracy; - return r; } @@ -112,5 +109,4 @@ _LocationMonitor::GetAccuracy(void) const { return __accuracy; } - }} diff --git a/src/FLoc_LocationProviderImpl.cpp b/src/FLoc_LocationProviderImpl.cpp index bccc8a3..5bd8c9a 100644 --- a/src/FLoc_LocationProviderImpl.cpp +++ b/src/FLoc_LocationProviderImpl.cpp @@ -87,27 +87,21 @@ _LocationProviderImpl::~_LocationProviderImpl(void) result _LocationProviderImpl::Construct(const LocationCriteria& criteria, ILocationProviderListener& listener) { - result r = E_SUCCESS; - _LocationManager* pLocationManager = null; - - pLocationManager = _LocationManager::GetInstance(); + _LocationManager* pLocationManager = _LocationManager::GetInstance(); SysTryReturn(NID_LOC, pLocationManager != null, GetLastResult(), GetLastResult(), "[%s] Failed to get the location manager instance.", GetErrorMessage(GetLastResult())); std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pRegionList(new (std::nothrow) ArrayList()); SysTryReturn(NID_LOC, pRegionList != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - r = pRegionList->Construct(); + result r = pRegionList->Construct(); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to construct the list. Propagating.", GetErrorMessage(r)); std::unique_ptr< Tizen::Base::Runtime::Timer> pTimer (new (std::nothrow) Timer()); SysTryReturn(NID_LOC, pTimer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pTimer->Construct(*this); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to construct the timer. Propagating.", GetErrorMessage(r)); std::unique_ptr< Tizen::System::Alarm> pAlarm (new (std::nothrow) Alarm()); SysTryReturn(NID_LOC, pAlarm != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pAlarm->Construct(*this); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to construct the alarm. Propagating.", GetErrorMessage(r)); @@ -123,7 +117,6 @@ _LocationProviderImpl::Construct(const LocationCriteria& criteria, ILocationProv std::unique_ptr< Tizen::Locations::Location > pLastLocation(_LocationImpl::GetLocationInstanceN()); SysTryReturn(NID_LOC, pLastLocation != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - std::unique_ptr<Tizen::Locations::Location> pLastRegionLocation (_LocationImpl::GetLocationInstanceN()); SysTryReturn(NID_LOC, pLastRegionLocation != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); @@ -141,7 +134,6 @@ _LocationProviderImpl::Construct(const LocationCriteria& criteria, ILocationProv __pLocationManager = pLocationManager; SysLog(NID_LOC, "Location provider constructed with the accuracy (%x).", criteria.GetAccuracy()); - return E_SUCCESS; } @@ -150,14 +142,12 @@ _LocationProviderImpl::StartLocationUpdatesByInterval(int interval) { bool userConsent = GetUserPrivilege(); SysTryReturn(NID_LOC, userConsent, E_USER_NOT_CONSENTED, E_USER_NOT_CONSENTED, "[E_USER_NOT_CONSENTED] The user has disabled the required settings."); - SysTryReturn(NID_LOC, interval >= 1, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The interval(%d) should be greater than or equal to 1", interval); if (__locationUpdater.type == _LOCATION_UPDATE_TYPE_INTERVAL && __locationUpdater.updateInterval == interval) { return E_SUCCESS; } - const double INVALID_DISTANCE_THRESHOLD = 0.0; return StartLocationUpdates(_LOCATION_UPDATE_TYPE_INTERVAL, interval, INVALID_DISTANCE_THRESHOLD); } @@ -167,16 +157,13 @@ _LocationProviderImpl::StartLocationUpdatesByDistance(double distance) { bool userConsent = GetUserPrivilege(); SysTryReturn(NID_LOC, userConsent, E_USER_NOT_CONSENTED, E_USER_NOT_CONSENTED, "[E_USER_NOT_CONSENTED] The user has disabled the required settings."); - SysTryReturn(NID_LOC, distance > 0.0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The distance(%lf) should be greater than 0.0", distance); - SysTryReturn(NID_LOC, Double::IsNaN(distance) == false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The distance is NaN."); if (__locationUpdater.type == _LOCATION_UPDATE_TYPE_DISTANCE && (Double::Compare(__locationUpdater.distanceThreshold, distance) == 0)) { return E_SUCCESS; } - const int INVALID_INTERVAL = 0; return StartLocationUpdates(_LOCATION_UPDATE_TYPE_DISTANCE, INVALID_INTERVAL, distance); } @@ -185,13 +172,10 @@ result _LocationProviderImpl::StopLocationUpdates(void) { SysLog(NID_LOC, "Stopping the location updates for the request ID (%ld)", __locationUpdater.reqId); - SysTryReturn(NID_LOC, __locationUpdater.type != _LOCATION_UPDATE_TYPE_NONE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Location update has not been requested."); result r = __pLocationManager->StopLocationUpdates(__locationUpdater.reqId); - ResetLocationUpdates(); - return r; } @@ -238,21 +222,16 @@ _LocationProviderImpl::AddMonitoringRegion(const Coordinates& regionCenter, doub { bool userConsent = GetUserPrivilege(); SysTryReturn(NID_LOC, userConsent, E_USER_NOT_CONSENTED, E_USER_NOT_CONSENTED, "[E_USER_NOT_CONSENTED] The user has disabled the required settings."); - SysTryReturn(NID_LOC, radius >= 50.0 && radius <= 100000.00, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The radius is not within the specified limits."); - SysTryReturn(NID_LOC, (!Double::IsNaN(radius) && !Double::IsNaN(regionCenter.GetLatitude()) && !Double::IsNaN(regionCenter.GetLongitude())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of the value is NaN."); - SysLog(NID_LOC, "Requested to add the monitoring region with center (Latitude: %lf, Longitude %lf) and radius (%lf).", regionCenter.GetLatitude(), regionCenter.GetLongitude(), radius); static int nextRegionId = 0; - result r = E_SUCCESS; std::unique_ptr< _RegionInfo > pRegionInfo(new (std::nothrow) _RegionInfo(regionCenter, radius, nextRegionId)); SysTryReturn(NID_LOC, pRegionInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - r = __regionMonitor.pRegionList->Add(*pRegionInfo.get()); + result r = __regionMonitor.pRegionList->Add(*pRegionInfo.get()); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to add the Region info into the list. Propogated.", GetErrorMessage(r)); pRegionInfo.release(); @@ -269,7 +248,6 @@ _LocationProviderImpl::AddMonitoringRegion(const Coordinates& regionCenter, doub __regionMonitor.status = LOC_SVC_STATUS_NOT_FIXED; NotifyServiceStatus(_LOC_PRV_EVENT_SEND_MONITOR_SVC_CB, __regionMonitor.status); - return E_SUCCESS; CATCH: @@ -282,7 +260,6 @@ _LocationProviderImpl::RemoveMonitoringRegion(RegionId regionId) { int count = __regionMonitor.pRegionList->GetCount(); bool isIdValid = false; - SysLog(NID_LOC, "Total regions currently monitored is (%d).", count); for (int i = 0; i < count; i++) @@ -297,7 +274,6 @@ _LocationProviderImpl::RemoveMonitoringRegion(RegionId regionId) } SysTryReturn(NID_LOC, isIdValid == true, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The region ID is invalid."); - if (__regionMonitor.pRegionList->GetCount() == 0) { __regionMonitor.status = LOC_SVC_STATUS_IDLE; @@ -307,7 +283,6 @@ _LocationProviderImpl::RemoveMonitoringRegion(RegionId regionId) } StopRegionMonitoring(); } - return E_SUCCESS; } @@ -325,7 +300,6 @@ _LocationProviderImpl::RemoveAllMonitoringRegions(void) } StopRegionMonitoring(); } - return; } @@ -364,23 +338,19 @@ _LocationProviderImpl::GetLocation(const LocationCriteria& criteria) std::unique_ptr< _LocationMonitor > pLocMonitor(new (std::nothrow) _LocationMonitor()); SysTryCatch(NID_LOC, pLocMonitor, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pLocMonitor->Construct(MAX_TIMEOUT, criteria.GetAccuracy()); SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to construct the Location Monitor.", GetErrorMessage(r)); pLocationManager = _LocationManager::GetInstance(); SysTryCatch(NID_LOC, pLocationManager, , r, "[%s] Failed to get the location manager instance.", GetErrorMessage(r)); - r = pLocationManager->RegisterLocationMonitor(pLocMonitor.get()); SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to register the location monitor.", GetErrorMessage(r)); r = pLocMonitor->Wait(); - if (!IsFailed(r)) { pLocation = pLocMonitor->GetLocationN(); } - if (pLocation) { retLocation = *pLocation; @@ -389,9 +359,7 @@ _LocationProviderImpl::GetLocation(const LocationCriteria& criteria) { SetLastResult(E_LOCATION_UNAVAILABLE); } - delete pLocation; - return retLocation; CATCH: @@ -410,7 +378,6 @@ _LocationProviderImpl::GetLastKnownLocation(void) SysTryReturn(NID_LOC, pLocationManager, retLocation, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); retLocation = pLocationManager->GetLastKnownLocation(); - if (!retLocation.IsValid()) { SetLastResult(E_LOCATION_UNAVAILABLE); @@ -419,7 +386,6 @@ _LocationProviderImpl::GetLastKnownLocation(void) { ClearLastResult(); } - return retLocation; } @@ -432,7 +398,6 @@ _LocationProviderImpl::OnLocationUpdated(RequestId reqId, const Tizen::Locations std::unique_ptr< Location > pLocation(new (std::nothrow) Location(location)); SysTryReturnVoidResult(NID_LOC, pLocation, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - std::unique_ptr< _LocProviderEventArg > pLocProviderEventArg(new (std::nothrow) _LocProviderEventArg()); SysTryReturnVoidResult(NID_LOC, pLocProviderEventArg, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); @@ -550,7 +515,7 @@ _LocationProviderImpl::OnActiveAppChanged(const Tizen::App::AppId& appId) else { SysLog(NID_LOC, "Application is not active."); - + if (__locationUpdater.awakeEnabled == false && (__locationUpdater.status == LOC_SVC_STATUS_RUNNING || __locationUpdater.status == LOC_SVC_STATUS_NOT_FIXED)) { SysLog(NID_LOC, "Stop the location updates as application is not active with awake mode as (%d) and location update state as (%x).", __locationUpdater.awakeEnabled, __locationUpdater.status); @@ -565,7 +530,6 @@ void _LocationProviderImpl::OnAlarmExpired(Alarm& alarm) { SysLog(NID_LOC, "Region Monitor Alarm expired."); - result r = ActivateRegionMonitoring(); SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to start the region monitoring. Propogating.", GetErrorMessage(r)); } @@ -601,10 +565,10 @@ _LocationProviderImpl::StartLocationUpdates(LocationUpdateType updateType, int i { startUpdate = false; } - else + else { AppUiState appUiState = pAppInstance->GetAppUiState(); - + if (appUiState == APP_UI_STATE_BACKGROUND) { SysLog(NID_LOC, "App is background."); @@ -660,7 +624,6 @@ _LocationProviderImpl::CheckDistanceThreshold(const Location& oldPosition, const __locationUpdater.firstLocationUpdate = false; return true; } - displacement = coordOld.GetDistanceTo(coordNew); SysLog(NID_LOC, "Displacement is (%lf)", displacement); return ((displacement > __locationUpdater.distanceThreshold) ? true : false); @@ -853,7 +816,6 @@ _LocationProviderImpl::GetRegionCurrentState(const _RegionInfo& region, const Lo location.GetCoordinates().GetLongitude(), location.GetHorizontalAccuracy()); _RegionState regionState = REGION_STATE_UNKNOWN; - double distanceBtwCenters = region.GetCoordinate().GetDistanceTo(location.GetCoordinates()); double regionRadius = region.GetRadius(); double locationRadius = location.GetHorizontalAccuracy(); @@ -952,22 +914,17 @@ _LocationProviderImpl::GetUserPrivilege(void) } bool hasPrivilege = false; - result gps = E_SUCCESS; - result wps = E_SUCCESS; - bool gpsEnabled = true; bool wpsEnabled = true; - gps = _SettingInfoImpl::GetValue(L"http://tizen.org/setting/location.gps", gpsEnabled); - wps = _SettingInfoImpl::GetValue(L"http://tizen.org/setting/location.wps", wpsEnabled); + result gps = _SettingInfoImpl::GetValue(L"http://tizen.org/setting/location.gps", gpsEnabled); + result wps = _SettingInfoImpl::GetValue(L"http://tizen.org/setting/location.wps", wpsEnabled); hasPrivilege = gpsEnabled | wpsEnabled; - if (gps != E_SUCCESS || wps != E_SUCCESS || hasPrivilege == false) { return false; } - return true; } @@ -978,10 +935,10 @@ _LocationProviderImpl::ActivateRegionMonitoring(void) SystemTime::GetTicks(currentTime); SysLog(NID_LOC, "Current system time is %lld", currentTime); - + _LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetValidity(false); _LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetTimestamp(currentTime); - + result r = __regionMonitor.pTimer->Start(DEFAULT_WAITING_TIME_FOR_FIXING_LOCATION * 1000); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the timer. Propogating.", GetErrorMessage(r)); @@ -1025,7 +982,6 @@ _LocationProviderImpl::SetNextRegionMonitoringTime(void) alarmTime = newAlarmTime; } } - alarmDateTime.AddSeconds(alarmTime); result r = _AlarmImpl::GetInstance(__regionMonitor.pAlarm.get())->Set(alarmDateTime, 0, null); SysTryLog(NID_LOC, r == E_SUCCESS, "Failed to set the alarm for next cycle."); diff --git a/src/FLoc_MathUtils.cpp b/src/FLoc_MathUtils.cpp index dc6042b..edee539 100644 --- a/src/FLoc_MathUtils.cpp +++ b/src/FLoc_MathUtils.cpp @@ -50,7 +50,6 @@ _MathUtils::CalculateOverlapRegion(const _RegionInfo& region, const Location& lo double distanceBtwCenters = region.GetCoordinate().GetDistanceTo(location.GetCoordinates()); double regionRadius = region.GetRadius(); double locationRadius = location.GetHorizontalAccuracy(); - double distanceBtwCentersSqr = distanceBtwCenters * distanceBtwCenters; double regionRadiusSqr = regionRadius * regionRadius; double locationRadiusSqr = locationRadius * locationRadius; @@ -67,7 +66,6 @@ _MathUtils::CalculateOverlapRegion(const _RegionInfo& region, const Location& lo overlapArea = regionRadiusSqr * (theta - Math::Sin(theta) * Math::Cos(theta)) + locationRadiusSqr * (phi - Math::Sin(phi) * Math::Cos(phi)); } - return overlapArea; } @@ -80,7 +78,6 @@ _MathUtils::GetShortestDistance(const Location& location, const Tizen::Base::Col for (int i = 0; i < count; i++) { const _RegionInfo* pRegionInfo = static_cast<const _RegionInfo*> (regionList.GetAt(i)); - if (pRegionInfo) { Coordinates regionCoordinate = pRegionInfo->GetCoordinate(); @@ -94,7 +91,6 @@ _MathUtils::GetShortestDistance(const Location& location, const Tizen::Base::Col } SysLog(NID_LOC, "Shortest distance from location (lat: %lf and lon: %lf) to the nearest region boundary is (%lf) meters", location.GetCoordinates().GetLatitude(), location.GetCoordinates().GetLongitude(), minDistance); - return minDistance; } } } // Tizen::Locations |