patch for rc20 tizen_2.2
authorJinkun Jang <jinkun.jang@samsung.com>
Thu, 7 Nov 2013 16:06:38 +0000 (01:06 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Thu, 7 Nov 2013 16:06:38 +0000 (01:06 +0900)
packaging/osp-locations.changes
packaging/osp-locations.spec
src/FLoc_LocationManager.cpp
src/FLoc_LocationManager.h
src/FLoc_LocationProviderImpl.cpp
src/FLoc_LocationProviderImpl.h

index daea9df..382b231 100644 (file)
@@ -1,3 +1,12 @@
++[Version] osp-locations_1.2.2.4
++[Date] 30 Oct 2013
++[Title] Handle KeepLocationUdpatesAwake properly. Delete the dependency with normal location udpates. And push the OnSettingsChanged callback to event queue.
++[Issue#] P131015-04420
++[Problem] StartLocationUpdates was not triggered when application does not have power privilege.
++[Cause] We were calling PowerManager API in StartLocationUpdates API of location manager.
++[Solution] Now the PowerManager API to lock the CPU state is called only if the application calls KeepLocationUpdatesAwake.
++[Developer] Sanjay Kumar Agarwal (sanjay.ka@samsung.com)
++===========================================================
 +[Version] osp-locations_1.2.2.3
 +[Date] 10 Sep 2013
 +[Title] Fix the problem where thread is blocked when error happens in OnStart
index 70fb6f5..aea9665 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:          osp-locations
 Summary:       The Locations library of OSP
-Version:       1.2.2.3
+Version:       1.2.2.4
 Release:       2
 Group:         System/Libraries
 License:       Apache License, Version 2
index a3eb7ce..87d1568 100644 (file)
@@ -66,6 +66,7 @@ _LocationManager::_LocationManager(void)
        , __minRequestedAccuracy(LOC_ACCURACY_INVALID)
        , __timerInterval(0)
        , __timerTicks(0)
+       , __awakeReqCount(0)
        , __pLocRequestInfoList(null)
        , __pSyncLocRequestInfoList(null)
        , __pAlarmRequestInfoList(null)
@@ -247,6 +248,28 @@ _LocationManager::RequestStopAlarm(RequestId reqId)
        return E_SUCCESS;
 }
 
+void
+_LocationManager::KeepLocationUpdateAwake(bool enable)
+{
+       SysLog(NID_LOC, "Location update awake requested (%d).", enable);
+       const int ARRAY_LIST_CAPACITY = 1;
+
+       std::unique_ptr< ArrayList, AllElementsDeleter > pArgList(new (std::nothrow) ArrayList());
+       SysTryReturnVoidResult(NID_LOC, pArgList, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       std::unique_ptr< Boolean > pEnable(new (std::nothrow) Boolean(enable));
+       SysTryReturnVoidResult(NID_LOC, pEnable, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pArgList->Construct(ARRAY_LIST_CAPACITY);
+       SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Array Construct failed. Propogating.", GetErrorMessage(r));
+       r = pArgList->Add(*pEnable);
+       SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Arraylist addition of an object failed. Propogating.", GetErrorMessage(r));
+       pEnable.release();
+
+       r = SendUserEvent(REQ_ID_HANDLE_LOC_AWAKE_REQ, pArgList.get());
+       SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to send the user event. Propagating.", GetErrorMessage(r));
+       pArgList.release();
+}
+
 Location
 _LocationManager::GetLastKnownLocation(void)
 {
@@ -345,11 +368,6 @@ _LocationManager::AddToLocRequestInfoList(const _LocationRequestInfo* pLocReques
        __pLocRequestInfoList->Add(*pNewLocRequestInfo.get());
        pNewLocRequestInfo.release();
 
-       if (__minRequestedAccuracy == LOC_ACCURACY_INVALID)
-       {
-               result r = _PowerManagerImpl::PowerControl(1, 1);
-               SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to keep the CPU in awake state.", GetErrorMessage(r));
-       }
        const int FIRST_REQUEST = 1;
        int count = __pLocRequestInfoList->GetCount();
        SysLog(NID_LOC, "Total count of request info is (%d).", count);
@@ -379,8 +397,6 @@ _LocationManager::RemoveFromLocRequestInfoList(RequestId reqId)
        SysLog(NID_LOC, "Total count of request info is (%d).", __pLocRequestInfoList->GetCount());
        if (__pLocRequestInfoList->GetCount() == LIST_COUNT_ZERO)
        {
-               _PowerManagerImpl::PowerControl(1, 0);
-
                Reset();
                location_manager_stop(__locMgrStatus.gpsHandler.handle);
                location_manager_stop(__locMgrStatus.wpsHandler.handle);
@@ -983,6 +999,142 @@ _LocationManager::GetLocation(location_method_e nativeLocMethod)
 }
 
 void
+_LocationManager::HandleSettingsChange(void)
+{
+       const String GPS_STRING(L"http://tizen.org/setting/location.gps");
+       const String WPS_STRING(L"http://tizen.org/setting/location.wps");
+
+       bool gpsEnabled = false;
+       bool wpsEnabled = false;
+       result gps = _SettingInfoImpl::GetValue(GPS_STRING, gpsEnabled);
+       SysTryReturnVoidResult(NID_LOC, gps == E_SUCCESS, gps, "[%s] Failed to get the setting value for GPS.", GetErrorMessage(gps));
+       result wps = _SettingInfoImpl::GetValue(WPS_STRING, wpsEnabled);
+       SysTryReturnVoidResult(NID_LOC, wps == E_SUCCESS, wps, "[%s] Failed to get the setting value for WPS.", GetErrorMessage(wps));
+
+       SysLog(NID_LOC, "The previous GPS setting value is (%d) and WPS setting value is (%d).", __gpsEnabled, __wpsEnabled);
+       SysLog(NID_LOC, "The changed GPS setting value is (%d) and WPS setting value is (%d).", gpsEnabled, wpsEnabled);
+
+       SysLog(NID_LOC, "The Location manager state is (%d).", __locMgrStatus.locMgrState);
+
+       switch (__locMgrStatus.locMgrState)
+       {
+       case LOC_MGR_STATE_PASSIVE_IDLE:
+       {
+               if (gpsEnabled && !wpsEnabled)
+               {
+                       SysLog(NID_LOC, "GPS setting enabled during the LOC_MGR_STATE_PASSIVE_IDLE.");
+                       int res = location_manager_start(__locMgrStatus.gpsHandler.handle);
+                       SysTryLog(NID_LOC, res == 0, "Failed to start the GPS location updates in Passive Idle mode.");
+                       if (res == 0)
+                       {
+                               const int LOC_CHECK_TIMER_VALUE = 1;
+                               __locMgrStatus.locMgrState = LOC_MGR_STATE_GPS_ONLY;
+                               __locMgrStatus.locMgrSubState = LM_SS_NO_FIX;
+                               __pLocCheckTimer->Start(LOC_CHECK_TIMER_VALUE * 1000);
+                       }
+               }
+               else if (!gpsEnabled && wpsEnabled)
+               {
+                       SysLog(NID_LOC, "WPS setting enabled during the LOC_MGR_STATE_PASSIVE_IDLE.");
+                       int res = location_manager_start(__locMgrStatus.wpsHandler.handle);
+                       SysTryLog(NID_LOC, res == 0, "Failed to start the WPS location updates in Passive Idle mode.");
+                       if (res == 0)
+                       {
+                               const int LOC_CHECK_TIMER_VALUE = 1;
+                               __locMgrStatus.locMgrState = LOC_MGR_STATE_WPS_ONLY;
+                               __locMgrStatus.locMgrSubState = LM_SS_NO_FIX;
+                               __pLocCheckTimer->Start(LOC_CHECK_TIMER_VALUE * 1000);
+                       }
+               }
+       }
+       break;
+
+       case LOC_MGR_STATE_BOTH_GPS_WPS:
+       {
+               if (!gpsEnabled)
+               {
+                       SysLog(NID_LOC, "GPS setting turned off during LOC_MGR_STATE_BOTH_GPS_WPS.");
+                       location_manager_stop(__locMgrStatus.gpsHandler.handle);
+                       __locMgrStatus.locMgrState = LOC_MGR_STATE_WPS_ONLY;
+               }
+
+               if (!wpsEnabled)
+               {
+                       SysLog(NID_LOC, "WPS setting turned off during LOC_MGR_STATE_BOTH_GPS_WPS.");
+                       location_manager_stop(__locMgrStatus.wpsHandler.handle);
+                       __locMgrStatus.locMgrState = LOC_MGR_STATE_GPS_ONLY;
+               }
+       }
+       break;
+
+       case LOC_MGR_STATE_GPS_ONLY:
+       {
+               if (!gpsEnabled)
+               {
+                       int res = -1;
+                       if (wpsEnabled)
+                       {
+                               SysLog(NID_LOC, "The WPS setting is enabled. So starting WPS now.");
+                               res = location_manager_start(__locMgrStatus.wpsHandler.handle);
+                               SysTryLog(NID_LOC, res == 0, "Failed to start the location updates for WPS. Return value is (%d).", res);
+                               if (res == 0)
+                               {
+                                       __locMgrStatus.locMgrState = LOC_MGR_STATE_WPS_ONLY;
+                               }
+                       }
+                       if (!wpsEnabled || res != 0)
+                       {
+                               __locMgrStatus.locMgrState = LOC_MGR_STATE_PASSIVE_IDLE;
+                               StopSubStateTimer();
+                               __pLocCheckTimer->Cancel();
+                       }
+
+                       SysLog(NID_LOC, "GPS setting turned off during LOC_MGR_STATE_GPS_ONLY.");
+                       location_manager_stop(__locMgrStatus.gpsHandler.handle);
+               }
+       }
+       break;
+
+       case LOC_MGR_STATE_WPS_ONLY:
+       {
+               if (!wpsEnabled)
+               {
+                       int res = -1;
+                       if (gpsEnabled)
+                       {
+                               SysLog(NID_LOC, "The GPS setting is enabled. So starting GPS now.");
+                               res = location_manager_start(__locMgrStatus.gpsHandler.handle);
+                               SysTryLog(NID_LOC, res == 0, "Failed to start the location updates for GPS. Return value is (%d).", res);
+                               if (res == 0)
+                               {
+                                       __locMgrStatus.locMgrState = LOC_MGR_STATE_GPS_ONLY;
+                               }
+                       }
+                       if (!gpsEnabled || res != 0)
+                       {
+                               __locMgrStatus.locMgrState = LOC_MGR_STATE_PASSIVE_IDLE;
+                               StopSubStateTimer();
+                               __pLocCheckTimer->Cancel();
+                       }
+
+                       SysLog(NID_LOC, "WPS setting turned off during LOC_MGR_STATE_WPS_ONLY.");
+                       location_manager_stop(__locMgrStatus.wpsHandler.handle);
+               }
+       }
+       break;
+
+       case LOC_MGR_STATE_IDLE:
+       // follow through
+       default:
+               SysLog(NID_LOC, "GPS setting changed when there is no active location request. (%d),", __locMgrStatus.locMgrState);
+       break;
+       }
+
+       __gpsEnabled = gpsEnabled;
+       __wpsEnabled = wpsEnabled;
+}
+
+void
 _LocationManager::HandleBothGpsWpsState(void)
 {
        bool isGpsAccMet = false;
@@ -1737,6 +1889,7 @@ _LocationManager::OnStop(void)
                location_manager_destroy(__locMgrStatus.wpsHandler.handle);
        }
        SettingInfo::RemoveSettingEventListener(*this);
+       _PowerManagerImpl::PowerControl(1, 0);
 }
 
 void
@@ -1855,6 +2008,50 @@ _LocationManager::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
        }
        break;
 
+       case REQ_ID_HANDLE_SETTINGS_CHANGE:
+       {
+               SysLog(NID_LOC, "REQ_ID_HANDLE_SETTINGS_CHANGE");
+               HandleSettingsChange();
+       }
+       break;
+
+       case REQ_ID_HANDLE_LOC_AWAKE_REQ:
+       {
+               SysLog(NID_LOC, "REQ_ID_HANDLE_LOC_AWAKE_REQ");
+               SysTryReturnVoidResult(NID_LOC, pArgs, E_INVALID_ARG, "[E_INVALID_ARG] Null argument encountered. Ignored.");
+               Boolean* pEnable = null;
+               result r = E_SUCCESS;
+               bool enable = false;
+               SysTryCatch(NID_LOC, pArgs->GetCount() == ARRAY_LIST_CAPACITY, pArgs->RemoveAll(true), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
+               pEnable = static_cast< Boolean* >(pArgs->GetAt(0));
+               SysTryCatch(NID_LOC, pEnable, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument encountered. Ignored.");
+
+               enable = pEnable->ToBool();
+
+               if (enable == true)
+               {
+                       __awakeReqCount++;
+               }
+               else
+               {
+                       __awakeReqCount--;
+               }
+
+               SysLog(NID_LOC, "The number of current awake request count is (%d).", __awakeReqCount);
+
+               if (__awakeReqCount == 1)
+               {
+                       r = _PowerManagerImpl::PowerControl(1, 1);
+                       SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to lock the CPU in awake state.", GetErrorMessage(r));
+               }
+               else if (__awakeReqCount == 0)
+               {
+                       r = _PowerManagerImpl::PowerControl(1, 0);
+                       SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to unlock the CPU in awake state.", GetErrorMessage(r));
+               }
+       }
+       break;
+
        }
 
        if (pArgs)
@@ -1921,132 +2118,7 @@ _LocationManager::OnSettingChanged(Tizen::Base::String& key)
                return;
        }
 
-       bool gpsEnabled = false;
-       bool wpsEnabled = false;
-       result gps = _SettingInfoImpl::GetValue(GPS_STRING, gpsEnabled);
-       SysTryReturnVoidResult(NID_LOC, gps == E_SUCCESS, gps, "[%s] Failed to get the setting value for GPS.", GetErrorMessage(gps));
-       result wps = _SettingInfoImpl::GetValue(WPS_STRING, wpsEnabled);
-       SysTryReturnVoidResult(NID_LOC, wps == E_SUCCESS, wps, "[%s] Failed to get the setting value for WPS.", GetErrorMessage(wps));
-
-       SysLog(NID_LOC, "The current GPS setting value is (%d) and WPS setting value is (%d).", __gpsEnabled, __wpsEnabled);
-       SysLog(NID_LOC, "The changed GPS setting value is (%d) and WPS setting value is (%d).", gpsEnabled, wpsEnabled);
-
-       switch (__locMgrStatus.locMgrState)
-       {
-       case LOC_MGR_STATE_PASSIVE_IDLE:
-       {
-               if (gpsEnabled && !wpsEnabled)
-               {
-                       SysLog(NID_LOC, "GPS setting enabled during the LOC_MGR_STATE_PASSIVE_IDLE.");
-                       int res = location_manager_start(__locMgrStatus.gpsHandler.handle);
-                       SysTryLog(NID_LOC, res == 0, "Failed to start the GPS location updates in Passive Idle mode.");
-                       if (res == 0)
-                       {
-                               const int LOC_CHECK_TIMER_VALUE = 1;
-                               __locMgrStatus.locMgrState = LOC_MGR_STATE_GPS_ONLY;
-                               __locMgrStatus.locMgrSubState = LM_SS_NO_FIX;
-                               __pLocCheckTimer->Start(LOC_CHECK_TIMER_VALUE * 1000);
-                       }
-               }
-               else if (!gpsEnabled && wpsEnabled)
-               {
-                       SysLog(NID_LOC, "WPS setting enabled during the LOC_MGR_STATE_PASSIVE_IDLE.");
-                       int res = location_manager_start(__locMgrStatus.wpsHandler.handle);
-                       SysTryLog(NID_LOC, res == 0, "Failed to start the WPS location updates in Passive Idle mode.");
-                       if (res == 0)
-                       {
-                               const int LOC_CHECK_TIMER_VALUE = 1;
-                               __locMgrStatus.locMgrState = LOC_MGR_STATE_WPS_ONLY;
-                               __locMgrStatus.locMgrSubState = LM_SS_NO_FIX;
-                               __pLocCheckTimer->Start(LOC_CHECK_TIMER_VALUE * 1000);
-                       }
-               }
-       }
-       break;
-
-       case LOC_MGR_STATE_BOTH_GPS_WPS:
-       {
-               if (!gpsEnabled)
-               {
-                       SysLog(NID_LOC, "GPS setting turned off during LOC_MGR_STATE_BOTH_GPS_WPS.");
-                       location_manager_stop(__locMgrStatus.gpsHandler.handle);
-                       __locMgrStatus.locMgrState = LOC_MGR_STATE_WPS_ONLY;
-               }
-
-               if (!wpsEnabled)
-               {
-                       SysLog(NID_LOC, "WPS setting turned off during LOC_MGR_STATE_BOTH_GPS_WPS.");
-                       location_manager_stop(__locMgrStatus.wpsHandler.handle);
-                       __locMgrStatus.locMgrState = LOC_MGR_STATE_GPS_ONLY;
-               }
-       }
-       break;
-
-       case LOC_MGR_STATE_GPS_ONLY:
-       {
-               if (!gpsEnabled)
-               {
-                       int res = -1;
-                       if (wpsEnabled)
-                       {
-                               SysLog(NID_LOC, "The WPS setting is enabled. So starting WPS now.");
-                               res = location_manager_start(__locMgrStatus.wpsHandler.handle);
-                               SysTryLog(NID_LOC, res == 0, "Failed to start the location updates for WPS. Return value is (%d).", res);
-                               if (res == 0)
-                               {
-                                       __locMgrStatus.locMgrState = LOC_MGR_STATE_WPS_ONLY;
-                               }
-                       }
-                       if (!wpsEnabled || res != 0)
-                       {
-                               __locMgrStatus.locMgrState = LOC_MGR_STATE_PASSIVE_IDLE;
-                               StopSubStateTimer();
-                               __pLocCheckTimer->Cancel();
-                       }
-
-                       SysLog(NID_LOC, "GPS setting turned off during LOC_MGR_STATE_GPS_ONLY.");
-                       location_manager_stop(__locMgrStatus.gpsHandler.handle);
-               }
-       }
-       break;
-
-       case LOC_MGR_STATE_WPS_ONLY:
-       {
-               if (!wpsEnabled)
-               {
-                       int res = -1;
-                       if (gpsEnabled)
-                       {
-                               SysLog(NID_LOC, "The GPS setting is enabled. So starting GPS now.");
-                               res = location_manager_start(__locMgrStatus.gpsHandler.handle);
-                               SysTryLog(NID_LOC, res == 0, "Failed to start the location updates for GPS. Return value is (%d).", res);
-                               if (res == 0)
-                               {
-                                       __locMgrStatus.locMgrState = LOC_MGR_STATE_GPS_ONLY;
-                               }
-                       }
-                       if (!gpsEnabled || res != 0)
-                       {
-                               __locMgrStatus.locMgrState = LOC_MGR_STATE_PASSIVE_IDLE;
-                               StopSubStateTimer();
-                               __pLocCheckTimer->Cancel();
-                       }
-
-                       SysLog(NID_LOC, "WPS setting turned off during LOC_MGR_STATE_WPS_ONLY.");
-                       location_manager_stop(__locMgrStatus.wpsHandler.handle);
-               }
-       }
-       break;
-
-       case LOC_MGR_STATE_IDLE:
-       // follow through
-       default:
-               SysLog(NID_LOC, "GPS setting changed when there is no active location request. (%d),", __locMgrStatus.locMgrState);
-       break;
-       }
-
-       __gpsEnabled = gpsEnabled;
-       __wpsEnabled = wpsEnabled;
+       SendUserEvent(REQ_ID_HANDLE_SETTINGS_CHANGE, null);
 }
 
 bool
index 04de9d6..712e4d8 100644 (file)
@@ -85,6 +85,12 @@ public:
        //
        result RequestStopAlarm(RequestId reqId);
 
+       // This method handles the CPU awake request.
+       //
+       // @since 2.2
+       //
+       void KeepLocationUpdateAwake(bool enabled);
+
        // This method returns the stored location.
        //
        // @since 2.0
@@ -242,6 +248,12 @@ private:
        //
        result GetLocation(location_method_e nativeLocMethod);
 
+       // This method handles the settings change.
+       //
+       // @since 2.2
+       //
+       void HandleSettingsChange(void);
+
        // This method handles the location information obtained from core location provider/s when the location manager state is LOC_MGR_STATE_BOTH_GPS_WPS.
        //
        // @since 2.2
@@ -385,6 +397,8 @@ private:
        const static RequestId REQ_ID_UPDATE_INTERVAL = 5;
        const static RequestId REQ_ID_START_ALARM = 6;
        const static RequestId REQ_ID_STOP_ALARM = 7;
+       const static RequestId REQ_ID_HANDLE_SETTINGS_CHANGE = 8;
+       const static RequestId REQ_ID_HANDLE_LOC_AWAKE_REQ = 9;
 
        enum _LocationManagerState
        {
@@ -465,6 +479,7 @@ private:
        LocationAccuracy __minRequestedAccuracy;
        int __timerInterval;
        int __timerTicks;
+       int __awakeReqCount;
        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;
index 57700ee..014b9c7 100644 (file)
@@ -182,6 +182,8 @@ _LocationProviderImpl::KeepLocationUpdateAwake(bool enable)
        }
        __locationUpdater.awakeEnabled = enable;
 
+       __pLocationManager->KeepLocationUpdateAwake(enable);
+
        UiApp* appInstance = UiApp::GetInstance();
        if (appInstance == null)        // This is service APP. So should be handled now.
        {
@@ -483,8 +485,7 @@ _LocationProviderImpl::OnLocationEventReceivedN(RequestId reqId, Tizen::Location
                        __regionMonitor.speed = location.GetSpeed() * 0.2777778;
 
                        double currentHorAcc = pLocation->GetHorizontalAccuracy();
-                       double previousHorAcc = __regionMonitor.pLocation->GetHorizontalAccuracy();
-                       
+                       double previousHorAcc = __regionMonitor.pLocation->GetHorizontalAccuracy();                     
 
                        if (Double::IsNaN(previousHorAcc) || (!Double::IsNaN(currentHorAcc) &&  currentHorAcc <= previousHorAcc) || timeDifference > DEFAULT_THRESHOLD_LOC_VALIDITY_TIME_OUT)     // Copy the location only if it is new and accuracy is better than before.
                        {
@@ -524,8 +525,11 @@ 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));
+       if (__regionMonitor.status != LOC_SVC_STATUS_IDLE)
+       {
+               result r = ActivateRegionMonitoring(true);
+               SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to start the region monitoring. Propogating.", GetErrorMessage(r));
+       }
 }
 
 void
@@ -988,6 +992,8 @@ _LocationProviderImpl::ActivateRegionMonitoring(bool startUpdate)
                _LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetValidity(false);
                _LocationImpl::GetInstance(*__regionMonitor.pLocation)->SetTimestamp(currentTime);
 
+               __pLocationManager->KeepLocationUpdateAwake(true);
+               __regionMonitor.tempPaused = false;
                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.");
@@ -1002,6 +1008,11 @@ _LocationProviderImpl::StopRegionMonitoring(void)
        result r = __pLocationManager->RequestStopAlarm(__regionMonitor.reqId);
        SysTryLog(NID_LOC, r == E_SUCCESS, "[%s] Failed to stop the alarm. Ignored.", GetErrorMessage(r));
 
+       if (!__regionMonitor.tempPaused)
+       {
+               __pLocationManager->KeepLocationUpdateAwake(false);
+               __regionMonitor.tempPaused = true;
+       }
        r = __regionMonitor.pTimer->Cancel();
        SysTryLog(NID_LOC, r == E_SUCCESS, "[%s] Failed to stop the timer. Ignored.", GetErrorMessage(r));
 
@@ -1043,6 +1054,8 @@ _LocationProviderImpl::SetNextRegionMonitoringTime(void)
                }
        }
 
+       __pLocationManager->KeepLocationUpdateAwake(false);
+       __regionMonitor.tempPaused = true;
        result r = __pLocationManager->StopLocationUpdates(__regionMonitor.reqId);
        SysTryLog(NID_LOC, r == E_SUCCESS, "Failed to stop the location updates.");
 
index 5cdd1e8..526146a 100644 (file)
@@ -304,7 +304,8 @@ private:
        {
        public:
                _RegionMonitor(void)
-                       : reqId(-1)
+                       : tempPaused(true)
+                       , reqId(-1)
                        , status(LOC_SVC_STATUS_IDLE)
                        , speed(DEFAULT_AVG_SPEED)
                        , pTimer(null)
@@ -318,6 +319,7 @@ private:
                }
 
        public:
+               bool tempPaused;
                RequestId reqId;
                LocationServiceStatus status;
                double speed;