summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNandan SR <nandan.sr@samsung.com>2013-04-04 16:13:12 +0530
committerNandan SR <nandan.sr@samsung.com>2013-04-05 09:12:58 +0530
commit85aa74a0b661c67d371b6b2b762c7ae68753cd9b (patch)
tree94341869b28645d5a0022bcdbe32c7857d7792f7 /src
parent3e275221e296650b501730fdb75951c19599f22f (diff)
downloadlocations-85aa74a0b661c67d371b6b2b762c7ae68753cd9b.tar.gz
locations-85aa74a0b661c67d371b6b2b762c7ae68753cd9b.tar.bz2
locations-85aa74a0b661c67d371b6b2b762c7ae68753cd9b.zip
Wait before returning the instance till the Location manager initialization is complete
Change-Id: Iec005a6c1c5db96f65e141fa9312d184f64a75d3 Signed-off-by: Nandan SR <nandan.sr@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/FLoc_LocationManager.cpp9
-rw-r--r--src/FLoc_LocationManager.h19
-rw-r--r--src/FLoc_WaitLoopListener.h68
3 files changed, 86 insertions, 10 deletions
diff --git a/src/FLoc_LocationManager.cpp b/src/FLoc_LocationManager.cpp
index 9afa9ac..37a7b7f 100644
--- a/src/FLoc_LocationManager.cpp
+++ b/src/FLoc_LocationManager.cpp
@@ -66,7 +66,6 @@ _LocationManager::_LocationManager(void)
, __pLocRequestInfoList(null)
, __pSyncLocRequestInfoList(null)
, __pLocUpdateTimer(null)
- , __initialized(false)
{
}
@@ -268,7 +267,7 @@ _LocationManager::GetAccuracyLevel(double horAcc) const
bool
_LocationManager::IsAppEnabled(void)
{
- SysTryReturn(NID_LOC, __initialized, false, E_SYSTEM, "[%s] Location manager is not initialized.", GetErrorMessage(E_SYSTEM));
+ SysTryReturn(NID_LOC, __waitLoopListener.GetValue(), false, E_SYSTEM, "[%s] Location manager is not initialized.", GetErrorMessage(E_SYSTEM));
Boolean enable(false);
Monitor synchronizer;
@@ -1059,7 +1058,7 @@ _LocationManager::OnStart(void)
__gpsHandler.pLocation= std::move(pGpsLocation);
__wpsHandler.pLocation= std::move(pWpsLocation);
- __initialized = true;
+ __waitLoopListener.SetValue(true);
SysLog(NID_LOC, "All the resources for location manager successfully created.");
return true;
@@ -1079,7 +1078,7 @@ CATCH:
void
_LocationManager::OnStop(void)
{
- __initialized = false;
+ __waitLoopListener.SetValue(false);
if (__gpsHandler.handle)
{
@@ -1380,6 +1379,8 @@ _LocationManager::InitLocationManager(void)
r = pLocMgr->Start();
SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Falied to start the Location Manager. Propagating.", GetErrorMessage(r));
+ WaitingLoop::GetInstance()->Wait(*pLocMgr->GetWaitLoopListener());
+
__pUniqueInstance = pLocMgr.release();
std::atexit(DestroyLocationManager);
}
diff --git a/src/FLoc_LocationManager.h b/src/FLoc_LocationManager.h
index dbf524f..4a75f71 100644
--- a/src/FLoc_LocationManager.h
+++ b/src/FLoc_LocationManager.h
@@ -32,6 +32,7 @@
#include <FLocLocation.h>
#include "FLoc_ILocationManagerListener.h"
#include "FLoc_Types.h"
+#include "FLoc_WaitLoopListener.h"
namespace Tizen { namespace Locations
{
@@ -87,6 +88,12 @@ public:
//
bool IsAppEnabled(void);
+ // This method returns the wait loop listener of this class.
+ //
+ // @since 2.0
+ //
+ _WaitLoopListener* GetWaitLoopListener(void){return &__waitLoopListener;}
+
// This method returns the single instance of the location maanger.
//
// @since 2.0
@@ -303,17 +310,17 @@ private:
}
__locationMgrState;
- class __LocationManagerHandle
+ class _LocationManagerHandle
{
public:
- __LocationManagerHandle(void)
+ _LocationManagerHandle(void)
: serviceState(LOCATIONS_SERVICE_DISABLED)
, handle(null)
, pLocation(null)
{
}
- ~__LocationManagerHandle(void)
+ ~_LocationManagerHandle(void)
{
}
@@ -326,13 +333,13 @@ private:
LocationAccuracy __minRequestedAccuracy;
int __timerInterval;
int __timerTicks;
- __LocationManagerHandle __gpsHandler;
- __LocationManagerHandle __wpsHandler;
+ _LocationManagerHandle __gpsHandler;
+ _LocationManagerHandle __wpsHandler;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pLocRequestInfoList;
std::unique_ptr< Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter > __pSyncLocRequestInfoList;
std::unique_ptr< Tizen::Base::Runtime::Timer > __pLocUpdateTimer;
static _LocationManager* __pUniqueInstance;
- bool __initialized;
+ _WaitLoopListener __waitLoopListener;
friend class std::default_delete< _LocationManager >;
}; // class _LocationManager
diff --git a/src/FLoc_WaitLoopListener.h b/src/FLoc_WaitLoopListener.h
new file mode 100644
index 0000000..be41387
--- /dev/null
+++ b/src/FLoc_WaitLoopListener.h
@@ -0,0 +1,68 @@
+//
+// 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