_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());
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));
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;
}
_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());
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));
SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r));
pArgList.release();
-
return E_SUCCESS;
}
_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)));
SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r));
pArgList.release();
-
return E_SUCCESS;
}
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));
SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r));
pArgList.release();
-
return E_SUCCESS;
CATCH:
_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));
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());
onceBlock = PTHREAD_ONCE_INIT;
}
}
-
return __pUniqueInstance;
}
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();
_LocationManager::RemoveFromLocRequestInfoList(RequestId reqId)
{
const int LIST_COUNT_ZERO = 0;
-
int count = __pLocRequestInfoList->GetCount();
for (int i = 0; i < count; i++)
break;
}
}
-
SysLog(NID_LOC, "Total count of request info is (%d).", __pLocRequestInfoList->GetCount());
-
if (__pLocRequestInfoList->GetCount() == LIST_COUNT_ZERO)
{
_PowerManagerImpl::PowerControl(1, 0);
__pLocUpdateTimer->Cancel();
location_manager_stop(__gpsHandler.handle);
location_manager_stop(__wpsHandler.handle);
- location_manager_stop(__cpsHandler.handle);
Reset();
}
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)
SysLog(NID_LOC, "The retrieval under process.");
return;
}
-
while (__pSyncLocRequestInfoList->GetCount() != 0)
{
hasRetrievalStarted = true;
}
}
}
-
hasRetrievalStarted = false;
-
return;
CATCH:
isAccuracyChanged = true;
}
}
-
if (!isAccuracyChanged)
{
return;
}
-
SysLog(NID_LOC, "Location updates are restarted and new minimum requested Accuracy is (%d).", __minRequestedAccuracy);
switch (__locMethodRequested)
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;
__locationMgrState = LOC_MGR_STATE_FAST_SENSING;
__locMethodRequested = LOC_METHOD_REQUESTED_ALL;
-
}
void
{
int gcd = 1;
int count = __pLocRequestInfoList->GetCount();
- result r = E_SUCCESS;
__pLocUpdateTimer->Cancel();
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)
}
}
}
-
__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.");
time_t time_stamp = 0;
RequestId requestId;
-
Location locationData = _LocationImpl::GetLocationInstance();
_LocationImpl* pLocDataImpl = _LocationImpl::GetInstance(locationData);
}
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;
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;
}
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;
}
pLocationImpl->SetExtraInfo(L"satellite", satInfo);
}
}
-
pLocationImpl->SetTimestamp(((long long)timestampPosition) * 1000); // in milliseconds
pLocationImpl->SetValidity(true);
pLocationImpl->SetExtraInfo(L"location_method", locationMethod);
{
long long gpsTimestamp = 0;
long long wpsTimestamp = 0;
- long long cpsTimestamp = 0;
Location lastGpsLocation = GetLastKnownLocation(LOCATIONS_METHOD_GPS);
if (lastGpsLocation.IsValid())
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;
}
}
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())
{
{
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())
}
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
_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;
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;
}
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");
{
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);
}
}
_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:
{
location_manager_destroy(__wpsHandler.handle);
}
-
- if (__cpsHandler.handle)
- {
- location_manager_destroy(__cpsHandler.handle);
- }
return false;
}
{
location_manager_destroy(__gpsHandler.handle);
}
-
if (__wpsHandler.handle)
{
location_manager_destroy(__wpsHandler.handle);
}
-
- if (__cpsHandler.handle)
- {
- location_manager_destroy(__cpsHandler.handle);
- }
}
void
{
SysLog(NID_LOC, "REQ_ID_SUSTAIN_GPS.");
location_manager_stop(__wpsHandler.handle);
- location_manager_stop(__cpsHandler.handle);
__locMethodRequested = LOC_METHOD_REQUESTED_GPS;
}
break;
{
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.");
SysTryCatch(NID_LOC, pSyncLocRequestInfo, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
AddToSyncLocationRequestInfoList(*pSyncLocRequestInfo);
-
pArgs->RemoveAt(0);
}
break;
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);
{
SysLog(NID_LOC, "GPS Location not available at the Native side.");
}
- break;
+ }
+ break;
case LOC_METHOD_REQUESTED_NONE:
// follow through
}
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));
}
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);
}
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));
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));
__pLocationManager = pLocationManager;
SysLog(NID_LOC, "Location provider constructed with the accuracy (%x).", criteria.GetAccuracy());
-
return E_SUCCESS;
}
{
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);
}
{
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);
}
_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;
}
{
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();
__regionMonitor.status = LOC_SVC_STATUS_NOT_FIXED;
NotifyServiceStatus(_LOC_PRV_EVENT_SEND_MONITOR_SVC_CB, __regionMonitor.status);
-
return E_SUCCESS;
CATCH:
{
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++)
}
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;
}
StopRegionMonitoring();
}
-
return E_SUCCESS;
}
}
StopRegionMonitoring();
}
-
return;
}
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;
{
SetLastResult(E_LOCATION_UNAVAILABLE);
}
-
delete pLocation;
-
return retLocation;
CATCH:
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);
{
ClearLastResult();
}
-
return retLocation;
}
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));
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);
_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));
}
{
startUpdate = false;
}
- else
+ else
{
AppUiState appUiState = pAppInstance->GetAppUiState();
-
+
if (appUiState == APP_UI_STATE_BACKGROUND)
{
SysLog(NID_LOC, "App is background.");
__locationUpdater.firstLocationUpdate = false;
return true;
}
-
displacement = coordOld.GetDistanceTo(coordNew);
SysLog(NID_LOC, "Displacement is (%lf)", displacement);
return ((displacement > __locationUpdater.distanceThreshold) ? true : false);
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();
}
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;
}
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));
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.");