diff --git a/core/UlpProxyBase.h b/core/UlpProxyBase.h index 0873748b..90097571 100644 --- a/core/UlpProxyBase.h +++ b/core/UlpProxyBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -37,11 +37,19 @@ class LocAdapterBase; class UlpProxyBase { public: - inline UlpProxyBase() {} + LocPosMode mPosMode; + bool mFixSet; + inline UlpProxyBase() { + mPosMode.mode = LOC_POSITION_MODE_INVALID; + mFixSet = false; + } inline virtual ~UlpProxyBase() {} - inline virtual bool sendStartFix() { return false;} - inline virtual bool sendStopFix() { return false;} - inline virtual bool sendFixMode(LocPosMode ¶ms) { return false;} + inline virtual bool sendStartFix() { mFixSet = true; return false; } + inline virtual bool sendStopFix() { mFixSet = false; return false; } + inline virtual bool sendFixMode(LocPosMode ¶ms) { + mPosMode = params; + return false; + } inline virtual bool reportPosition(UlpLocation &location, GpsLocationExtended &locationExtended, void* locationExt, diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index c8d08853..0b17b2c3 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -52,22 +52,6 @@ void LocInternalAdapter::stopFixInt() { void LocInternalAdapter::getZppInt() { sendMsg(new LocEngGetZpp(mLocEngAdapter)); } -void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) { - struct LocSetUlpProxy : public LocMsg { - LocAdapterBase* mAdapter; - UlpProxyBase* mUlp; - inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) : - LocMsg(), mAdapter(adapter), mUlp(ulp) { - } - virtual void proc() const { - LOC_LOGV("%s] ulp %p adapter %p", __func__, - mUlp, mAdapter); - mAdapter->setUlpProxy(mUlp); - } - }; - - sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp)); -} LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, void* owner, ContextBase* context, @@ -95,6 +79,23 @@ LocEngAdapter::~LocEngAdapter() LOC_LOGV("LocEngAdapter deleted"); } +void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) { + struct LocSetUlpProxy : public LocMsg { + LocAdapterBase* mAdapter; + UlpProxyBase* mUlp; + inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) : + LocMsg(), mAdapter(adapter), mUlp(ulp) { + } + virtual void proc() const { + LOC_LOGV("%s] ulp %p adapter %p", __func__, + mUlp, mAdapter); + mAdapter->setUlpProxy(mUlp); + } + }; + + sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp)); +} + void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp) { if (ulp == mUlp) { @@ -102,18 +103,24 @@ void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp) //and we get the same object back for UlpProxyBase . Do nothing return; } - delete mUlp; + LOC_LOGV("%s] %p", __func__, ulp); if (NULL == ulp) { + LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__); ulp = new UlpProxyBase(); } - mUlp = ulp; - if (LOC_POSITION_MODE_INVALID != mFixCriteria.mode) { + if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) { // need to send this mode and start msg to ULP - mUlp->sendFixMode(mFixCriteria); - mUlp->sendStartFix(); + ulp->sendFixMode(mUlp->mPosMode); } + + if(mUlp->mFixSet) { + ulp->sendStartFix(); + } + + delete mUlp; + mUlp = ulp; } void LocInternalAdapter::reportPosition(UlpLocation &location, @@ -294,4 +301,3 @@ void LocEngAdapter::handleEngineUpEvent() { sendMsg(new LocEngUp(mOwner)); } -