INCLUDE_DIRECTORIES (
${ROOTSTRAP_ROOT}/usr/include/location
+ ${ROOTSTRAP_ROOT}/usr/include
inc
src
/usr/include/osp
/usr/include/osp/app
/usr/include/osp/base
- /usr/include/osp/io
/usr/include/osp/system
/usr/include/osp/security
)
TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-uifw")
TARGET_LINK_LIBRARIES(${this_target} "-lcapi-location-manager")
TARGET_LINK_LIBRARIES(${this_target} "-lpthread")
+TARGET_LINK_LIBRARIES(${this_target} "-lalarm")
SET_TARGET_PROPERTIES(${this_target}
PROPERTIES
Coordinates::Set(double latitude, double longitude, double altitude)
{
SysSecureTryReturn(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);
+ E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The latitude(%lf) must be in the range [-90.0, 90.0].", latitude);
SysSecureTryReturn(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);
+ 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;
Coordinates::SetLatitude(double latitude)
{
SysSecureTryReturn(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);
+ 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;
}
Coordinates::SetLongitude(double longitude)
{
SysSecureTryReturn(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);
+ 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;
}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FLoc_AlarmRequestInfo.h
+ * @brief This is the header file for the %_AlarmRequestInfo class.
+ *
+ * This header file contains the declarations of the %_AlarmRequestInfo class member variables.
+ */
+
+#ifndef _FLOC_INTERNAL_ALARM_REQUEST_INFO_H_
+#define _FLOC_INTERNAL_ALARM_REQUEST_INFO_H_
+
+#include <FBaseObject.h>
+#include <FLocTypes.h>
+
+namespace Tizen { namespace Locations
+{
+
+class _ILocationManagerListener;
+
+class _AlarmRequestInfo
+ : public Tizen::Base::Object
+{
+public:
+ _AlarmRequestInfo(int interval, _ILocationManagerListener* pListener, RequestId reqId)
+ : Tizen::Base::Object()
+ , __interval(interval)
+ , __alarmId(-1)
+ , __reqId(reqId)
+ , __pListener(pListener)
+ {
+ }
+
+ ~_AlarmRequestInfo(void)
+ {
+ }
+
+ _AlarmRequestInfo(const _AlarmRequestInfo& rhs)
+ : Tizen::Base::Object()
+ , __interval(rhs.__interval)
+ , __alarmId(rhs.__alarmId)
+ , __reqId(rhs.__reqId)
+ , __pListener(rhs.__pListener)
+ {
+ }
+
+ int GetInterval(void) const {return __interval;}
+
+ RequestId GetRequestId(void) const {return __reqId;}
+
+ void SetAlarmId(int alarmId) {__alarmId = alarmId;}
+
+ _ILocationManagerListener* GetListener(void) const {return __pListener;}
+
+ int GetAlarmId(void) const {return __alarmId;}
+
+private:
+ _AlarmRequestInfo(void);
+
+ _AlarmRequestInfo& operator =(const _AlarmRequestInfo& rhs);
+
+private:
+ int __interval;
+ int __alarmId;
+ RequestId __reqId;
+ _ILocationManagerListener* __pListener;
+
+};
+}}
+#endif //_FLOC_INTERNAL_ALARM_REQUEST_INFO_H_
*/
virtual void OnRegionMonitoringStatusChanged(Tizen::Locations::LocationServiceStatus locSvcStatus) = 0;
+ /**
+ * Called when the alarm expiry event is fired from the location provider impl class to break the context. @n
+ *
+ * @since 2.0
+ */
+ virtual void OnAlarmExpiredEventReceived(void) = 0;
+
}; //_ILocProviderEventListener
}} // Tizen::Locations
*/
virtual void OnLocationUpdated(RequestId reqId, const Tizen::Locations::Location& location) = 0;
+ /**
+ * Called when the alarm requested by the location provider has expired. @n
+ *
+ * @since 2.0
+ */
+ virtual void OnAlarmExpired(void) = 0;
}; //_ILocationManagerListener
}} // Tizen::Locations
_LOC_PRV_EVENT_SEND_LOC,
_LOC_PRV_EVENT_SEND_LOC_SVC_CB,
_LOC_PRV_EVENT_SEND_MONITOR_SVC_CB,
+ _LOC_PRV_EVENT_SEND_ALARM_EXPIRY,
};
class _LocProviderEventArg
#include <cassert>
#include <iostream>
#include <pthread.h>
+#include <stdlib.h>
#include <unique_ptr.h>
#include <FBaseColArrayList.h>
#include <FBaseInteger.h>
#include <FBaseRtMutex.h>
#include <FBaseRtTimer.h>
#include <FBaseRtMonitor.h>
-#include <FBaseRtWaitingLoop.h>
#include <FBaseSysLog.h>
#include <FLocCoordinates.h>
#include <FSysSystemTime.h>
#include <FSys_PowerManagerImpl.h>
+#include "FLoc_AlarmRequestInfo.h"
#include "FLoc_Config.h"
#include "FLoc_LocationImpl.h"
#include "FLoc_LocationManager.h"
RequestId reqId;
const int ARRAY_LIST_CAPACITY = 1;
+ Location location = GetLastKnownLocation();
+ Tizen::Base::DateTime lastLocTime = location.GetTimestamp();
+
result r = StartLocationUpdates(pLocationMonitor->GetAccuracy(), 1, null, reqId);
SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Error to request location updates.", GetErrorMessage(r));
- std::unique_ptr< _SyncLocationRequestInfo > pSyncLocationRequestInfo(new (std::nothrow) _SyncLocationRequestInfo(pLocationMonitor, reqId));
+ std::unique_ptr< _SyncLocationRequestInfo > pSyncLocationRequestInfo(new (std::nothrow) _SyncLocationRequestInfo(pLocationMonitor, reqId, lastLocTime));
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));
return r;
}
+result
+_LocationManager::RequestStartAlarm(int interval, _ILocationManagerListener* pListener, RequestId reqId)
+{
+ const int ARRAY_LIST_CAPACITY = 1;
+
+ 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));
+
+ std::unique_ptr< _AlarmRequestInfo > pAlarmRequestInfo(new (std::nothrow) _AlarmRequestInfo(interval, pListener, reqId));
+ SysTryReturn(NID_LOC, pAlarmRequestInfo, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ 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(*pAlarmRequestInfo.get());
+ SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Arraylist addition of an object failed. Propogating", GetErrorMessage(r));
+
+ pAlarmRequestInfo.release();
+
+ r = SendUserEvent(REQ_ID_START_ALARM, pArgList.get());
+ SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r));
+
+ pArgList.release();
+
+ SysLog(NID_LOC, "Success to add the alarm.");
+ return E_SUCCESS;
+}
+
+result
+_LocationManager::RequestStopAlarm(RequestId reqId)
+{
+ SysLog(NID_LOC, "Alarm stop requested for request ID (%d).", reqId);
+ const int ARRAY_LIST_CAPACITY = 1;
+
+ 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));
+
+ 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));
+
+ 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));
+
+ pReqId.release();
+
+ r = SendUserEvent(REQ_ID_STOP_ALARM, pArgList.get());
+ SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r));
+
+ pArgList.release();
+ return E_SUCCESS;
+}
+
Location
_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());
+ SysLog(NID_LOC, "Last location(validity: %x, method: %ls) retrieved.",
+ location.IsValid(), location.GetExtraInfo(L"location_method").GetPointer());
return location;
__pLocUpdateTimer->Cancel();
location_manager_stop(__gpsHandler.handle);
location_manager_stop(__wpsHandler.handle);
-
Reset();
}
else
void
_LocationManager::AddToSyncLocationRequestInfoList(_SyncLocationRequestInfo& syncLocRequestInfo)
{
- static bool hasRetrievalStarted = false;
+ result r = syncLocRequestInfo.StartTimer(*this);
+ SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to start the sync timer.", GetErrorMessage(r));
- result r = __pSyncLocRequestInfoList->Add(syncLocRequestInfo);
+ 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;
- const int WAIT_TIME = 1000;
- WaitingLoop::GetInstance()->Wait(WAIT_TIME);
-
- int count = __pSyncLocRequestInfoList->GetCount();
- for (int i = 0; i < count; i++)
- {
- _SyncLocationRequestInfo* pSyncLocRequestInfo = static_cast< _SyncLocationRequestInfo* >(__pSyncLocRequestInfoList->GetAt(i));
- if (pSyncLocRequestInfo != null)
- {
- SysLog(NID_LOC, "Handle the sync location request with request ID (%ld)", pSyncLocRequestInfo->GetRequestId());
-
- HandleSyncRetrievalTimerExpiry(*pSyncLocRequestInfo);
- }
- }
- }
- hasRetrievalStarted = false;
return;
CATCH:
}
void
+_LocationManager::AddToAlarmRequestInfoList(_AlarmRequestInfo& alarmRequestInfo)
+{
+ alarm_id_t alarmId;
+ int res = alarmmgr_add_alarm_withcb(ALARM_TYPE_DEFAULT, alarmRequestInfo.GetInterval(), 0, AlarmExpiryCallback, this, &alarmId);
+ SysTryReturnVoidResult(NID_LOC, res == ALARMMGR_RESULT_SUCCESS, E_SYSTEM, "Failed to add the alarm for next cycle.");
+
+ SysLog(NID_LOC, "The alarm ID (%d) will be set to the request.", alarmId);
+ alarmRequestInfo.SetAlarmId(alarmId);
+
+ std::unique_ptr< _AlarmRequestInfo > pNewAlarmRequestInfo(new (std::nothrow) _AlarmRequestInfo(alarmRequestInfo));
+ SysTryReturnVoidResult(NID_LOC, pNewAlarmRequestInfo, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ result r = __pAlarmRequestInfoList->Add(*pNewAlarmRequestInfo.get());
+ SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, E_SYSTEM, "Failed to add the alarm request into list.");
+ pNewAlarmRequestInfo.release();
+
+ return;
+}
+
+void
+_LocationManager::RemoveFromAlarmRequestInfoList(RequestId reqId)
+{
+ int count = __pAlarmRequestInfoList->GetCount();
+ SysLog(NID_LOC, "Total count of Alarm Request pending is (%d).", count);
+
+ for (int i = 0; i < count; i++)
+ {
+ const _AlarmRequestInfo* pAlarmRequestInfo = static_cast< const _AlarmRequestInfo* >(__pAlarmRequestInfoList->GetAt(i));
+ if (reqId == pAlarmRequestInfo->GetRequestId())
+ {
+ int res = alarmmgr_remove_alarm(pAlarmRequestInfo->GetAlarmId());
+ SysTryLog(NID_LOC, res == ALARMMGR_RESULT_SUCCESS, "Failed to remove the Alarm.");
+ SysLog(NID_LOC, "The alarm with request Id (%d) and Alarm Id (%d) will be removed.", reqId, pAlarmRequestInfo->GetAlarmId());
+ __pAlarmRequestInfoList->RemoveAt(i);
+ break;
+ }
+ }
+
+ return;
+}
+
+void
_LocationManager::RestartLocationUpdates(void)
{
int count = __pLocRequestInfoList->GetCount();
LocationAccuracy accuracy = LOC_ACCURACY_INVALID;
DateTime timestamp = DateTime::GetMinValue();
- Location location = GetRecentLocationAvailable();
+ const Location* pBestLoc = FindBestLocation();
SysLog(NID_LOC, "Location(timestamp: %ls, validity: %x, accuracy: %f) is retrieved.",
- location.GetTimestamp().ToString().GetPointer(), location.IsValid(), location.GetHorizontalAccuracy());
- if (location.IsValid())
+ pBestLoc->GetTimestamp().ToString().GetPointer(), pBestLoc->IsValid(), pBestLoc->GetHorizontalAccuracy());
+ if (pBestLoc->IsValid())
{
- accuracy = GetAccuracyLevel(location.GetHorizontalAccuracy());
- timestamp = location.GetTimestamp();
+ accuracy = GetAccuracyLevel(pBestLoc->GetHorizontalAccuracy());
+ timestamp = pBestLoc->GetTimestamp();
}
bool inTime = syncLocRequestInfo.IsInTime(timestamp);
bool accurate = syncLocRequestInfo.IsAccuracySatisfying(accuracy);
if (inTime && accurate)
{
- unique_ptr< Location > pLocation(new (std::nothrow) Location(location));
+ unique_ptr< Location > pLocation(new (std::nothrow) Location(*pBestLoc));
SysTryCatchLabel(NID_LOC, pLocation != null, , NOTIFY, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
syncLocRequestInfo.GetLocationMonitor()->SetLocation(pLocation.get());
{
if (inTime)
{
- unique_ptr< Location > pLocation(new (std::nothrow) Location(location));
+ unique_ptr< Location > pLocation(new (std::nothrow) Location(*pBestLoc));
SysTryCatchLabel(NID_LOC, pLocation != null, , NOTIFY, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
syncLocRequestInfo.GetLocationMonitor()->SetLocation(pLocation.get());
}
SysLog(NID_LOC, "Wait for next location(Tick: %d).", syncLocRequestInfo.GetTickCount());
- syncLocRequestInfo.IncrementTickCount();
+ syncLocRequestInfo.StartTimer(*this);
return;
NOTIFY:
int res = location_manager_get_last_position(nativeHandle, &altitude, &latitude, &longitude, ×tampPosition);
SysTryCatch(NID_LOC, res == 0, , E_SYSTEM, "[E_SYSTEM] Failed to fetch last position from nativeHandle(%x).", nativeHandle);
SysSecureLog(NID_LOC, "Last position(latitude: %lf, longitude: %lf, altitude: %lf, timestamp: %ld",
- latitude, longitude, altitude, timestampPosition);
+ latitude, longitude, altitude, timestampPosition);
Coordinates coord;
coord.Set(latitude, longitude, altitude);
if (res == 0)
{
SysLog(NID_LOC, "Last velocity(climb: %lf, direction: %lf, speed: %lf, timestamp: %ld)",
- climb, direction, speed, timestampVelocity);
+ climb, direction, speed, timestampVelocity);
pLocationImpl->SetCourse(direction);
pLocationImpl->SetSpeed(speed);
}
long timeDiff = abs(timestampPosition - timestampSatellite);
res = gps_status_foreach_last_satellites_in_view(nativeHandle, SatelliteInfoUpdated, &satInfo);
SysLog(NID_LOC, "Last satellite(foreachResult: %d, inUse: %d, inView: %d, timestamp: %ld, timeDiff: %ld)",
- res, satUsedCount, satViewCount, timestampSatellite, timeDiff);
+ res, satUsedCount, satViewCount, timestampSatellite, timeDiff);
satInfo.Trim();
SysLog(NID_LOC, "Last satellite(info: %ls)", satInfo.GetPointer());
pLocationImpl->SetExtraInfo(L"satellite", satInfo);
}
}
- pLocationImpl->SetTimestamp(((long long)timestampPosition) * 1000); // in milliseconds
+ pLocationImpl->SetTimestamp(((long long) timestampPosition) * 1000); // in milliseconds
pLocationImpl->SetValidity(true);
pLocationImpl->SetExtraInfo(L"location_method", locationMethod);
}
}
}
-void
+void
_LocationManager::UpdateLocRequestInfoList(RequestId reqId, int interval)
{
int count = __pLocRequestInfoList->GetCount();
}
res = location_manager_get_position(nativeHandle, &altitude, &latitude, &longitude, ×tamp);
- SysTryReturnResult(NID_LOC, res == 0, E_SYSTEM, "Failed to obtain the natvie location information for the method (%x)", nativeLocMethod);
+ SysTryReturnResult(NID_LOC, res == 0, E_SYSTEM, "Failed to obtain the natvie location information for the method (%x)", nativeLocMethod);
if (res == 0)
{
int res = -1;
- std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pLocInfoRequestList(new (std::nothrow) ArrayList());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pLocInfoRequestList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturn(NID_LOC, pLocInfoRequestList != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
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());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pSyncLocInfoRequestList(new (std::nothrow) ArrayList(SingleObjectDeleter));
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.");
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pAlarmInfoRequestList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+ SysTryReturn(NID_LOC, pAlarmInfoRequestList != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ r = pAlarmInfoRequestList->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());
__pLocRequestInfoList = std::move(pLocInfoRequestList);
__pSyncLocRequestInfoList = std::move(pSyncLocInfoRequestList);
+ __pAlarmRequestInfoList = std::move(pAlarmInfoRequestList);
__pLocUpdateTimer = std::move(pLocUpdateTimer);
- __gpsHandler.pLocation= std::move(pGpsLocation);
- __wpsHandler.pLocation= std::move(pWpsLocation);
+ __gpsHandler.pLocation = std::move(pGpsLocation);
+ __wpsHandler.pLocation = std::move(pWpsLocation);
r = __pInitMonitor->Enter();
SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to Enter Monitor. Propagating.", GetErrorMessage(r));
}
break;
+ case REQ_ID_START_ALARM:
+ {
+ SysLog(NID_LOC, "REQ_ID_START_ALARM");
+ SysTryReturnVoidResult(NID_LOC, pArgs, E_INVALID_ARG, "[E_INVALID_ARG] Null argument encountered. Ignored.");
+ _AlarmRequestInfo* pAlarmRequestInfo = null;
+ SysTryCatch(NID_LOC, pArgs->GetCount() == ARRAY_LIST_CAPACITY, pArgs->RemoveAll(true), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
+ pAlarmRequestInfo = static_cast< _AlarmRequestInfo* >(pArgs->GetAt(0));
+ SysTryCatch(NID_LOC, pAlarmRequestInfo, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
+
+ AddToAlarmRequestInfoList(*pAlarmRequestInfo);
+ }
+ break;
+
+ case REQ_ID_STOP_ALARM:
+ {
+ SysLog(NID_LOC, "REQ_ID_STOP_ALARM");
+ SysTryReturnVoidResult(NID_LOC, pArgs, E_INVALID_ARG, "[E_INVALID_ARG] Null argument encountered. Ignored.");
+ Integer* pReqId = null;
+ SysTryCatch(NID_LOC, pArgs->GetCount() == ARRAY_LIST_CAPACITY, pArgs->RemoveAll(true), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
+ pReqId = static_cast< Integer* >(pArgs->GetAt(0));
+ SysTryCatch(NID_LOC, pReqId, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
+
+ RemoveFromAlarmRequestInfoList(static_cast< long >(pReqId->ToInt()));
+ }
+ break;
+
}
if (pArgs)
__pLocUpdateTimer->Start(__timerInterval * 1000);
SendLocationCallbacks();
}
+ else
+ {
+ int count = __pSyncLocRequestInfoList->GetCount();
+ for (int i = 0; i < count; i++)
+ {
+ _SyncLocationRequestInfo* pSyncLocRequestInfo = static_cast< _SyncLocationRequestInfo* >(__pSyncLocRequestInfoList->GetAt(i));
+ if (pSyncLocRequestInfo != null && pSyncLocRequestInfo->Equals(timer))
+ {
+ SysLog(NID_LOC, "Timer expired for the sync location request with request ID (%ld)", pSyncLocRequestInfo->GetRequestId());
+
+ HandleSyncRetrievalTimerExpiry(*pSyncLocRequestInfo);
+ break;
+ }
+ }
+ }
return;
}
pThis->__wpsHandler.serviceState = state;
}
+int
+_LocationManager::AlarmExpiryCallback(alarm_id_t alarm_id, void* user_param)
+{
+ SysLog(NID_LOC, "The Alarm expired successfully for the alarm ID (%d).", alarm_id);
+ if (user_param == null)
+ {
+ SysLog(NID_LOC, "The user parameter is null. So cannot handle the callback.");
+ return -1;
+ }
+
+ _LocationManager* pThis = static_cast< _LocationManager* >(user_param);
+ int count = pThis->__pAlarmRequestInfoList->GetCount();
+
+ for (int i = 0; i < count; i++)
+ {
+ _AlarmRequestInfo* pAlarmRequestInfo = static_cast< _AlarmRequestInfo* >(pThis->__pAlarmRequestInfoList->GetAt(i));
+ if (pAlarmRequestInfo)
+ {
+ if (alarm_id == pAlarmRequestInfo->GetAlarmId())
+ {
+ pAlarmRequestInfo->GetListener()->OnAlarmExpired();
+ pThis->__pAlarmRequestInfoList->RemoveAt(i);
+ break;
+ }
+ }
+ }
+
+ return 0;
+}
+
void
_LocationManager::InitLocationManager(void)
{
r = pLocMgr->Start();
SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to start the Location Manager. Propagating.", GetErrorMessage(r));
- r = pLocMgr->WaitThreadStart();
- SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to WaitThreadStart. Propagating.", GetErrorMessage(r));
+ r = pLocMgr->WaitUntilThreadStart();
+ SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to WaitUntilThreadStart. Propagating.", GetErrorMessage(r));
__pUniqueInstance = pLocMgr.release();
std::atexit(DestroyLocationManager);
}
result
-_LocationManager::WaitThreadStart()
+_LocationManager::WaitUntilThreadStart()
{
result r = __pInitMonitor->Enter();
SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to Enter Monitor. Propagating.", GetErrorMessage(r));
#define _FLOC_INTERNAL_LOCATION_MANAGER_H_
#include <unique_ptr.h>
+#include <alarm.h>
#include <location/locations.h>
#include <FBaseColAllElementsDeleter.h>
#include <FBaseRtEventDrivenThread.h>
#include <FLocLocation.h>
#include "FLoc_ILocationManagerListener.h"
#include "FLoc_Types.h"
-#include "FLoc_WaitLoopListener.h"
namespace Tizen { namespace Locations
{
+class _AlarmRequestInfo;
class _LocationMonitor;
class _LocationRequestInfo;
class _SyncLocationRequestInfo;
//
result RegisterLocationMonitor(_LocationMonitor* pLocationMonitor);
- // This method returns the stored location.
+ // This method adds the alarm request into the list of requests and requests for alarm from the core alarm manager.
//
// @since 2.0
//
- Location GetLastKnownLocation(void);
+ result RequestStartAlarm(int interval, _ILocationManagerListener* pListener, RequestId reqId);
- // This method converts the horizontal accuracy in meters to the LocationAccuracy enum type.
+ // This method removes the alarm request from the list of requests and requests the removal of alarm from the core alarm manager.
//
// @since 2.0
//
- LocationAccuracy GetAccuracyLevel(double horAcc) const;
+ result RequestStopAlarm(RequestId reqId);
- // This method returns the wait loop listener of this class.
+ // This method returns the stored location.
//
// @since 2.0
//
- _WaitLoopListener* GetWaitLoopListener(void){return &__waitLoopListener;}
+ Location GetLastKnownLocation(void);
+
+ // This method converts the horizontal accuracy in meters to the LocationAccuracy enum type.
+ //
+ // @since 2.0
+ //
+ LocationAccuracy GetAccuracyLevel(double horAcc) const;
// This method returns the single instance of the location maanger.
//
//
void RemoveSyncLocRetrievalRequest(_SyncLocationRequestInfo& syncLocRequestInfo);
+ // The method adds the _AlarmRequestInfo instance corresponding to a reqId from the array list.
+ //
+ // @since 2.0
+ //
+ void AddToAlarmRequestInfoList(_AlarmRequestInfo& alarmRequestInfo);
+
+ // The method removes the _AlarmRequestInfo instance from the list.
+ //
+ // @since 2.0
+ //
+ void RemoveFromAlarmRequestInfoList(RequestId reqId);
+
// The method restarts both GPS and WPS native location providers.
//
// @since 2.0
//
// @since 2.0
//
- result WaitThreadStart();
+ result WaitUntilThreadStart();
// The method calls the construct method of the event driven thread.
//
// @since 2.0
//
-
result Construct(void);
// This method is gets the last known location from Native side for the given method.
//
static void WpsServiceUpdateCallback(location_service_state_e state, void* user_data);
+ // This method is called by the core alarm manager when the requested alarm is expired.
+ //
+ // @since 2.0
+ //
+ static int AlarmExpiryCallback(alarm_id_t alarm_id, void* user_param);
+
// This method initializes the single instance of the location manager.
//
// @since 2.0
const static RequestId REQ_ID_SYNC_LOC_RETRIEVAL = 6;
const static RequestId REQ_ID_GET_LAST_LOCATION = 7;
const static RequestId REQ_ID_UPDATE_INTERVAL = 8;
+ const static RequestId REQ_ID_START_ALARM = 9;
+ const static RequestId REQ_ID_STOP_ALARM = 10;
enum _LocationMethodRequested
{
_LocationManagerHandle __wpsHandler;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pLocRequestInfoList;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pSyncLocRequestInfoList;
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pAlarmRequestInfoList;
std::unique_ptr< Tizen::Base::Runtime::Timer > __pLocUpdateTimer;
static _LocationManager* __pUniqueInstance;
- _WaitLoopListener __waitLoopListener;
Tizen::Base::Runtime::Monitor* __pInitMonitor;
friend class std::default_delete< _LocationManager >;
#include <FLocTypes.h>
#include <FSysPowerManager.h>
#include <FSysSystemTime.h>
-#include <FSys_AlarmImpl.h>
#include <FSys_SettingInfoImpl.h>
#include "FLoc_LocationImpl.h"
#include "FLoc_LocationManager.h"
_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());
+ std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pRegionList(new (std::nothrow) ArrayList(SingleObjectDeleter));
SysTryReturn(NID_LOC, pRegionList != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
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());
+ 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));
-
UiApp* pAppInstance = Tizen::App::UiApp::GetInstance();
if (pAppInstance != null)
{
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());
+ 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));
_Event::Initialize();
__regionMonitor.pRegionList = std::move(pRegionList);
__regionMonitor.pTimer = std::move(pTimer);
- __regionMonitor.pAlarm = std::move(pAlarm);
__regionMonitor.pLocation = std::move(pLastRegionLocation);
__locationUpdater.pLocation = std::move(pLastLocation);
-
+
__criteria = criteria;
__pLocationListener = &listener;
__pLocationManager = pLocationManager;
_RegionInfo* pRegionInfo = static_cast< _RegionInfo* >(__regionMonitor.pRegionList->GetAt(i));
if (regionId == pRegionInfo->GetRegionId())
{
- __regionMonitor.pRegionList->RemoveAt(i, true);
+ __regionMonitor.pRegionList->RemoveAt(i);
isIdValid = true;
break;
}
}
void
+_LocationProviderImpl::OnAlarmExpired(void)
+{
+ SysLog(NID_LOC, "The call back of the Alarm expiry is called from location manager.");
+
+ 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));
+
+ pLocProviderEventArg->SetEventType(_LOC_PRV_EVENT_SEND_ALARM_EXPIRY);
+
+ result r = _Event::FireAsync(*pLocProviderEventArg);
+ SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to fire the event.", GetErrorMessage(r));
+ pLocProviderEventArg.release();
+
+ return;
+}
+
+void
_LocationProviderImpl::OnLocationEventReceivedN(RequestId reqId, Tizen::Locations::Location& location)
{
SysLog(NID_LOC, "Location Event received.");
bool gpsEnabled = false;
_SettingInfoImpl::GetValue(L"http://tizen.org/setting/location.gps", gpsEnabled);
SysLog(NID_LOC, "The GPS settings value is %d", gpsEnabled);
-
+
__regionMonitor.speed = location.GetSpeed() * 0.2777778;
- if ( currentAccuracy <= lastLocAccuracy || timeDifference > DEFAULT_THRESHOLD_LOC_VALIDITY_TIME_OUT) // Copy the location only if it is new and accuracy is better than before.
+ if (currentAccuracy <= lastLocAccuracy || timeDifference > DEFAULT_THRESHOLD_LOC_VALIDITY_TIME_OUT) // Copy the location only if it is new and accuracy is better than before.
{
*__regionMonitor.pLocation = location;
}
else
{
SysLog(NID_LOC, "Location criteria (accuracy: %ld) is not met for handling region monitoring.", currentAccuracy);
- }
+ }
}
}
}
void
+_LocationProviderImpl::OnAlarmExpiredEventReceived(void)
+{
+ SysLog(NID_LOC, "Region Monitor Alarm expired event received.");
+ result r = ActivateRegionMonitoring(true);
+ SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to start the region monitoring. Propogating.", GetErrorMessage(r));
+}
+
+void
_LocationProviderImpl::OnActiveAppChanged(const Tizen::App::AppId& appId)
{
Tizen::App::App* pApp = Tizen::App::App::GetInstance();
}
void
-_LocationProviderImpl::OnAlarmExpired(Alarm& alarm)
-{
- SysLog(NID_LOC, "Region Monitor Alarm expired.");
- result r = ActivateRegionMonitoring(true);
- SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to start the region monitoring. Propogating.", GetErrorMessage(r));
-}
-
-void
_LocationProviderImpl::OnTimerExpired(Timer& timer)
{
SysLog(NID_LOC, "Region Monitor timer expired due to unavailability of location information.");
__locationUpdater.distanceThreshold = distance;
}
- if (!__locationUpdater.awakeEnabled)
+ if (!__locationUpdater.awakeEnabled)
{
UiApp* pAppInstance = Tizen::App::UiApp::GetInstance();
if (pAppInstance == null)
r = __pLocationManager->StartLocationUpdates(__criteria.GetAccuracy(), __locationUpdater.updateInterval, this, __locationUpdater.reqId);
SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to start the Native location updates. Propagating.", GetErrorMessage(r));
__locationUpdater.status = LOC_SVC_STATUS_NOT_FIXED;
- }
+ }
}
else
{
- __locationUpdater.status = LOC_SVC_STATUS_PAUSED;
+ __locationUpdater.status = LOC_SVC_STATUS_PAUSED;
}
__locationUpdater.type = updateType;
case _LOC_PRV_EVENT_SEND_MONITOR_SVC_CB:
pLocProviderEventListener->OnRegionMonitoringStatusChanged(pEventArg->GetLocServiceStatus());
break;
+
+ case _LOC_PRV_EVENT_SEND_ALARM_EXPIRY:
+ pLocProviderEventListener->OnAlarmExpiredEventReceived();
+ break;
}
}
TryReturn(location.GetHorizontalAccuracy() >= 0.0, REGION_STATE_UNKNOWN, "Location received with invalid accuracy");
SysSecureLog(NID_LOC, "[RegionID %d] Region Information is (Center latitude: %lf, Center longitude: %lf, Region radius:%lf", region.GetRegionId(), region.GetCoordinate().GetLatitude(),
- region.GetCoordinate().GetLongitude(), region.GetRadius());
+ region.GetCoordinate().GetLongitude(), region.GetRadius());
SysSecureLog(NID_LOC, "[RegionID %d] Location Information is (Latitude: %lf, Longitude: %lf, Horizontal accuracy:%lf", region.GetRegionId(), location.GetCoordinates().GetLatitude(),
- location.GetCoordinates().GetLongitude(), location.GetHorizontalAccuracy());
+ location.GetCoordinates().GetLongitude(), location.GetHorizontalAccuracy());
_RegionState regionState = REGION_STATE_UNKNOWN;
double distanceBtwCenters = region.GetCoordinate().GetDistanceTo(location.GetCoordinates());
}
result r = __regionMonitor.pTimer->Start(DEFAULT_WAITING_TIME * 1000);
- SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the timer. Propogating.", GetErrorMessage(r));
+ SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the timer. Propogating.", GetErrorMessage(r));
if (startUpdate)
{
_LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetValidity(false);
- _LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetTimestamp(currentTime);
+ _LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetTimestamp(currentTime);
r = __pLocationManager->StartLocationUpdates(__criteria.GetAccuracy(), MIN_LOCATION_UPDATE_INTERVAL, this, __regionMonitor.reqId);
SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the location updates. Propogating.", GetErrorMessage(r));
SysLog(NID_LOC, "Location updates started.");
}
-
+
return E_SUCCESS;
}
void
_LocationProviderImpl::StopRegionMonitoring(void)
{
- result r = _AlarmImpl::GetInstance(__regionMonitor.pAlarm.get())->Cancel();
+ result r = __pLocationManager->RequestStopAlarm(__regionMonitor.reqId);
SysTryLog(NID_LOC, r == E_SUCCESS, "[%s] Failed to stop the alarm. Ignored.", GetErrorMessage(r));
r = __regionMonitor.pTimer->Cancel();
const int bufferTime = 5; //Buffer of 5 seconds for determining the alarmTime;
double minDistance = _MathUtils::GetShortestDistance(*__regionMonitor.pLocation, *__regionMonitor.pRegionList);
- long long newAlarmTime = ((int) minDistance / speed) - bufferTime; //Calculate the alarm time based on the shortest distance between current location and nearest region boundary.
+ long long newAlarmTime = ((int) minDistance / speed) - bufferTime; //Calculate the alarm time based on the shortest distance between current location and nearest region boundary.
if (newAlarmTime < DEFAULT_REGION_MONITORING_CYCLE_INTERVAL)
{
result r = __pLocationManager->StopLocationUpdates(__regionMonitor.reqId);
SysTryLog(NID_LOC, r == E_SUCCESS, "Failed to stop the location updates.");
-
- alarmDateTime.AddSeconds(alarmTime);
- r = _AlarmImpl::GetInstance(__regionMonitor.pAlarm.get())->Set(alarmDateTime, 0, null);
- SysTryLog(NID_LOC, r == E_SUCCESS, "Failed to set the alarm for next cycle.");
-
+
+ r = __pLocationManager->RequestStartAlarm(alarmTime, this, __regionMonitor.reqId);
+
SysLog(NID_LOC, "Next alarm expires after %ld seconds.", alarmTime);
}
}}
#include <FBaseRtITimerEventListener.h>
#include <FBaseRtTimer.h>
#include <FLocLocationCriteria.h>
-#include <FSysAlarm.h>
-#include <FSysIAlarmEventListener.h>
#include <FBaseRt_Event.h>
#include <FLoc_Config.h>
#include "FLoc_ILocationManagerListener.h"
, public Tizen::Locations::_ILocProviderEventListener
, public Tizen::App::IActiveAppEventListener
, public Tizen::Base::Runtime::ITimerEventListener
- , public Tizen::System::IAlarmEventListener
{
public:
/**
virtual void OnLocationUpdated(RequestId reqId, const Tizen::Locations::Location& location);
/**
+ * @see @ref Tizen::Locations::_ILocationManagerListener::OnAlarmExpired()
+ */
+ virtual void OnAlarmExpired(void);
+
+ /**
* @see @ref Tizen::Locations::_ILocProviderEventListener::OnLocationEventReceivedN()
*/
virtual void OnLocationEventReceivedN(RequestId reqId, Tizen::Locations::Location& location);
virtual void OnRegionMonitoringStatusChanged(Tizen::Locations::LocationServiceStatus locSvcStatus);
/**
- * @see @ref Tizen::App::IActiveAppEventListener::OnActiveAppChanged()
+ * @see @ref Tizen::Locations::_ILocProviderEventListener::OnAlarmExpiredEventReceived()
*/
- virtual void OnActiveAppChanged(const Tizen::App::AppId& appId);
+ virtual void OnAlarmExpiredEventReceived(void);
/**
- * @see @ref Tizen::System::IAlarmEventListener::OnAlarmExpired()
+ * @see @ref Tizen::App::IActiveAppEventListener::OnActiveAppChanged()
*/
- virtual void OnAlarmExpired(Tizen::System::Alarm& alarm);
+ virtual void OnActiveAppChanged(const Tizen::App::AppId& appId);
/**
* @see @ref Tizen::Base::Runtime::ITimerEventListener::OnTimerExpired()
, awakeEnabled(false)
, updateInterval(0)
, status(LOC_SVC_STATUS_IDLE)
- , type(_LOCATION_UPDATE_TYPE_NONE)
+ , type(_LOCATION_UPDATE_TYPE_NONE)
, reqId(-1)
, distanceThreshold(0.0)
, pLocation(null)
~_LocationUpdater(void)
{
}
-
+
public:
bool firstLocationUpdate;
bool awakeEnabled;
LocationUpdateType type;
RequestId reqId;
double distanceThreshold;
- std::unique_ptr<Tizen::Locations::Location> pLocation;
- }__locationUpdater;
-
+ std::unique_ptr< Tizen::Locations::Location > pLocation;
+ }
+ __locationUpdater;
+
class _RegionMonitor
{
public:
_RegionMonitor(void)
: reqId(-1)
, status(LOC_SVC_STATUS_IDLE)
- , speed (DEFAULT_AVG_SPEED)
+ , speed(DEFAULT_AVG_SPEED)
, pTimer(null)
- , pAlarm(null)
, pLocation(null)
, pRegionList(null)
{
~_RegionMonitor(void)
{
}
-
+
public:
RequestId reqId;
LocationServiceStatus status;
double speed;
- std::unique_ptr<Tizen::Base::Runtime::Timer> pTimer;
- std::unique_ptr<Tizen::System::Alarm> pAlarm;
- std::unique_ptr<Tizen::Locations::Location> pLocation;
+ std::unique_ptr< Tizen::Base::Runtime::Timer > pTimer;
+ std::unique_ptr< Tizen::Locations::Location > pLocation;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > pRegionList;
- }__regionMonitor;
+ }
+ __regionMonitor;
LocationAccuracy __lastLocationAccuracy;
LocationCriteria __criteria;
for (int i = 0; i < count; i++)
{
- const _RegionInfo* pRegionInfo = static_cast<const _RegionInfo*> (regionList.GetAt(i));
+ const _RegionInfo* pRegionInfo = static_cast< const _RegionInfo* >(regionList.GetAt(i));
if (pRegionInfo)
{
Coordinates regionCoordinate = pRegionInfo->GetCoordinate();
namespace Tizen { namespace Base { namespace Collection
{
- class IList;
+class IList;
}}}
namespace Tizen { namespace Locations
: public Tizen::Base::Object
{
public:
- _SyncLocationRequestInfo(_LocationMonitor* pLocMonitor, RequestId reqId)
+ _SyncLocationRequestInfo(_LocationMonitor* pLocMonitor, RequestId reqId, const Tizen::Base::DateTime& requestTime)
: Tizen::Base::Object()
+ , __oldLocTime(requestTime)
, __pLocMonitor(pLocMonitor)
+ , __pTimer(null)
, __reqId(reqId)
, __tickCount(0)
{
- Tizen::System::SystemTime::GetCurrentTime(__requestTime);
}
~_SyncLocationRequestInfo(void) {}
_LocationMonitor* GetLocationMonitor(void) const {return __pLocMonitor;}
+ result StartTimer(Tizen::Base::Runtime::ITimerEventListener& listener)
+ {
+ result r = E_SUCCESS;
+
+ if (__pTimer == null)
+ {
+ std::unique_ptr< Tizen::Base::Runtime::Timer > pTimer(new (std::nothrow) Tizen::Base::Runtime::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(listener);
+ SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to construct the timer.", GetErrorMessage(r));
+
+ __pTimer = std::move(pTimer);
+ }
+
+ const int DEFAULT_TIME_OUT = 1000;
+ r = __pTimer->Start(DEFAULT_TIME_OUT);
+ SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the timer.", GetErrorMessage(r));
+ __tickCount++;
+ return E_SUCCESS;
+ }
+
+ bool Equals(const Tizen::Base::Runtime::Timer& timer) {return __pTimer->Equals(timer);}
+
RequestId GetRequestId(void) const {return __reqId;}
int GetTickCount(void) const {return __tickCount;}
- void IncrementTickCount(void) { __tickCount++;}
-
bool IsInTime(const Tizen::Base::DateTime& timestamp)
{
- return (timestamp > __requestTime) ? true : false;
+ SysSecureLog(NID_LOC, "Previous location time is (%ls) and the current location time is (%ls)", __oldLocTime.ToString().GetPointer(), timestamp.ToString().GetPointer());
+ return (timestamp > __oldLocTime) ? true : false;
}
bool IsAccuracySatisfying(LocationAccuracy accuracy)
_SyncLocationRequestInfo& operator =(const _SyncLocationRequestInfo& rhs);
private:
- Tizen::Base::DateTime __requestTime;
+ Tizen::Base::DateTime __oldLocTime;
_LocationMonitor* __pLocMonitor;
+ std::unique_ptr< Tizen::Base::Runtime::Timer > __pTimer;
RequestId __reqId;
int __tickCount;
}; //_SyncLocationRequestInfo
+++ /dev/null
-//
-// Open Service Platform
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file FLoc_WaitLoopListener.h
- * @brief This is the header file for the %_WaitLoopListener class.
- *
- * This header file contains the declarations of the %_WaitLoopListener class methods.
- */
-
-#ifndef _FLOC_INTERNAL_WAITLOOP_LISTENER_H_
-#define _FLOC_INTERNAL_WAITLOOP_LISTENER_H_
-
-#include <FBaseRtIWaitingLoopCondition.h>
-
-namespace Tizen { namespace Locations
-{
-
-class _WaitLoopListener
- : public Tizen::Base::Object
- , public Tizen::Base::Runtime::IWaitingLoopCondition
-{
-public:
- _WaitLoopListener(void)
- : Tizen::Base::Object()
- , __isThreadInitialized(false)
- {
- }
-
- ~_WaitLoopListener(void)
- {
- }
-
- void SetValue(bool isInit)
- {
- __isThreadInitialized = isInit;
- }
-
- bool GetValue(void)
- {
- return __isThreadInitialized;
- }
-
-private:
- virtual bool IsMet(void)
- {
- return (__isThreadInitialized == true) ? true : false;
- }
-
-private:
- bool __isThreadInitialized;
-} ;// class _WaitLoopListener
-}} // Tizen::Locations
-#endif // _FLOC_INTERNAL_WAITLOOP_LISTENER_H_
\ No newline at end of file