sm8250-common: import gps from LA.UM.9.12.r1-13500.01-SMxx50.QSSI12.0
Change-Id: Ib5a80c095e5e203f90cc0d685758553fd18a7f0c
This commit is contained in:
parent
e4e7e5be57
commit
72410cf795
270 changed files with 66183 additions and 615 deletions
675
gps/gnss/Agps.cpp
Normal file
675
gps/gnss/Agps.cpp
Normal file
|
|
@ -0,0 +1,675 @@
|
|||
/* Copyright (c) 2012-2019, 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "LocSvc_Agps"
|
||||
|
||||
#include <Agps.h>
|
||||
#include <loc_pla.h>
|
||||
#include <ContextBase.h>
|
||||
#include <loc_timer.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* AGPS State Machine Methods
|
||||
* -------------------------------------------------------------------*/
|
||||
void AgpsStateMachine::processAgpsEvent(AgpsEvent event){
|
||||
|
||||
LOC_LOGD("processAgpsEvent(): SM %p, Event %d, State %d",
|
||||
this, event, mState);
|
||||
|
||||
switch (event) {
|
||||
|
||||
case AGPS_EVENT_SUBSCRIBE:
|
||||
processAgpsEventSubscribe();
|
||||
break;
|
||||
|
||||
case AGPS_EVENT_UNSUBSCRIBE:
|
||||
processAgpsEventUnsubscribe();
|
||||
break;
|
||||
|
||||
case AGPS_EVENT_GRANTED:
|
||||
processAgpsEventGranted();
|
||||
break;
|
||||
|
||||
case AGPS_EVENT_RELEASED:
|
||||
processAgpsEventReleased();
|
||||
break;
|
||||
|
||||
case AGPS_EVENT_DENIED:
|
||||
processAgpsEventDenied();
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid Loc Agps Event");
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::processAgpsEventSubscribe(){
|
||||
|
||||
switch (mState) {
|
||||
|
||||
case AGPS_STATE_RELEASED:
|
||||
/* Add subscriber to list
|
||||
* No notifications until we get RSRC_GRANTED */
|
||||
addSubscriber(mCurrentSubscriber);
|
||||
requestOrReleaseDataConn(true);
|
||||
transitionState(AGPS_STATE_PENDING);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_PENDING:
|
||||
/* Already requested for data connection,
|
||||
* do nothing until we get RSRC_GRANTED event;
|
||||
* Just add this subscriber to the list, for notifications */
|
||||
addSubscriber(mCurrentSubscriber);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_ACQUIRED:
|
||||
/* We already have the data connection setup,
|
||||
* Notify current subscriber with GRANTED event,
|
||||
* And add it to the subscriber list for further notifications. */
|
||||
notifyEventToSubscriber(AGPS_EVENT_GRANTED, mCurrentSubscriber, false);
|
||||
addSubscriber(mCurrentSubscriber);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_RELEASING:
|
||||
addSubscriber(mCurrentSubscriber);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid state: %d", mState);
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::processAgpsEventUnsubscribe(){
|
||||
|
||||
switch (mState) {
|
||||
|
||||
case AGPS_STATE_RELEASED:
|
||||
notifyEventToSubscriber(
|
||||
AGPS_EVENT_UNSUBSCRIBE, mCurrentSubscriber, false);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_PENDING:
|
||||
case AGPS_STATE_ACQUIRED:
|
||||
/* If the subscriber wishes to wait for connection close,
|
||||
* before being removed from list, move to inactive state
|
||||
* and notify */
|
||||
if (mCurrentSubscriber->mWaitForCloseComplete) {
|
||||
mCurrentSubscriber->mIsInactive = true;
|
||||
}
|
||||
else {
|
||||
/* Notify only current subscriber and then delete it from
|
||||
* subscriberList */
|
||||
notifyEventToSubscriber(
|
||||
AGPS_EVENT_UNSUBSCRIBE, mCurrentSubscriber, true);
|
||||
}
|
||||
|
||||
/* If no subscribers in list, release data connection */
|
||||
if (mSubscriberList.empty()) {
|
||||
transitionState(AGPS_STATE_RELEASED);
|
||||
requestOrReleaseDataConn(false);
|
||||
}
|
||||
/* Some subscribers in list, but all inactive;
|
||||
* Release data connection */
|
||||
else if(!anyActiveSubscribers()) {
|
||||
transitionState(AGPS_STATE_RELEASING);
|
||||
requestOrReleaseDataConn(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case AGPS_STATE_RELEASING:
|
||||
/* If the subscriber wishes to wait for connection close,
|
||||
* before being removed from list, move to inactive state
|
||||
* and notify */
|
||||
if (mCurrentSubscriber->mWaitForCloseComplete) {
|
||||
mCurrentSubscriber->mIsInactive = true;
|
||||
}
|
||||
else {
|
||||
/* Notify only current subscriber and then delete it from
|
||||
* subscriberList */
|
||||
notifyEventToSubscriber(
|
||||
AGPS_EVENT_UNSUBSCRIBE, mCurrentSubscriber, true);
|
||||
}
|
||||
|
||||
/* If no subscribers in list, just move the state.
|
||||
* Request for releasing data connection should already have been
|
||||
* sent */
|
||||
if (mSubscriberList.empty()) {
|
||||
transitionState(AGPS_STATE_RELEASED);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid state: %d", mState);
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::processAgpsEventGranted(){
|
||||
|
||||
switch (mState) {
|
||||
|
||||
case AGPS_STATE_RELEASED:
|
||||
case AGPS_STATE_ACQUIRED:
|
||||
case AGPS_STATE_RELEASING:
|
||||
LOC_LOGE("Unexpected event GRANTED in state %d", mState);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_PENDING:
|
||||
// Move to acquired state
|
||||
transitionState(AGPS_STATE_ACQUIRED);
|
||||
notifyAllSubscribers(
|
||||
AGPS_EVENT_GRANTED, false,
|
||||
AGPS_NOTIFICATION_TYPE_FOR_ACTIVE_SUBSCRIBERS);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid state: %d", mState);
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::processAgpsEventReleased(){
|
||||
|
||||
switch (mState) {
|
||||
|
||||
case AGPS_STATE_RELEASED:
|
||||
/* Subscriber list should be empty if we are in released state */
|
||||
if (!mSubscriberList.empty()) {
|
||||
LOC_LOGE("Unexpected event RELEASED in RELEASED state");
|
||||
}
|
||||
break;
|
||||
|
||||
case AGPS_STATE_ACQUIRED:
|
||||
/* Force release received */
|
||||
LOC_LOGW("Force RELEASED event in ACQUIRED state");
|
||||
transitionState(AGPS_STATE_RELEASED);
|
||||
notifyAllSubscribers(
|
||||
AGPS_EVENT_RELEASED, true,
|
||||
AGPS_NOTIFICATION_TYPE_FOR_ALL_SUBSCRIBERS);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_RELEASING:
|
||||
/* Notify all inactive subscribers about the event */
|
||||
notifyAllSubscribers(
|
||||
AGPS_EVENT_RELEASED, true,
|
||||
AGPS_NOTIFICATION_TYPE_FOR_INACTIVE_SUBSCRIBERS);
|
||||
|
||||
/* If we have active subscribers now, they must be waiting for
|
||||
* data conn setup */
|
||||
if (anyActiveSubscribers()) {
|
||||
transitionState(AGPS_STATE_PENDING);
|
||||
requestOrReleaseDataConn(true);
|
||||
}
|
||||
/* No active subscribers, move to released state */
|
||||
else {
|
||||
transitionState(AGPS_STATE_RELEASED);
|
||||
}
|
||||
break;
|
||||
|
||||
case AGPS_STATE_PENDING:
|
||||
/* NOOP */
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid state: %d", mState);
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::processAgpsEventDenied(){
|
||||
|
||||
switch (mState) {
|
||||
|
||||
case AGPS_STATE_RELEASED:
|
||||
LOC_LOGE("Unexpected event DENIED in state %d", mState);
|
||||
break;
|
||||
|
||||
case AGPS_STATE_ACQUIRED:
|
||||
/* NOOP */
|
||||
break;
|
||||
|
||||
case AGPS_STATE_RELEASING:
|
||||
/* Notify all inactive subscribers about the event */
|
||||
notifyAllSubscribers(
|
||||
AGPS_EVENT_RELEASED, true,
|
||||
AGPS_NOTIFICATION_TYPE_FOR_INACTIVE_SUBSCRIBERS);
|
||||
|
||||
/* If we have active subscribers now, they must be waiting for
|
||||
* data conn setup */
|
||||
if (anyActiveSubscribers()) {
|
||||
transitionState(AGPS_STATE_PENDING);
|
||||
requestOrReleaseDataConn(true);
|
||||
}
|
||||
/* No active subscribers, move to released state */
|
||||
else {
|
||||
transitionState(AGPS_STATE_RELEASED);
|
||||
}
|
||||
break;
|
||||
|
||||
case AGPS_STATE_PENDING:
|
||||
transitionState(AGPS_STATE_RELEASED);
|
||||
notifyAllSubscribers(
|
||||
AGPS_EVENT_DENIED, true,
|
||||
AGPS_NOTIFICATION_TYPE_FOR_ALL_SUBSCRIBERS);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid state: %d", mState);
|
||||
}
|
||||
}
|
||||
|
||||
/* Request or Release data connection
|
||||
* bool request :
|
||||
* true = Request data connection
|
||||
* false = Release data connection */
|
||||
void AgpsStateMachine::requestOrReleaseDataConn(bool request){
|
||||
|
||||
AGnssExtStatusIpV4 nifRequest;
|
||||
memset(&nifRequest, 0, sizeof(nifRequest));
|
||||
|
||||
nifRequest.type = mAgpsType;
|
||||
nifRequest.apnTypeMask = mApnTypeMask;
|
||||
if (request) {
|
||||
LOC_LOGD("AGPS Data Conn Request mAgpsType=%d mApnTypeMask=0x%X",
|
||||
mAgpsType, mApnTypeMask);
|
||||
nifRequest.status = LOC_GPS_REQUEST_AGPS_DATA_CONN;
|
||||
}
|
||||
else{
|
||||
LOC_LOGD("AGPS Data Conn Release mAgpsType=%d mApnTypeMask=0x%X",
|
||||
mAgpsType, mApnTypeMask);
|
||||
nifRequest.status = LOC_GPS_RELEASE_AGPS_DATA_CONN;
|
||||
}
|
||||
|
||||
mFrameworkStatusV4Cb(nifRequest);
|
||||
}
|
||||
|
||||
void AgpsStateMachine::notifyAllSubscribers(
|
||||
AgpsEvent event, bool deleteSubscriberPostNotify,
|
||||
AgpsNotificationType notificationType){
|
||||
|
||||
LOC_LOGD("notifyAllSubscribers(): "
|
||||
"SM %p, Event %d Delete %d Notification Type %d",
|
||||
this, event, deleteSubscriberPostNotify, notificationType);
|
||||
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
while ( it != mSubscriberList.end() ) {
|
||||
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
|
||||
if (notificationType == AGPS_NOTIFICATION_TYPE_FOR_ALL_SUBSCRIBERS ||
|
||||
(notificationType == AGPS_NOTIFICATION_TYPE_FOR_INACTIVE_SUBSCRIBERS &&
|
||||
subscriber->mIsInactive) ||
|
||||
(notificationType == AGPS_NOTIFICATION_TYPE_FOR_ACTIVE_SUBSCRIBERS &&
|
||||
!subscriber->mIsInactive)) {
|
||||
|
||||
/* Deleting via this call would require another traversal
|
||||
* through subscriber list, inefficient; hence pass in false*/
|
||||
notifyEventToSubscriber(event, subscriber, false);
|
||||
|
||||
if (deleteSubscriberPostNotify) {
|
||||
it = mSubscriberList.erase(it);
|
||||
delete subscriber;
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::notifyEventToSubscriber(
|
||||
AgpsEvent event, AgpsSubscriber* subscriberToNotify,
|
||||
bool deleteSubscriberPostNotify) {
|
||||
|
||||
LOC_LOGD("notifyEventToSubscriber(): "
|
||||
"SM %p, Event %d Subscriber %p Delete %d",
|
||||
this, event, subscriberToNotify, deleteSubscriberPostNotify);
|
||||
|
||||
switch (event) {
|
||||
|
||||
case AGPS_EVENT_GRANTED:
|
||||
mAgpsManager->mAtlOpenStatusCb(
|
||||
subscriberToNotify->mConnHandle, 1, getAPN(), getAPNLen(),
|
||||
getBearer(), mAgpsType, mApnTypeMask);
|
||||
break;
|
||||
|
||||
case AGPS_EVENT_DENIED:
|
||||
mAgpsManager->mAtlOpenStatusCb(
|
||||
subscriberToNotify->mConnHandle, 0, getAPN(), getAPNLen(),
|
||||
getBearer(), mAgpsType, mApnTypeMask);
|
||||
break;
|
||||
|
||||
case AGPS_EVENT_UNSUBSCRIBE:
|
||||
case AGPS_EVENT_RELEASED:
|
||||
mAgpsManager->mAtlCloseStatusCb(subscriberToNotify->mConnHandle, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("Invalid event %d", event);
|
||||
}
|
||||
|
||||
/* Search this subscriber in list and delete */
|
||||
if (deleteSubscriberPostNotify) {
|
||||
deleteSubscriber(subscriberToNotify);
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::transitionState(AgpsState newState){
|
||||
|
||||
LOC_LOGD("transitionState(): SM %p, old %d, new %d",
|
||||
this, mState, newState);
|
||||
|
||||
mState = newState;
|
||||
|
||||
// notify state transitions to all subscribers ?
|
||||
}
|
||||
|
||||
void AgpsStateMachine::addSubscriber(AgpsSubscriber* subscriberToAdd){
|
||||
|
||||
LOC_LOGD("addSubscriber(): SM %p, Subscriber %p",
|
||||
this, subscriberToAdd);
|
||||
|
||||
// Check if subscriber is already present in the current list
|
||||
// If not, then add
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
for (; it != mSubscriberList.end(); it++) {
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
if (subscriber->equals(subscriberToAdd)) {
|
||||
LOC_LOGE("Subscriber already in list");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AgpsSubscriber* cloned = subscriberToAdd->clone();
|
||||
LOC_LOGD("addSubscriber(): cloned subscriber: %p", cloned);
|
||||
mSubscriberList.push_back(cloned);
|
||||
}
|
||||
|
||||
void AgpsStateMachine::deleteSubscriber(AgpsSubscriber* subscriberToDelete){
|
||||
|
||||
LOC_LOGD("deleteSubscriber(): SM %p, Subscriber %p",
|
||||
this, subscriberToDelete);
|
||||
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
while ( it != mSubscriberList.end() ) {
|
||||
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
if (subscriber && subscriber->equals(subscriberToDelete)) {
|
||||
|
||||
it = mSubscriberList.erase(it);
|
||||
delete subscriber;
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AgpsStateMachine::anyActiveSubscribers(){
|
||||
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
for (; it != mSubscriberList.end(); it++) {
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
if (!subscriber->mIsInactive) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AgpsStateMachine::setAPN(char* apn, unsigned int len){
|
||||
|
||||
if (NULL != mAPN) {
|
||||
delete mAPN;
|
||||
mAPN = NULL;
|
||||
}
|
||||
|
||||
if (NULL == apn || len > MAX_APN_LEN || strlen(apn) != len) {
|
||||
LOC_LOGD("Invalid apn len (%d) or null apn", len);
|
||||
mAPN = NULL;
|
||||
mAPNLen = 0;
|
||||
} else {
|
||||
mAPN = new char[len+1];
|
||||
if (NULL != mAPN) {
|
||||
memcpy(mAPN, apn, len);
|
||||
mAPN[len] = '\0';
|
||||
mAPNLen = len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AgpsSubscriber* AgpsStateMachine::getSubscriber(int connHandle){
|
||||
|
||||
/* Go over the subscriber list */
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
for (; it != mSubscriberList.end(); it++) {
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
if (subscriber->mConnHandle == connHandle) {
|
||||
return subscriber;
|
||||
}
|
||||
}
|
||||
|
||||
/* Not found, return NULL */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AgpsSubscriber* AgpsStateMachine::getFirstSubscriber(bool isInactive){
|
||||
|
||||
/* Go over the subscriber list */
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
for (; it != mSubscriberList.end(); it++) {
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
if(subscriber->mIsInactive == isInactive) {
|
||||
return subscriber;
|
||||
}
|
||||
}
|
||||
|
||||
/* Not found, return NULL */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AgpsStateMachine::dropAllSubscribers(){
|
||||
|
||||
LOC_LOGD("dropAllSubscribers(): SM %p", this);
|
||||
|
||||
/* Go over the subscriber list */
|
||||
std::list<AgpsSubscriber*>::const_iterator it = mSubscriberList.begin();
|
||||
while ( it != mSubscriberList.end() ) {
|
||||
AgpsSubscriber* subscriber = *it;
|
||||
it = mSubscriberList.erase(it);
|
||||
delete subscriber;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* Loc AGPS Manager Methods
|
||||
* -------------------------------------------------------------------*/
|
||||
|
||||
/* CREATE AGPS STATE MACHINES
|
||||
* Must be invoked in Msg Handler context */
|
||||
void AgpsManager::createAgpsStateMachines(const AgpsCbInfo& cbInfo) {
|
||||
|
||||
LOC_LOGD("AgpsManager::createAgpsStateMachines");
|
||||
|
||||
bool agpsCapable =
|
||||
((loc_core::ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA) ||
|
||||
(loc_core::ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB));
|
||||
|
||||
if (NULL == mInternetNif && (cbInfo.atlType & AGPS_ATL_TYPE_WWAN)) {
|
||||
mInternetNif = new AgpsStateMachine(this, LOC_AGPS_TYPE_WWAN_ANY);
|
||||
mInternetNif->registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
|
||||
LOC_LOGD("Internet NIF: %p", mInternetNif);
|
||||
}
|
||||
if (agpsCapable) {
|
||||
if (NULL == mAgnssNif && (cbInfo.atlType & AGPS_ATL_TYPE_SUPL) &&
|
||||
(cbInfo.atlType & AGPS_ATL_TYPE_SUPL_ES)) {
|
||||
mAgnssNif = new AgpsStateMachine(this, LOC_AGPS_TYPE_SUPL);
|
||||
mAgnssNif->registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
|
||||
LOC_LOGD("AGNSS NIF: %p", mAgnssNif);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AgpsStateMachine* AgpsManager::getAgpsStateMachine(AGpsExtType agpsType) {
|
||||
|
||||
LOC_LOGD("AgpsManager::getAgpsStateMachine(): agpsType %d", agpsType);
|
||||
|
||||
switch (agpsType) {
|
||||
|
||||
case LOC_AGPS_TYPE_INVALID:
|
||||
case LOC_AGPS_TYPE_SUPL:
|
||||
case LOC_AGPS_TYPE_SUPL_ES:
|
||||
if (mAgnssNif == NULL) {
|
||||
LOC_LOGE("NULL AGNSS NIF !");
|
||||
}
|
||||
return mAgnssNif;
|
||||
case LOC_AGPS_TYPE_WWAN_ANY:
|
||||
if (mInternetNif == NULL) {
|
||||
LOC_LOGE("NULL Internet NIF !");
|
||||
}
|
||||
return mInternetNif;
|
||||
default:
|
||||
return mInternetNif;
|
||||
}
|
||||
|
||||
LOC_LOGE("No SM found !");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AgpsManager::requestATL(int connHandle, AGpsExtType agpsType,
|
||||
LocApnTypeMask apnTypeMask){
|
||||
|
||||
LOC_LOGD("AgpsManager::requestATL(): connHandle %d, agpsType 0x%X apnTypeMask: 0x%X",
|
||||
connHandle, agpsType, apnTypeMask);
|
||||
|
||||
if (0 == loc_core::ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL &&
|
||||
LOC_AGPS_TYPE_SUPL_ES == agpsType) {
|
||||
agpsType = LOC_AGPS_TYPE_SUPL;
|
||||
apnTypeMask &= ~LOC_APN_TYPE_MASK_EMERGENCY;
|
||||
apnTypeMask |= LOC_APN_TYPE_MASK_SUPL;
|
||||
LOC_LOGD("Changed agpsType to non-emergency when USE_EMERGENCY... is 0"
|
||||
"and removed LOC_APN_TYPE_MASK_EMERGENCY from apnTypeMask"
|
||||
"agpsType 0x%X apnTypeMask : 0x%X",
|
||||
agpsType, apnTypeMask);
|
||||
}
|
||||
AgpsStateMachine* sm = getAgpsStateMachine(agpsType);
|
||||
|
||||
if (sm == NULL) {
|
||||
|
||||
LOC_LOGE("No AGPS State Machine for agpsType: %d apnTypeMask: 0x%X",
|
||||
agpsType, apnTypeMask);
|
||||
mAtlOpenStatusCb(
|
||||
connHandle, 0, NULL, 0, AGPS_APN_BEARER_INVALID, agpsType, apnTypeMask);
|
||||
return;
|
||||
}
|
||||
sm->setType(agpsType);
|
||||
sm->setApnTypeMask(apnTypeMask);
|
||||
|
||||
/* Invoke AGPS SM processing */
|
||||
AgpsSubscriber subscriber(connHandle, true, false, apnTypeMask);
|
||||
sm->setCurrentSubscriber(&subscriber);
|
||||
/* Send subscriber event */
|
||||
sm->processAgpsEvent(AGPS_EVENT_SUBSCRIBE);
|
||||
}
|
||||
|
||||
void AgpsManager::releaseATL(int connHandle){
|
||||
|
||||
LOC_LOGD("AgpsManager::releaseATL(): connHandle %d", connHandle);
|
||||
|
||||
/* First find the subscriber with specified handle.
|
||||
* We need to search in all state machines. */
|
||||
AgpsStateMachine* sm = NULL;
|
||||
AgpsSubscriber* subscriber = NULL;
|
||||
|
||||
if (mAgnssNif &&
|
||||
(subscriber = mAgnssNif->getSubscriber(connHandle)) != NULL) {
|
||||
sm = mAgnssNif;
|
||||
}
|
||||
else if (mInternetNif &&
|
||||
(subscriber = mInternetNif->getSubscriber(connHandle)) != NULL) {
|
||||
sm = mInternetNif;
|
||||
}
|
||||
if (sm == NULL) {
|
||||
LOC_LOGE("Subscriber with connHandle %d not found in any SM",
|
||||
connHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now send unsubscribe event */
|
||||
sm->setCurrentSubscriber(subscriber);
|
||||
sm->processAgpsEvent(AGPS_EVENT_UNSUBSCRIBE);
|
||||
}
|
||||
|
||||
void AgpsManager::reportAtlOpenSuccess(
|
||||
AGpsExtType agpsType, char* apnName, int apnLen,
|
||||
AGpsBearerType bearerType){
|
||||
|
||||
LOC_LOGD("AgpsManager::reportAtlOpenSuccess(): "
|
||||
"AgpsType %d, APN [%s], Len %d, BearerType %d",
|
||||
agpsType, apnName, apnLen, bearerType);
|
||||
|
||||
/* Find the state machine instance */
|
||||
AgpsStateMachine* sm = getAgpsStateMachine(agpsType);
|
||||
|
||||
/* Set bearer and apn info in state machine instance */
|
||||
sm->setBearer(bearerType);
|
||||
sm->setAPN(apnName, apnLen);
|
||||
|
||||
/* Send GRANTED event to state machine */
|
||||
sm->processAgpsEvent(AGPS_EVENT_GRANTED);
|
||||
}
|
||||
|
||||
void AgpsManager::reportAtlOpenFailed(AGpsExtType agpsType){
|
||||
|
||||
LOC_LOGD("AgpsManager::reportAtlOpenFailed(): AgpsType %d", agpsType);
|
||||
|
||||
/* Fetch SM and send DENIED event */
|
||||
AgpsStateMachine* sm = getAgpsStateMachine(agpsType);
|
||||
sm->processAgpsEvent(AGPS_EVENT_DENIED);
|
||||
}
|
||||
|
||||
void AgpsManager::reportAtlClosed(AGpsExtType agpsType){
|
||||
|
||||
LOC_LOGD("AgpsManager::reportAtlClosed(): AgpsType %d", agpsType);
|
||||
|
||||
/* Fetch SM and send RELEASED event */
|
||||
AgpsStateMachine* sm = getAgpsStateMachine(agpsType);
|
||||
sm->processAgpsEvent(AGPS_EVENT_RELEASED);
|
||||
}
|
||||
|
||||
void AgpsManager::handleModemSSR(){
|
||||
|
||||
LOC_LOGD("AgpsManager::handleModemSSR");
|
||||
|
||||
/* Drop subscribers from all state machines */
|
||||
if (mAgnssNif) {
|
||||
mAgnssNif->dropAllSubscribers();
|
||||
}
|
||||
if (mInternetNif) {
|
||||
mInternetNif->dropAllSubscribers();
|
||||
}
|
||||
}
|
||||
318
gps/gnss/Agps.h
Normal file
318
gps/gnss/Agps.h
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
/* Copyright (c) 2012-2018, 2020 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AGPS_H
|
||||
#define AGPS_H
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <MsgTask.h>
|
||||
#include <gps_extended_c.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
|
||||
using namespace loc_util;
|
||||
|
||||
/* ATL callback function pointers
|
||||
* Passed in by Adapter to AgpsManager */
|
||||
typedef std::function<void(
|
||||
int handle, int isSuccess, char* apn, uint32_t apnLen,
|
||||
AGpsBearerType bearerType, AGpsExtType agpsType,
|
||||
LocApnTypeMask mask)> AgpsAtlOpenStatusCb;
|
||||
|
||||
typedef std::function<void(int handle, int isSuccess)> AgpsAtlCloseStatusCb;
|
||||
|
||||
/* Post message to adapter's message queue */
|
||||
typedef std::function<void(LocMsg* msg)> SendMsgToAdapterMsgQueueFn;
|
||||
|
||||
/* AGPS States */
|
||||
typedef enum {
|
||||
AGPS_STATE_INVALID = 0,
|
||||
AGPS_STATE_RELEASED,
|
||||
AGPS_STATE_PENDING,
|
||||
AGPS_STATE_ACQUIRED,
|
||||
AGPS_STATE_RELEASING
|
||||
} AgpsState;
|
||||
|
||||
typedef enum {
|
||||
AGPS_EVENT_INVALID = 0,
|
||||
AGPS_EVENT_SUBSCRIBE,
|
||||
AGPS_EVENT_UNSUBSCRIBE,
|
||||
AGPS_EVENT_GRANTED,
|
||||
AGPS_EVENT_RELEASED,
|
||||
AGPS_EVENT_DENIED
|
||||
} AgpsEvent;
|
||||
|
||||
/* Notification Types sent to subscribers */
|
||||
typedef enum {
|
||||
AGPS_NOTIFICATION_TYPE_INVALID = 0,
|
||||
|
||||
/* Meant for all subscribers, either active or inactive */
|
||||
AGPS_NOTIFICATION_TYPE_FOR_ALL_SUBSCRIBERS,
|
||||
|
||||
/* Meant for only inactive subscribers */
|
||||
AGPS_NOTIFICATION_TYPE_FOR_INACTIVE_SUBSCRIBERS,
|
||||
|
||||
/* Meant for only active subscribers */
|
||||
AGPS_NOTIFICATION_TYPE_FOR_ACTIVE_SUBSCRIBERS
|
||||
} AgpsNotificationType;
|
||||
|
||||
/* Classes in this header */
|
||||
class AgpsSubscriber;
|
||||
class AgpsManager;
|
||||
class AgpsStateMachine;
|
||||
|
||||
/* SUBSCRIBER
|
||||
* Each Subscriber instance corresponds to one AGPS request,
|
||||
* received by the AGPS state machine */
|
||||
class AgpsSubscriber {
|
||||
|
||||
public:
|
||||
int mConnHandle;
|
||||
|
||||
/* Does this subscriber wait for data call close complete,
|
||||
* before being notified ATL close ?
|
||||
* While waiting for data call close, subscriber will be in
|
||||
* inactive state. */
|
||||
bool mWaitForCloseComplete;
|
||||
bool mIsInactive;
|
||||
LocApnTypeMask mApnTypeMask;
|
||||
|
||||
inline AgpsSubscriber(
|
||||
int connHandle, bool waitForCloseComplete, bool isInactive,
|
||||
LocApnTypeMask apnTypeMask) :
|
||||
mConnHandle(connHandle),
|
||||
mWaitForCloseComplete(waitForCloseComplete),
|
||||
mIsInactive(isInactive),
|
||||
mApnTypeMask(apnTypeMask) {}
|
||||
inline virtual ~AgpsSubscriber() {}
|
||||
|
||||
inline virtual bool equals(const AgpsSubscriber *s) const
|
||||
{ return (mConnHandle == s->mConnHandle); }
|
||||
|
||||
inline virtual AgpsSubscriber* clone()
|
||||
{ return new AgpsSubscriber(
|
||||
mConnHandle, mWaitForCloseComplete, mIsInactive, mApnTypeMask); }
|
||||
};
|
||||
|
||||
/* AGPS STATE MACHINE */
|
||||
class AgpsStateMachine {
|
||||
protected:
|
||||
/* AGPS Manager instance, from where this state machine is created */
|
||||
AgpsManager* mAgpsManager;
|
||||
|
||||
/* List of all subscribers for this State Machine.
|
||||
* Once a subscriber is notified for ATL open/close status,
|
||||
* it is deleted */
|
||||
std::list<AgpsSubscriber*> mSubscriberList;
|
||||
|
||||
/* Current subscriber, whose request this State Machine is
|
||||
* currently processing */
|
||||
AgpsSubscriber* mCurrentSubscriber;
|
||||
|
||||
/* Current state for this state machine */
|
||||
AgpsState mState;
|
||||
|
||||
AgnssStatusIpV4Cb mFrameworkStatusV4Cb;
|
||||
private:
|
||||
/* AGPS Type for this state machine
|
||||
LOC_AGPS_TYPE_ANY 0
|
||||
LOC_AGPS_TYPE_SUPL 1
|
||||
LOC_AGPS_TYPE_WWAN_ANY 3
|
||||
LOC_AGPS_TYPE_SUPL_ES 5 */
|
||||
AGpsExtType mAgpsType;
|
||||
LocApnTypeMask mApnTypeMask;
|
||||
|
||||
/* APN and IP Type info for AGPS Call */
|
||||
char* mAPN;
|
||||
unsigned int mAPNLen;
|
||||
AGpsBearerType mBearer;
|
||||
|
||||
public:
|
||||
/* CONSTRUCTOR */
|
||||
AgpsStateMachine(AgpsManager* agpsManager, AGpsExtType agpsType):
|
||||
mFrameworkStatusV4Cb(NULL),
|
||||
mAgpsManager(agpsManager), mSubscriberList(),
|
||||
mCurrentSubscriber(NULL), mState(AGPS_STATE_RELEASED),
|
||||
mAgpsType(agpsType), mAPN(NULL), mAPNLen(0),
|
||||
mBearer(AGPS_APN_BEARER_INVALID) {};
|
||||
|
||||
virtual ~AgpsStateMachine() { if(NULL != mAPN) delete[] mAPN; };
|
||||
|
||||
/* Getter/Setter methods */
|
||||
void setAPN(char* apn, unsigned int len);
|
||||
inline char* getAPN() const { return mAPN; }
|
||||
inline uint32_t getAPNLen() const { return mAPNLen; }
|
||||
inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; }
|
||||
inline LocApnTypeMask getApnTypeMask() const { return mApnTypeMask; }
|
||||
inline void setApnTypeMask(LocApnTypeMask apnTypeMask)
|
||||
{ mApnTypeMask = apnTypeMask; }
|
||||
inline AGpsBearerType getBearer() const { return mBearer; }
|
||||
inline void setType(AGpsExtType type) { mAgpsType = type; }
|
||||
inline AGpsExtType getType() const { return mAgpsType; }
|
||||
inline void setCurrentSubscriber(AgpsSubscriber* subscriber)
|
||||
{ mCurrentSubscriber = subscriber; }
|
||||
|
||||
inline void registerFrameworkStatusCallback(AgnssStatusIpV4Cb frameworkStatusV4Cb) {
|
||||
mFrameworkStatusV4Cb = frameworkStatusV4Cb;
|
||||
}
|
||||
|
||||
/* Fetch subscriber with specified handle */
|
||||
AgpsSubscriber* getSubscriber(int connHandle);
|
||||
|
||||
/* Fetch first active or inactive subscriber in list
|
||||
* isInactive = true : fetch first inactive subscriber
|
||||
* isInactive = false : fetch first active subscriber */
|
||||
AgpsSubscriber* getFirstSubscriber(bool isInactive);
|
||||
|
||||
/* Process LOC AGPS Event being passed in
|
||||
* onRsrcEvent */
|
||||
virtual void processAgpsEvent(AgpsEvent event);
|
||||
|
||||
/* Drop all subscribers, in case of Modem SSR */
|
||||
void dropAllSubscribers();
|
||||
|
||||
protected:
|
||||
/* Remove the specified subscriber from list if present.
|
||||
* Also delete the subscriber instance. */
|
||||
void deleteSubscriber(AgpsSubscriber* subscriber);
|
||||
|
||||
private:
|
||||
/* Send call setup request to framework
|
||||
* sendRsrcRequest(LOC_GPS_REQUEST_AGPS_DATA_CONN)
|
||||
* sendRsrcRequest(LOC_GPS_RELEASE_AGPS_DATA_CONN) */
|
||||
void requestOrReleaseDataConn(bool request);
|
||||
|
||||
/* Individual event processing methods */
|
||||
void processAgpsEventSubscribe();
|
||||
void processAgpsEventUnsubscribe();
|
||||
void processAgpsEventGranted();
|
||||
void processAgpsEventReleased();
|
||||
void processAgpsEventDenied();
|
||||
|
||||
/* Clone the passed in subscriber and add to the subscriber list
|
||||
* if not already present */
|
||||
void addSubscriber(AgpsSubscriber* subscriber);
|
||||
|
||||
/* Notify subscribers about AGPS events */
|
||||
void notifyAllSubscribers(
|
||||
AgpsEvent event, bool deleteSubscriberPostNotify,
|
||||
AgpsNotificationType notificationType);
|
||||
virtual void notifyEventToSubscriber(
|
||||
AgpsEvent event, AgpsSubscriber* subscriber,
|
||||
bool deleteSubscriberPostNotify);
|
||||
|
||||
/* Do we have any subscribers in active state */
|
||||
bool anyActiveSubscribers();
|
||||
|
||||
/* Transition state */
|
||||
void transitionState(AgpsState newState);
|
||||
};
|
||||
|
||||
/* LOC AGPS MANAGER */
|
||||
class AgpsManager {
|
||||
|
||||
friend class AgpsStateMachine;
|
||||
public:
|
||||
/* CONSTRUCTOR */
|
||||
AgpsManager():
|
||||
mAtlOpenStatusCb(), mAtlCloseStatusCb(),
|
||||
mAgnssNif(NULL), mInternetNif(NULL)/*, mDsNif(NULL)*/ {}
|
||||
|
||||
/* Register callbacks */
|
||||
inline void registerATLCallbacks(AgpsAtlOpenStatusCb atlOpenStatusCb,
|
||||
AgpsAtlCloseStatusCb atlCloseStatusCb) {
|
||||
|
||||
mAtlOpenStatusCb = atlOpenStatusCb;
|
||||
mAtlCloseStatusCb = atlCloseStatusCb;
|
||||
}
|
||||
|
||||
/* Check if AGPS client is registered */
|
||||
inline bool isRegistered() { return nullptr != mAgnssNif || nullptr != mInternetNif; }
|
||||
|
||||
/* Create all AGPS state machines */
|
||||
void createAgpsStateMachines(const AgpsCbInfo& cbInfo);
|
||||
|
||||
/* Process incoming ATL requests */
|
||||
void requestATL(int connHandle, AGpsExtType agpsType, LocApnTypeMask apnTypeMask);
|
||||
void releaseATL(int connHandle);
|
||||
/* Process incoming framework data call events */
|
||||
void reportAtlOpenSuccess(AGpsExtType agpsType, char* apnName, int apnLen,
|
||||
AGpsBearerType bearerType);
|
||||
void reportAtlOpenFailed(AGpsExtType agpsType);
|
||||
void reportAtlClosed(AGpsExtType agpsType);
|
||||
|
||||
/* Handle Modem SSR */
|
||||
void handleModemSSR();
|
||||
|
||||
protected:
|
||||
|
||||
AgpsAtlOpenStatusCb mAtlOpenStatusCb;
|
||||
AgpsAtlCloseStatusCb mAtlCloseStatusCb;
|
||||
AgpsStateMachine* mAgnssNif;
|
||||
AgpsStateMachine* mInternetNif;
|
||||
private:
|
||||
/* Fetch state machine for handling request ATL call */
|
||||
AgpsStateMachine* getAgpsStateMachine(AGpsExtType agpsType);
|
||||
};
|
||||
|
||||
/* Request SUPL/INTERNET/SUPL_ES ATL
|
||||
* This LocMsg is defined in this header since it has to be used from more
|
||||
* than one place, other Agps LocMsg are restricted to GnssAdapter and
|
||||
* declared inline */
|
||||
struct AgpsMsgRequestATL: public LocMsg {
|
||||
|
||||
AgpsManager* mAgpsManager;
|
||||
int mConnHandle;
|
||||
AGpsExtType mAgpsType;
|
||||
LocApnTypeMask mApnTypeMask;
|
||||
|
||||
inline AgpsMsgRequestATL(AgpsManager* agpsManager, int connHandle,
|
||||
AGpsExtType agpsType, LocApnTypeMask apnTypeMask) :
|
||||
LocMsg(), mAgpsManager(agpsManager), mConnHandle(connHandle),
|
||||
mAgpsType(agpsType), mApnTypeMask(apnTypeMask){
|
||||
|
||||
LOC_LOGV("AgpsMsgRequestATL");
|
||||
}
|
||||
|
||||
inline virtual void proc() const {
|
||||
|
||||
LOC_LOGV("AgpsMsgRequestATL::proc()");
|
||||
mAgpsManager->requestATL(mConnHandle, mAgpsType, mApnTypeMask);
|
||||
}
|
||||
};
|
||||
|
||||
namespace AgpsUtils {
|
||||
|
||||
AGpsBearerType ipTypeToBearerType(LocApnIpType ipType);
|
||||
LocApnIpType bearerTypeToIpType(AGpsBearerType bearerType);
|
||||
|
||||
}
|
||||
|
||||
#endif /* AGPS_H */
|
||||
35
gps/gnss/Android.bp
Normal file
35
gps/gnss/Android.bp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
|
||||
cc_library_shared {
|
||||
|
||||
name: "libgnss",
|
||||
vendor: true,
|
||||
|
||||
|
||||
|
||||
shared_libs: [
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"libdl",
|
||||
"liblog",
|
||||
"libloc_core",
|
||||
"libgps.utils",
|
||||
],
|
||||
|
||||
srcs: [
|
||||
"location_gnss.cpp",
|
||||
"GnssAdapter.cpp",
|
||||
"Agps.cpp",
|
||||
"XtraSystemStatusObserver.cpp",
|
||||
"NativeAgpsHandler.cpp",
|
||||
],
|
||||
|
||||
cflags: ["-fno-short-enums"] + GNSS_CFLAGS,
|
||||
header_libs: [
|
||||
"libgps.utils_headers",
|
||||
"libloc_core_headers",
|
||||
"libloc_pla_headers",
|
||||
"liblocation_api_headers",
|
||||
],
|
||||
|
||||
}
|
||||
6979
gps/gnss/GnssAdapter.cpp
Normal file
6979
gps/gnss/GnssAdapter.cpp
Normal file
File diff suppressed because it is too large
Load diff
651
gps/gnss/GnssAdapter.h
Normal file
651
gps/gnss/GnssAdapter.h
Normal file
|
|
@ -0,0 +1,651 @@
|
|||
/* Copyright (c) 2017-2020 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef GNSS_ADAPTER_H
|
||||
#define GNSS_ADAPTER_H
|
||||
|
||||
#include <LocAdapterBase.h>
|
||||
#include <LocContext.h>
|
||||
#include <IOsObserver.h>
|
||||
#include <EngineHubProxyBase.h>
|
||||
#include <LocationAPI.h>
|
||||
#include <Agps.h>
|
||||
#include <SystemStatus.h>
|
||||
#include <XtraSystemStatusObserver.h>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <loc_misc_utils.h>
|
||||
#include <queue>
|
||||
#include <NativeAgpsHandler.h>
|
||||
|
||||
#define MAX_URL_LEN 256
|
||||
#define NMEA_SENTENCE_MAX_LENGTH 200
|
||||
#define GLONASS_SV_ID_OFFSET 64
|
||||
#define MAX_SATELLITES_IN_USE 12
|
||||
#define LOC_NI_NO_RESPONSE_TIME 20
|
||||
#define LOC_GPS_NI_RESPONSE_IGNORE 4
|
||||
#define ODCPI_EXPECTED_INJECTION_TIME_MS 10000
|
||||
#define DELETE_AIDING_DATA_EXPECTED_TIME_MS 5000
|
||||
|
||||
class GnssAdapter;
|
||||
|
||||
typedef std::map<LocationSessionKey, LocationOptions> LocationSessionMap;
|
||||
typedef std::map<LocationSessionKey, TrackingOptions> TrackingOptionsMap;
|
||||
|
||||
class OdcpiTimer : public LocTimer {
|
||||
public:
|
||||
OdcpiTimer(GnssAdapter* adapter) :
|
||||
LocTimer(), mAdapter(adapter), mActive(false) {}
|
||||
|
||||
inline void start() {
|
||||
mActive = true;
|
||||
LocTimer::start(ODCPI_EXPECTED_INJECTION_TIME_MS, false);
|
||||
}
|
||||
inline void stop() {
|
||||
mActive = false;
|
||||
LocTimer::stop();
|
||||
}
|
||||
inline void restart() {
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
inline bool isActive() {
|
||||
return mActive;
|
||||
}
|
||||
|
||||
private:
|
||||
// Override
|
||||
virtual void timeOutCallback() override;
|
||||
|
||||
GnssAdapter* mAdapter;
|
||||
bool mActive;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
pthread_t thread; /* NI thread */
|
||||
uint32_t respTimeLeft; /* examine time for NI response */
|
||||
bool respRecvd; /* NI User reponse received or not from Java layer*/
|
||||
void* rawRequest;
|
||||
uint32_t reqID; /* ID to check against response */
|
||||
GnssNiResponse resp;
|
||||
pthread_cond_t tCond;
|
||||
pthread_mutex_t tLock;
|
||||
GnssAdapter* adapter;
|
||||
} NiSession;
|
||||
typedef struct {
|
||||
NiSession session; /* SUPL NI Session */
|
||||
NiSession sessionEs; /* Emergency SUPL NI Session */
|
||||
uint32_t reqIDCounter;
|
||||
} NiData;
|
||||
|
||||
typedef enum {
|
||||
NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
|
||||
NMEA_PROVIDER_MP // Modem Processor Provider of NMEA
|
||||
} NmeaProviderType;
|
||||
typedef struct {
|
||||
GnssSvType svType;
|
||||
const char* talker;
|
||||
uint64_t mask;
|
||||
uint32_t svIdOffset;
|
||||
} NmeaSvMeta;
|
||||
|
||||
typedef struct {
|
||||
double latitude;
|
||||
double longitude;
|
||||
float accuracy;
|
||||
// the CPI will be blocked until the boot time
|
||||
// specified in blockedTillTsMs
|
||||
int64_t blockedTillTsMs;
|
||||
// CPIs whose both latitude and longitude differ
|
||||
// no more than latLonThreshold will be blocked
|
||||
// in units of degree
|
||||
double latLonDiffThreshold;
|
||||
} BlockCPIInfo;
|
||||
|
||||
typedef struct {
|
||||
bool isValid;
|
||||
bool enable;
|
||||
float tuncThresholdMs; // need to be specified if enable is true
|
||||
uint32_t energyBudget; // need to be specified if enable is true
|
||||
} TuncConfigInfo;
|
||||
|
||||
typedef struct {
|
||||
bool isValid;
|
||||
bool enable;
|
||||
} PaceConfigInfo;
|
||||
|
||||
typedef struct {
|
||||
bool isValid;
|
||||
bool enable;
|
||||
bool enableFor911;
|
||||
} RobustLocationConfigInfo;
|
||||
|
||||
typedef struct {
|
||||
TuncConfigInfo tuncConfigInfo;
|
||||
PaceConfigInfo paceConfigInfo;
|
||||
RobustLocationConfigInfo robustLocationConfigInfo;
|
||||
LeverArmConfigInfo leverArmConfigInfo;
|
||||
} LocIntegrationConfigInfo;
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
namespace loc_core {
|
||||
class SystemStatus;
|
||||
}
|
||||
|
||||
typedef std::function<void(
|
||||
uint64_t gnssEnergyConsumedFromFirstBoot
|
||||
)> GnssEnergyConsumedCallback;
|
||||
|
||||
typedef void* QDgnssListenerHDL;
|
||||
typedef std::function<void(
|
||||
bool sessionActive
|
||||
)> QDgnssSessionActiveCb;
|
||||
|
||||
struct CdfwInterface {
|
||||
void (*startDgnssApiService)(const MsgTask& msgTask);
|
||||
QDgnssListenerHDL (*createUsableReporter)(
|
||||
QDgnssSessionActiveCb sessionActiveCb);
|
||||
void (*destroyUsableReporter)(QDgnssListenerHDL handle);
|
||||
void (*reportUsable)(QDgnssListenerHDL handle, bool usable);
|
||||
};
|
||||
|
||||
typedef uint16_t DGnssStateBitMask;
|
||||
#define DGNSS_STATE_ENABLE_NTRIP_COMMAND 0X01
|
||||
#define DGNSS_STATE_NO_NMEA_PENDING 0X02
|
||||
#define DGNSS_STATE_NTRIP_SESSION_STARTED 0X04
|
||||
|
||||
class GnssReportLoggerUtil {
|
||||
public:
|
||||
typedef void (*LogGnssLatency)(const GnssLatencyInfo& gnssLatencyMeasInfo);
|
||||
|
||||
GnssReportLoggerUtil() : mLogLatency(nullptr) {
|
||||
const char* libname = "liblocdiagiface.so";
|
||||
void* libHandle = nullptr;
|
||||
mLogLatency = (LogGnssLatency)dlGetSymFromLib(libHandle, libname, "LogGnssLatency");
|
||||
}
|
||||
|
||||
bool isLogEnabled();
|
||||
void log(const GnssLatencyInfo& gnssLatencyMeasInfo);
|
||||
|
||||
private:
|
||||
LogGnssLatency mLogLatency;
|
||||
};
|
||||
|
||||
class GnssAdapter : public LocAdapterBase {
|
||||
|
||||
/* ==== Engine Hub ===================================================================== */
|
||||
EngineHubProxyBase* mEngHubProxy;
|
||||
bool mNHzNeeded;
|
||||
bool mSPEAlreadyRunningAtHighestInterval;
|
||||
|
||||
/* ==== TRACKING ======================================================================= */
|
||||
TrackingOptionsMap mTimeBasedTrackingSessions;
|
||||
LocationSessionMap mDistanceBasedTrackingSessions;
|
||||
LocPosMode mLocPositionMode;
|
||||
GnssSvUsedInPosition mGnssSvIdUsedInPosition;
|
||||
bool mGnssSvIdUsedInPosAvail;
|
||||
GnssSvMbUsedInPosition mGnssMbSvIdUsedInPosition;
|
||||
bool mGnssMbSvIdUsedInPosAvail;
|
||||
|
||||
/* ==== CONTROL ======================================================================== */
|
||||
LocationControlCallbacks mControlCallbacks;
|
||||
uint32_t mAfwControlId;
|
||||
uint32_t mNmeaMask;
|
||||
uint64_t mPrevNmeaRptTimeNsec;
|
||||
GnssSvIdConfig mGnssSvIdConfig;
|
||||
GnssSvTypeConfig mGnssSeconaryBandConfig;
|
||||
GnssSvTypeConfig mGnssSvTypeConfig;
|
||||
GnssSvTypeConfigCallback mGnssSvTypeConfigCb;
|
||||
bool mSupportNfwControl;
|
||||
LocIntegrationConfigInfo mLocConfigInfo;
|
||||
|
||||
/* ==== NI ============================================================================= */
|
||||
NiData mNiData;
|
||||
|
||||
/* ==== AGPS =========================================================================== */
|
||||
// This must be initialized via initAgps()
|
||||
AgpsManager mAgpsManager;
|
||||
void initAgps(const AgpsCbInfo& cbInfo);
|
||||
|
||||
/* ==== NFW =========================================================================== */
|
||||
NfwStatusCb mNfwCb;
|
||||
IsInEmergencySession mIsE911Session;
|
||||
inline void initNfw(const NfwCbInfo& cbInfo) {
|
||||
mNfwCb = (NfwStatusCb)cbInfo.visibilityControlCb;
|
||||
mIsE911Session = (IsInEmergencySession)cbInfo.isInEmergencySession;
|
||||
}
|
||||
|
||||
/* ==== Measurement Corrections========================================================= */
|
||||
bool mIsMeasCorrInterfaceOpen;
|
||||
measCorrSetCapabilitiesCb mMeasCorrSetCapabilitiesCb;
|
||||
bool initMeasCorr(bool bSendCbWhenNotSupported);
|
||||
bool mIsAntennaInfoInterfaceOpened;
|
||||
|
||||
/* ==== DGNSS Data Usable Report======================================================== */
|
||||
QDgnssListenerHDL mQDgnssListenerHDL;
|
||||
const CdfwInterface* mCdfwInterface;
|
||||
bool mDGnssNeedReport;
|
||||
bool mDGnssDataUsage;
|
||||
void reportDGnssDataUsable(const GnssSvMeasurementSet &svMeasurementSet);
|
||||
|
||||
/* ==== ODCPI ========================================================================== */
|
||||
OdcpiRequestCallback mOdcpiRequestCb;
|
||||
bool mOdcpiRequestActive;
|
||||
OdcpiPrioritytype mCallbackPriority;
|
||||
OdcpiTimer mOdcpiTimer;
|
||||
OdcpiRequestInfo mOdcpiRequest;
|
||||
void odcpiTimerExpire();
|
||||
|
||||
/* ==== DELETEAIDINGDATA =============================================================== */
|
||||
int64_t mLastDeleteAidingDataTime;
|
||||
|
||||
/* === SystemStatus ===================================================================== */
|
||||
SystemStatus* mSystemStatus;
|
||||
std::string mServerUrl;
|
||||
std::string mMoServerUrl;
|
||||
XtraSystemStatusObserver mXtraObserver;
|
||||
LocationSystemInfo mLocSystemInfo;
|
||||
std::vector<GnssSvIdSource> mBlacklistedSvIds;
|
||||
PowerStateType mSystemPowerState;
|
||||
|
||||
/* === Misc ===================================================================== */
|
||||
BlockCPIInfo mBlockCPIInfo;
|
||||
bool mPowerOn;
|
||||
uint32_t mAllowFlpNetworkFixes;
|
||||
std::queue<GnssLatencyInfo> mGnssLatencyInfoQueue;
|
||||
GnssReportLoggerUtil mLogger;
|
||||
bool mDreIntEnabled;
|
||||
|
||||
/* === NativeAgpsHandler ======================================================== */
|
||||
NativeAgpsHandler mNativeAgpsHandler;
|
||||
|
||||
/* === Misc callback from QMI LOC API ============================================== */
|
||||
GnssEnergyConsumedCallback mGnssEnergyConsumedCb;
|
||||
std::function<void(bool)> mPowerStateCb;
|
||||
|
||||
/*==== CONVERSION ===================================================================*/
|
||||
static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions);
|
||||
static void convertLocation(Location& out, const UlpLocation& ulpLocation,
|
||||
const GpsLocationExtended& locationExtended);
|
||||
static void convertLocationInfo(GnssLocationInfoNotification& out,
|
||||
const GpsLocationExtended& locationExtended,
|
||||
loc_sess_status status);
|
||||
static uint16_t getNumSvUsed(uint64_t svUsedIdsMask,
|
||||
int totalSvCntInThisConstellation);
|
||||
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
inline void initOdcpi(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
|
||||
inline void injectOdcpi(const Location& location);
|
||||
static bool isFlpClient(LocationCallbacks& locationCallbacks);
|
||||
|
||||
/*==== DGnss Ntrip Source ==========================================================*/
|
||||
StartDgnssNtripParams mStartDgnssNtripParams;
|
||||
bool mSendNmeaConsent;
|
||||
DGnssStateBitMask mDgnssState;
|
||||
void checkUpdateDgnssNtrip(bool isLocationValid);
|
||||
void stopDgnssNtrip();
|
||||
uint64_t mDgnssLastNmeaBootTimeMilli;
|
||||
|
||||
protected:
|
||||
|
||||
/* ==== CLIENT ========================================================================= */
|
||||
virtual void updateClientsEventMask();
|
||||
virtual void stopClientSessions(LocationAPI* client);
|
||||
inline void setNmeaReportRateConfig();
|
||||
void logLatencyInfo();
|
||||
|
||||
public:
|
||||
GnssAdapter();
|
||||
virtual inline ~GnssAdapter() { }
|
||||
|
||||
/* ==== SSR ============================================================================ */
|
||||
/* ======== EVENTS ====(Called from QMI Thread)========================================= */
|
||||
virtual void handleEngineUpEvent();
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
void restartSessions(bool modemSSR = false);
|
||||
void checkAndRestartTimeBasedSession();
|
||||
void checkAndRestartSPESession();
|
||||
void suspendSessions();
|
||||
|
||||
/* ==== CLIENT ========================================================================= */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
virtual void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks);
|
||||
|
||||
/* ==== TRACKING ======================================================================= */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
uint32_t startTrackingCommand(
|
||||
LocationAPI* client, TrackingOptions& trackingOptions);
|
||||
void updateTrackingOptionsCommand(
|
||||
LocationAPI* client, uint32_t id, TrackingOptions& trackingOptions);
|
||||
void stopTrackingCommand(LocationAPI* client, uint32_t id);
|
||||
/* ======== RESPONSES ================================================================== */
|
||||
void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId);
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
bool isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId);
|
||||
bool isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessionId);
|
||||
bool hasCallbacksToStartTracking(LocationAPI* client);
|
||||
bool isTrackingSession(LocationAPI* client, uint32_t sessionId);
|
||||
void saveTrackingSession(LocationAPI* client, uint32_t sessionId,
|
||||
const TrackingOptions& trackingOptions);
|
||||
void eraseTrackingSession(LocationAPI* client, uint32_t sessionId);
|
||||
|
||||
bool setLocPositionMode(const LocPosMode& mode);
|
||||
LocPosMode& getLocPositionMode() { return mLocPositionMode; }
|
||||
|
||||
bool startTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t sessionId,
|
||||
const TrackingOptions& trackingOptions);
|
||||
void startTimeBasedTracking(LocationAPI* client, uint32_t sessionId,
|
||||
const TrackingOptions& trackingOptions);
|
||||
bool stopTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t id);
|
||||
void stopTracking(LocationAPI* client, uint32_t id);
|
||||
bool updateTrackingMultiplex(LocationAPI* client, uint32_t id,
|
||||
const TrackingOptions& trackingOptions);
|
||||
void updateTracking(LocationAPI* client, uint32_t sessionId,
|
||||
const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions);
|
||||
bool checkAndSetSPEToRunforNHz(TrackingOptions & out);
|
||||
|
||||
void setConstrainedTunc(bool enable, float tuncConstraint,
|
||||
uint32_t energyBudget, uint32_t sessionId);
|
||||
void setPositionAssistedClockEstimator(bool enable, uint32_t sessionId);
|
||||
void gnssUpdateSvConfig(uint32_t sessionId,
|
||||
const GnssSvTypeConfig& constellationEnablementConfig,
|
||||
const GnssSvIdConfig& blacklistSvConfig);
|
||||
|
||||
void gnssUpdateSecondaryBandConfig(
|
||||
uint32_t sessionId, const GnssSvTypeConfig& secondaryBandConfig);
|
||||
void gnssGetSecondaryBandConfig(uint32_t sessionId);
|
||||
void resetSvConfig(uint32_t sessionId);
|
||||
void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo);
|
||||
void configRobustLocation(uint32_t sessionId, bool enable, bool enableForE911);
|
||||
void configMinGpsWeek(uint32_t sessionId, uint16_t minGpsWeek);
|
||||
|
||||
/* ==== NI ============================================================================= */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response);
|
||||
/* ======================(Called from NI Thread)======================================== */
|
||||
void gnssNiResponseCommand(GnssNiResponse response, void* rawRequest);
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
bool hasNiNotifyCallback(LocationAPI* client);
|
||||
NiData& getNiData() { return mNiData; }
|
||||
|
||||
/* ==== CONTROL CLIENT ================================================================= */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
uint32_t enableCommand(LocationTechnologyType techType);
|
||||
void disableCommand(uint32_t id);
|
||||
void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks);
|
||||
void readConfigCommand();
|
||||
void requestUlpCommand();
|
||||
void initEngHubProxyCommand();
|
||||
uint32_t* gnssUpdateConfigCommand(const GnssConfig& config);
|
||||
uint32_t* gnssGetConfigCommand(GnssConfigFlagsMask mask);
|
||||
uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data);
|
||||
void deleteAidingData(const GnssAidingData &data, uint32_t sessionId);
|
||||
void gnssUpdateXtraThrottleCommand(const bool enabled);
|
||||
std::vector<LocationError> gnssUpdateConfig(const std::string& oldMoServerUrl,
|
||||
const std::string& moServerUrl,
|
||||
const std::string& serverUrl,
|
||||
GnssConfig& gnssConfigRequested,
|
||||
GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0);
|
||||
|
||||
/* ==== GNSS SV TYPE CONFIG ============================================================ */
|
||||
/* ==== COMMANDS ====(Called from Client Thread)======================================== */
|
||||
/* ==== These commands are received directly from client bypassing Location API ======== */
|
||||
void gnssUpdateSvTypeConfigCommand(GnssSvTypeConfig config);
|
||||
void gnssGetSvTypeConfigCommand(GnssSvTypeConfigCallback callback);
|
||||
void gnssResetSvTypeConfigCommand();
|
||||
|
||||
/* ==== UTILITIES ====================================================================== */
|
||||
LocationError gnssSvIdConfigUpdateSync(const std::vector<GnssSvIdSource>& blacklistedSvIds);
|
||||
LocationError gnssSvIdConfigUpdateSync();
|
||||
void gnssSvIdConfigUpdate(const std::vector<GnssSvIdSource>& blacklistedSvIds);
|
||||
void gnssSvIdConfigUpdate();
|
||||
void gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config);
|
||||
void gnssSvTypeConfigUpdate(bool sendReset = false);
|
||||
inline void gnssSetSvTypeConfig(const GnssSvTypeConfig& config)
|
||||
{ mGnssSvTypeConfig = config; }
|
||||
inline void gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback)
|
||||
{ mGnssSvTypeConfigCb = callback; }
|
||||
inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback()
|
||||
{ return mGnssSvTypeConfigCb; }
|
||||
void setConfig();
|
||||
void gnssSecondaryBandConfigUpdate(LocApiResponse* locApiResponse= nullptr);
|
||||
|
||||
/* ========= AGPS ====================================================================== */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
void initDefaultAgpsCommand();
|
||||
void initAgpsCommand(const AgpsCbInfo& cbInfo);
|
||||
void initNfwCommand(const NfwCbInfo& cbInfo);
|
||||
void dataConnOpenCommand(AGpsExtType agpsType,
|
||||
const char* apnName, int apnLen, AGpsBearerType bearerType);
|
||||
void dataConnClosedCommand(AGpsExtType agpsType);
|
||||
void dataConnFailedCommand(AGpsExtType agpsType);
|
||||
void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb);
|
||||
void nfwControlCommand(bool enable);
|
||||
uint32_t setConstrainedTuncCommand (bool enable, float tuncConstraint,
|
||||
uint32_t energyBudget);
|
||||
uint32_t setPositionAssistedClockEstimatorCommand (bool enable);
|
||||
uint32_t gnssUpdateSvConfigCommand(const GnssSvTypeConfig& constellationEnablementConfig,
|
||||
const GnssSvIdConfig& blacklistSvConfig);
|
||||
uint32_t gnssUpdateSecondaryBandConfigCommand(
|
||||
const GnssSvTypeConfig& secondaryBandConfig);
|
||||
uint32_t gnssGetSecondaryBandConfigCommand();
|
||||
uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo);
|
||||
uint32_t configRobustLocationCommand(bool enable, bool enableForE911);
|
||||
bool openMeasCorrCommand(const measCorrSetCapabilitiesCb setCapabilitiesCb);
|
||||
bool measCorrSetCorrectionsCommand(const GnssMeasurementCorrections gnssMeasCorr);
|
||||
inline void closeMeasCorrCommand() { mIsMeasCorrInterfaceOpen = false; }
|
||||
uint32_t antennaInfoInitCommand(const antennaInfoCb antennaInfoCallback);
|
||||
inline void antennaInfoCloseCommand() { mIsAntennaInfoInterfaceOpened = false; }
|
||||
uint32_t configMinGpsWeekCommand(uint16_t minGpsWeek);
|
||||
uint32_t configDeadReckoningEngineParamsCommand(const DeadReckoningEngineConfig& dreConfig);
|
||||
uint32_t configEngineRunStateCommand(PositioningEngineMask engType,
|
||||
LocEngineRunState engState);
|
||||
|
||||
/* ========= ODCPI ===================================================================== */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
void initOdcpiCommand(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
|
||||
void injectOdcpiCommand(const Location& location);
|
||||
/* ======== RESPONSES ================================================================== */
|
||||
void reportResponse(LocationError err, uint32_t sessionId);
|
||||
void reportResponse(size_t count, LocationError* errs, uint32_t* ids);
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
LocationControlCallbacks& getControlCallbacks() { return mControlCallbacks; }
|
||||
void setControlCallbacks(const LocationControlCallbacks& controlCallbacks)
|
||||
{ mControlCallbacks = controlCallbacks; }
|
||||
void setAfwControlId(uint32_t id) { mAfwControlId = id; }
|
||||
uint32_t getAfwControlId() { return mAfwControlId; }
|
||||
virtual bool isInSession() { return !mTimeBasedTrackingSessions.empty(); }
|
||||
void initDefaultAgps();
|
||||
bool initEngHubProxy();
|
||||
void initCDFWService();
|
||||
void odcpiTimerExpireEvent();
|
||||
|
||||
/* ==== REPORTS ======================================================================== */
|
||||
/* ======== EVENTS ====(Called from QMI/EngineHub Thread)===================================== */
|
||||
virtual void reportPositionEvent(const UlpLocation& ulpLocation,
|
||||
const GpsLocationExtended& locationExtended,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask techMask,
|
||||
GnssDataNotification* pDataNotify = nullptr,
|
||||
int msInWeek = -1);
|
||||
virtual void reportEnginePositionsEvent(unsigned int count,
|
||||
EngineLocationInfo* locationArr);
|
||||
|
||||
virtual void reportSvEvent(const GnssSvNotification& svNotify,
|
||||
bool fromEngineHub=false);
|
||||
virtual void reportNmeaEvent(const char* nmea, size_t length);
|
||||
virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek);
|
||||
virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data,
|
||||
const LocInEmergency emergencyState);
|
||||
virtual void reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements,
|
||||
int msInWeek);
|
||||
virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
|
||||
virtual void reportSvEphemerisEvent(GnssSvEphemerisReport & svEphemeris);
|
||||
virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
|
||||
virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
|
||||
virtual void reportGnssConfigEvent(uint32_t sessionId, const GnssConfig& gnssConfig);
|
||||
virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
|
||||
virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo);
|
||||
|
||||
virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask);
|
||||
virtual bool releaseATL(int connHandle);
|
||||
virtual bool requestOdcpiEvent(OdcpiRequestInfo& request);
|
||||
virtual bool reportDeleteAidingDataEvent(GnssAidingData& aidingData);
|
||||
virtual bool reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& ionoModel);
|
||||
virtual bool reportGnssAdditionalSystemInfoEvent(
|
||||
GnssAdditionalSystemInfo& additionalSystemInfo);
|
||||
virtual void reportNfwNotificationEvent(GnssNfwNotification& notification);
|
||||
virtual void reportLatencyInfoEvent(const GnssLatencyInfo& gnssLatencyInfo);
|
||||
virtual bool reportQwesCapabilities
|
||||
(
|
||||
const std::unordered_map<LocationQwesFeatureType, bool> &featureMap
|
||||
);
|
||||
void reportPdnTypeFromWds(int pdnType, AGpsExtType agpsType, std::string apnName,
|
||||
AGpsBearerType bearerType);
|
||||
|
||||
/* ======== UTILITIES ================================================================= */
|
||||
bool needReportForGnssClient(const UlpLocation& ulpLocation,
|
||||
enum loc_sess_status status, LocPosTechMask techMask);
|
||||
bool needReportForFlpClient(enum loc_sess_status status, LocPosTechMask techMask);
|
||||
bool needToGenerateNmeaReport(const uint32_t &gpsTimeOfWeekMs,
|
||||
const struct timespec32_t &apTimeStamp);
|
||||
void reportPosition(const UlpLocation &ulpLocation,
|
||||
const GpsLocationExtended &locationExtended,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask techMask);
|
||||
void reportEnginePositions(unsigned int count,
|
||||
const EngineLocationInfo* locationArr);
|
||||
void reportSv(GnssSvNotification& svNotify);
|
||||
void reportNmea(const char* nmea, size_t length);
|
||||
void reportData(GnssDataNotification& dataNotify);
|
||||
bool requestNiNotify(const GnssNiNotification& notify, const void* data,
|
||||
const bool bInformNiAccept);
|
||||
void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements);
|
||||
void reportGnssSvIdConfig(const GnssSvIdConfig& config);
|
||||
void reportGnssSvTypeConfig(const GnssSvTypeConfig& config);
|
||||
void reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig);
|
||||
void requestOdcpi(const OdcpiRequestInfo& request);
|
||||
void invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot);
|
||||
void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb);
|
||||
void reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo);
|
||||
inline void reportNfwNotification(const GnssNfwNotification& notification) {
|
||||
if (NULL != mNfwCb) {
|
||||
mNfwCb(notification);
|
||||
}
|
||||
}
|
||||
inline bool getE911State(void) {
|
||||
if (NULL != mIsE911Session) {
|
||||
return mIsE911Session();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void updateSystemPowerState(PowerStateType systemPowerState);
|
||||
void reportSvPolynomial(const GnssSvPolynomial &svPolynomial);
|
||||
|
||||
|
||||
std::vector<double> parseDoublesString(char* dString);
|
||||
void reportGnssAntennaInformation(const antennaInfoCb antennaInfoCallback);
|
||||
|
||||
/*======== GNSSDEBUG ================================================================*/
|
||||
bool getDebugReport(GnssDebugReport& report);
|
||||
/* get AGC information from system status and fill it */
|
||||
void getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek);
|
||||
/* get Data information from system status and fill it */
|
||||
void getDataInformation(GnssDataNotification& data, int msInWeek);
|
||||
|
||||
/*==== SYSTEM STATUS ================================================================*/
|
||||
inline SystemStatus* getSystemStatus(void) { return mSystemStatus; }
|
||||
std::string& getServerUrl(void) { return mServerUrl; }
|
||||
std::string& getMoServerUrl(void) { return mMoServerUrl; }
|
||||
|
||||
/*==== CONVERSION ===================================================================*/
|
||||
static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion);
|
||||
static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl);
|
||||
static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices);
|
||||
static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask);
|
||||
static uint32_t convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask);
|
||||
static uint32_t convertAGloProt(const GnssConfigAGlonassPositionProtocolMask);
|
||||
static uint32_t convertSuplMode(const GnssConfigSuplModeMask suplModeMask);
|
||||
static void convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out,
|
||||
const GnssSvType& in_constellation,
|
||||
const SystemStatusReports& in);
|
||||
static bool convertToGnssSvIdConfig(
|
||||
const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config);
|
||||
static void convertFromGnssSvIdConfig(
|
||||
const GnssSvIdConfig& svConfig, std::vector<GnssSvIdSource>& blacklistedSvIds);
|
||||
static void convertGnssSvIdMaskToList(
|
||||
uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds,
|
||||
GnssSvId initialSvId, GnssSvType svType);
|
||||
static void computeVRPBasedLla(const UlpLocation& loc, GpsLocationExtended& locExt,
|
||||
const LeverArmConfigInfo& leverArmConfigInfo);
|
||||
|
||||
void injectLocationCommand(double latitude, double longitude, float accuracy);
|
||||
void injectLocationExtCommand(const GnssLocationInfoNotification &locationInfo);
|
||||
|
||||
void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
|
||||
void blockCPICommand(double latitude, double longitude, float accuracy,
|
||||
int blockDurationMsec, double latLonDiffThreshold);
|
||||
|
||||
/* ==== MISCELLANEOUS ================================================================== */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
void getPowerStateChangesCommand(std::function<void(bool)> powerStateCb);
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
void reportPowerStateIfChanged();
|
||||
void savePowerStateCallback(std::function<void(bool)> powerStateCb){
|
||||
mPowerStateCb = powerStateCb; }
|
||||
bool getPowerState() { return mPowerOn; }
|
||||
inline PowerStateType getSystemPowerState() { return mSystemPowerState; }
|
||||
|
||||
void setAllowFlpNetworkFixes(uint32_t allow) { mAllowFlpNetworkFixes = allow; }
|
||||
uint32_t getAllowFlpNetworkFixes() { return mAllowFlpNetworkFixes; }
|
||||
void setSuplHostServer(const char* server, int port, LocServerType type);
|
||||
void notifyClientOfCachedLocationSystemInfo(LocationAPI* client,
|
||||
const LocationCallbacks& callbacks);
|
||||
LocationCapabilitiesMask getCapabilities();
|
||||
void updateSystemPowerStateCommand(PowerStateType systemPowerState);
|
||||
|
||||
/*==== DGnss Usable Report Flag ====================================================*/
|
||||
inline void setDGnssUsableFLag(bool dGnssNeedReport) { mDGnssNeedReport = dGnssNeedReport;}
|
||||
inline bool isNMEAPrintEnabled() {
|
||||
return ((mContext != NULL) && (0 != mContext->mGps_conf.ENABLE_NMEA_PRINT));
|
||||
}
|
||||
|
||||
/*==== DGnss Ntrip Source ==========================================================*/
|
||||
void updateNTRIPGGAConsentCommand(bool consentAccepted) { mSendNmeaConsent = consentAccepted; }
|
||||
void enablePPENtripStreamCommand(const GnssNtripConnectionParams& params, bool enableRTKEngine);
|
||||
void disablePPENtripStreamCommand();
|
||||
void handleEnablePPENtrip(const GnssNtripConnectionParams& params);
|
||||
void handleDisablePPENtrip();
|
||||
void reportGGAToNtrip(const char* nmea);
|
||||
inline bool isDgnssNmeaRequired() { return mSendNmeaConsent &&
|
||||
mStartDgnssNtripParams.ntripParams.requiresNmeaLocation;}
|
||||
};
|
||||
|
||||
#endif //GNSS_ADAPTER_H
|
||||
32
gps/gnss/Makefile.am
Normal file
32
gps/gnss/Makefile.am
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
AM_CFLAGS = \
|
||||
$(LOCPLA_CFLAGS) \
|
||||
$(LOCHAL_CFLAGS) \
|
||||
$(GPSUTILS_CFLAGS) \
|
||||
$(LOCCORE_CFLAGS) \
|
||||
-I./ \
|
||||
-I../utils \
|
||||
-I$(WORKSPACE)/hardware/qcom/gps/core/data-items \
|
||||
-I../location \
|
||||
-std=c++1y
|
||||
|
||||
libgnss_la_SOURCES = \
|
||||
location_gnss.cpp \
|
||||
GnssAdapter.cpp \
|
||||
XtraSystemStatusObserver.cpp \
|
||||
Agps.cpp \
|
||||
NativeAgpsHandler.cpp
|
||||
|
||||
if USE_GLIB
|
||||
libgnss_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
|
||||
libgnss_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -avoid-version
|
||||
libgnss_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
|
||||
else
|
||||
libgnss_la_CFLAGS = $(AM_CFLAGS)
|
||||
libgnss_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0
|
||||
libgnss_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
|
||||
endif
|
||||
|
||||
libgnss_la_LIBADD = -lstdc++ -ldl $(GPSUTILS_LIBS) $(LOCCORE_LIBS)
|
||||
|
||||
#Create and Install libraries
|
||||
lib_LTLIBRARIES = libgnss.la
|
||||
127
gps/gnss/NativeAgpsHandler.cpp
Normal file
127
gps/gnss/NativeAgpsHandler.cpp
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/* Copyright (c) 2020, 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#define LOG_TAG "LocSvc_NativeAgpsHandler"
|
||||
|
||||
#include <LocAdapterBase.h>
|
||||
#include <SystemStatus.h>
|
||||
#include <DataItemId.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <DataItemConcreteTypesBase.h>
|
||||
#include <loc_log.h>
|
||||
#include <NativeAgpsHandler.h>
|
||||
#include <GnssAdapter.h>
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
// IDataItemObserver overrides
|
||||
void NativeAgpsHandler::getName(string& name) {
|
||||
name = "NativeAgpsHandler";
|
||||
}
|
||||
|
||||
void NativeAgpsHandler::notify(const list<IDataItemCore*>& dlist) {
|
||||
for (auto each : dlist) {
|
||||
switch (each->getId()) {
|
||||
case NETWORKINFO_DATA_ITEM_ID: {
|
||||
NetworkInfoDataItemBase* networkInfo =
|
||||
static_cast<NetworkInfoDataItemBase*>(each);
|
||||
uint64_t mobileBit = (uint64_t )1 << loc_core::TYPE_MOBILE;
|
||||
uint64_t allTypes = networkInfo->mAllTypes;
|
||||
mConnected = ((networkInfo->mAllTypes & mobileBit) == mobileBit);
|
||||
/**
|
||||
* mApn Telephony preferred Access Point Name to use for
|
||||
* carrier data connection when connected to a cellular network.
|
||||
* Empty string, otherwise.
|
||||
*/
|
||||
mApn = networkInfo->mApn;
|
||||
LOC_LOGd("updated mConnected:%d, mApn: %s", mConnected, mApn.c_str());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NativeAgpsHandler* NativeAgpsHandler::sLocalHandle = nullptr;
|
||||
NativeAgpsHandler::NativeAgpsHandler(IOsObserver* sysStatObs, GnssAdapter& adapter) :
|
||||
mSystemStatusObsrvr(sysStatObs), mConnected(false), mAdapter(adapter) {
|
||||
sLocalHandle = this;
|
||||
list<DataItemId> subItemIdList = {NETWORKINFO_DATA_ITEM_ID};
|
||||
mSystemStatusObsrvr->subscribe(subItemIdList, this);
|
||||
}
|
||||
|
||||
NativeAgpsHandler::~NativeAgpsHandler() {
|
||||
if (nullptr != mSystemStatusObsrvr) {
|
||||
LOC_LOGd("Unsubscribe for network info.");
|
||||
list<DataItemId> subItemIdList = {NETWORKINFO_DATA_ITEM_ID};
|
||||
mSystemStatusObsrvr->unsubscribe(subItemIdList, this);
|
||||
}
|
||||
sLocalHandle = nullptr;
|
||||
mSystemStatusObsrvr = nullptr;
|
||||
}
|
||||
|
||||
|
||||
AgpsCbInfo NativeAgpsHandler::getAgpsCbInfo() {
|
||||
AgpsCbInfo nativeCbInfo = {};
|
||||
nativeCbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb;
|
||||
nativeCbInfo.atlType = AGPS_ATL_TYPE_WWAN;
|
||||
return nativeCbInfo;
|
||||
}
|
||||
|
||||
void NativeAgpsHandler::agnssStatusIpV4Cb(AGnssExtStatusIpV4 statusInfo) {
|
||||
if (nullptr != sLocalHandle) {
|
||||
sLocalHandle->processATLRequestRelease(statusInfo);
|
||||
} else {
|
||||
LOC_LOGe("sLocalHandle is null");
|
||||
}
|
||||
}
|
||||
|
||||
void NativeAgpsHandler::processATLRequestRelease(AGnssExtStatusIpV4 statusInfo) {
|
||||
if (LOC_AGPS_TYPE_WWAN_ANY == statusInfo.type) {
|
||||
LOC_LOGd("status.type = %d status.apnTypeMask = 0x%X", statusInfo.type,
|
||||
statusInfo.apnTypeMask);
|
||||
switch (statusInfo.status) {
|
||||
case LOC_GPS_REQUEST_AGPS_DATA_CONN:
|
||||
if (mConnected) {
|
||||
mAdapter.dataConnOpenCommand(LOC_AGPS_TYPE_WWAN_ANY, mApn.c_str(), mApn.size(),
|
||||
AGPS_APN_BEARER_IPV4);
|
||||
} else {
|
||||
mAdapter.dataConnFailedCommand(LOC_AGPS_TYPE_WWAN_ANY);
|
||||
}
|
||||
break;
|
||||
case LOC_GPS_RELEASE_AGPS_DATA_CONN:
|
||||
mAdapter.dataConnClosedCommand(LOC_AGPS_TYPE_WWAN_ANY);
|
||||
break;
|
||||
default:
|
||||
LOC_LOGe("Invalid Request: %d", statusInfo.status);
|
||||
}
|
||||
} else {
|
||||
LOC_LOGe("mAgpsManger is null or invalid request type!");
|
||||
}
|
||||
}
|
||||
64
gps/gnss/NativeAgpsHandler.h
Normal file
64
gps/gnss/NativeAgpsHandler.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/* Copyright (c) 2020, 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef NATIVEAGPSHANDLER_H
|
||||
#define NATIVEAGPSHANDLER_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string.h>
|
||||
#include <gps_extended_c.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <IOsObserver.h>
|
||||
|
||||
using namespace std;
|
||||
using loc_core::IOsObserver;
|
||||
using loc_core::IDataItemObserver;
|
||||
using loc_core::IDataItemCore;
|
||||
|
||||
class GnssAdapter;
|
||||
|
||||
class NativeAgpsHandler : public IDataItemObserver {
|
||||
public:
|
||||
NativeAgpsHandler(IOsObserver* sysStatObs, GnssAdapter& adapter);
|
||||
~NativeAgpsHandler();
|
||||
AgpsCbInfo getAgpsCbInfo();
|
||||
// IDataItemObserver overrides
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
inline virtual void getName(string& name);
|
||||
private:
|
||||
static NativeAgpsHandler* sLocalHandle;
|
||||
static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 statusInfo);
|
||||
void processATLRequestRelease(AGnssExtStatusIpV4 statusInfo);
|
||||
IOsObserver* mSystemStatusObsrvr;
|
||||
bool mConnected;
|
||||
string mApn;
|
||||
GnssAdapter& mAdapter;
|
||||
};
|
||||
|
||||
#endif // NATIVEAGPSHANDLER_H
|
||||
384
gps/gnss/XtraSystemStatusObserver.cpp
Normal file
384
gps/gnss/XtraSystemStatusObserver.cpp
Normal file
|
|
@ -0,0 +1,384 @@
|
|||
/* Copyright (c) 2017-2020 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#define LOG_TAG "LocSvc_XtraSystemStatusObs"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <math.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <string>
|
||||
#include <loc_log.h>
|
||||
#include <loc_nmea.h>
|
||||
#include <SystemStatus.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <XtraSystemStatusObserver.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <DataItemId.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <DataItemConcreteTypesBase.h>
|
||||
|
||||
using namespace loc_util;
|
||||
using namespace loc_core;
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "LocSvc_XSSO"
|
||||
|
||||
class XtraIpcListener : public ILocIpcListener {
|
||||
IOsObserver* mSystemStatusObsrvr;
|
||||
const MsgTask* mMsgTask;
|
||||
XtraSystemStatusObserver& mXSSO;
|
||||
public:
|
||||
inline XtraIpcListener(IOsObserver* observer, const MsgTask* msgTask,
|
||||
XtraSystemStatusObserver& xsso) :
|
||||
mSystemStatusObsrvr(observer), mMsgTask(msgTask), mXSSO(xsso) {}
|
||||
virtual void onReceive(const char* data, uint32_t length,
|
||||
const LocIpcRecver* recver) override {
|
||||
#define STRNCMP(str, constStr) strncmp(str, constStr, sizeof(constStr)-1)
|
||||
if (!STRNCMP(data, "ping")) {
|
||||
LOC_LOGd("ping received");
|
||||
#ifdef USE_GLIB
|
||||
} else if (!STRNCMP(data, "connectBackhaul")) {
|
||||
char clientName[30] = {0};
|
||||
sscanf(data, "%*s %29s", clientName);
|
||||
mSystemStatusObsrvr->connectBackhaul(string(clientName));
|
||||
} else if (!STRNCMP(data, "disconnectBackhaul")) {
|
||||
char clientName[30] = {0};
|
||||
sscanf(data, "%*s %29s", clientName);
|
||||
mSystemStatusObsrvr->disconnectBackhaul(string(clientName));
|
||||
#endif
|
||||
} else if (!STRNCMP(data, "requestStatus")) {
|
||||
int32_t xtraStatusUpdated = 0;
|
||||
sscanf(data, "%*s %d", &xtraStatusUpdated);
|
||||
|
||||
struct HandleStatusRequestMsg : public LocMsg {
|
||||
XtraSystemStatusObserver& mXSSO;
|
||||
int32_t mXtraStatusUpdated;
|
||||
inline HandleStatusRequestMsg(XtraSystemStatusObserver& xsso,
|
||||
int32_t xtraStatusUpdated) :
|
||||
mXSSO(xsso), mXtraStatusUpdated(xtraStatusUpdated) {}
|
||||
inline void proc() const override {
|
||||
mXSSO.onStatusRequested(mXtraStatusUpdated);
|
||||
/* SSR for DGnss Ntrip Source*/
|
||||
mXSSO.restartDgnssSource();
|
||||
}
|
||||
};
|
||||
mMsgTask->sendMsg(new HandleStatusRequestMsg(mXSSO, xtraStatusUpdated));
|
||||
} else {
|
||||
LOC_LOGw("unknown event: %s", data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
XtraSystemStatusObserver::XtraSystemStatusObserver(IOsObserver* sysStatObs,
|
||||
const MsgTask* msgTask) :
|
||||
mSystemStatusObsrvr(sysStatObs), mMsgTask(msgTask),
|
||||
mGpsLock(-1), mConnections(~0), mXtraThrottle(true),
|
||||
mReqStatusReceived(false),
|
||||
mIsConnectivityStatusKnown(false),
|
||||
mSender(LocIpc::getLocIpcLocalSender(LOC_IPC_XTRA)),
|
||||
mDelayLocTimer(*mSender) {
|
||||
subscribe(true);
|
||||
auto recver = LocIpc::getLocIpcLocalRecver(
|
||||
make_shared<XtraIpcListener>(sysStatObs, msgTask, *this),
|
||||
LOC_IPC_HAL);
|
||||
mIpc.startNonBlockingListening(recver);
|
||||
mDelayLocTimer.start(100 /*.1 sec*/, false);
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateLockStatus(GnssConfigGpsLock lock) {
|
||||
// mask NI(NFW bit) since from XTRA's standpoint GPS is enabled if
|
||||
// MO(AFW bit) is enabled and disabled when MO is disabled
|
||||
mGpsLock = lock & ~GNSS_CONFIG_GPS_LOCK_NI;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "gpslock";
|
||||
ss << " " << mGpsLock;
|
||||
string s = ss.str();
|
||||
return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateConnections(uint64_t allConnections,
|
||||
NetworkInfoType* networkHandleInfo) {
|
||||
mIsConnectivityStatusKnown = true;
|
||||
mConnections = allConnections;
|
||||
|
||||
LOC_LOGd("updateConnections mConnections:%" PRIx64, mConnections);
|
||||
for (uint8_t i = 0; i < MAX_NETWORK_HANDLES; ++i) {
|
||||
mNetworkHandle[i] = networkHandleInfo[i];
|
||||
LOC_LOGd("updateConnections [%d] networkHandle:%" PRIx64 " networkType:%u",
|
||||
i, mNetworkHandle[i].networkHandle, mNetworkHandle[i].networkType);
|
||||
}
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "connection" << endl << mConnections << endl
|
||||
<< mNetworkHandle[0].toString() << endl
|
||||
<< mNetworkHandle[1].toString() << endl
|
||||
<< mNetworkHandle[2].toString() << endl
|
||||
<< mNetworkHandle[3].toString() << endl
|
||||
<< mNetworkHandle[4].toString() << endl
|
||||
<< mNetworkHandle[5].toString() << endl
|
||||
<< mNetworkHandle[6].toString() << endl
|
||||
<< mNetworkHandle[7].toString() << endl
|
||||
<< mNetworkHandle[8].toString() << endl
|
||||
<< mNetworkHandle[MAX_NETWORK_HANDLES-1].toString();
|
||||
string s = ss.str();
|
||||
return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateTac(const string& tac) {
|
||||
mTac = tac;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "tac";
|
||||
ss << " " << tac.c_str();
|
||||
string s = ss.str();
|
||||
return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateMccMnc(const string& mccmnc) {
|
||||
mMccmnc = mccmnc;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "mncmcc";
|
||||
ss << " " << mccmnc.c_str();
|
||||
string s = ss.str();
|
||||
return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateXtraThrottle(const bool enabled) {
|
||||
mXtraThrottle = enabled;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "xtrathrottle";
|
||||
ss << " " << (enabled ? 1 : 0);
|
||||
string s = ss.str();
|
||||
return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) );
|
||||
}
|
||||
|
||||
inline bool XtraSystemStatusObserver::onStatusRequested(int32_t xtraStatusUpdated) {
|
||||
mReqStatusReceived = true;
|
||||
|
||||
if (xtraStatusUpdated) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
|
||||
ss << "respondStatus" << endl;
|
||||
(mGpsLock == -1 ? ss : ss << mGpsLock) << endl;
|
||||
(mConnections == (uint64_t)~0 ? ss : ss << mConnections) << endl
|
||||
<< mNetworkHandle[0].toString() << endl
|
||||
<< mNetworkHandle[1].toString() << endl
|
||||
<< mNetworkHandle[2].toString() << endl
|
||||
<< mNetworkHandle[3].toString() << endl
|
||||
<< mNetworkHandle[4].toString() << endl
|
||||
<< mNetworkHandle[5].toString() << endl
|
||||
<< mNetworkHandle[6].toString() << endl
|
||||
<< mNetworkHandle[7].toString() << endl
|
||||
<< mNetworkHandle[8].toString() << endl
|
||||
<< mNetworkHandle[MAX_NETWORK_HANDLES-1].toString() << endl
|
||||
<< mTac << endl << mMccmnc << endl << mIsConnectivityStatusKnown;
|
||||
|
||||
string s = ss.str();
|
||||
return ( LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size()) );
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::startDgnssSource(const StartDgnssNtripParams& params) {
|
||||
stringstream ss;
|
||||
const GnssNtripConnectionParams* ntripParams = &(params.ntripParams);
|
||||
|
||||
ss << "startDgnssSource" << endl;
|
||||
ss << ntripParams->useSSL << endl;
|
||||
ss << ntripParams->hostNameOrIp.data() << endl;
|
||||
ss << ntripParams->port << endl;
|
||||
ss << ntripParams->mountPoint.data() << endl;
|
||||
ss << ntripParams->username.data() << endl;
|
||||
ss << ntripParams->password.data() << endl;
|
||||
if (ntripParams->requiresNmeaLocation && !params.nmea.empty()) {
|
||||
ss << params.nmea.data() << endl;
|
||||
}
|
||||
string s = ss.str();
|
||||
|
||||
LOC_LOGd("%s", s.data());
|
||||
LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size());
|
||||
// make a local copy of the string for SSR
|
||||
mNtripParamsString.assign(std::move(s));
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::restartDgnssSource() {
|
||||
if (!mNtripParamsString.empty()) {
|
||||
LocIpc::send(*mSender,
|
||||
(const uint8_t*)mNtripParamsString.data(), mNtripParamsString.size());
|
||||
LOC_LOGv("Xtra SSR %s", mNtripParamsString.data());
|
||||
}
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::stopDgnssSource() {
|
||||
LOC_LOGv();
|
||||
mNtripParamsString.clear();
|
||||
|
||||
const char s[] = "stopDgnssSource";
|
||||
LocIpc::send(*mSender, (const uint8_t*)s, strlen(s));
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::updateNmeaToDgnssServer(const string& nmea)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "updateDgnssServerNmea" << endl;
|
||||
ss << nmea.data() << endl;
|
||||
|
||||
string s = ss.str();
|
||||
LOC_LOGd("%s", s.data());
|
||||
LocIpc::send(*mSender, (const uint8_t*)s.data(), s.size());
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::subscribe(bool yes)
|
||||
{
|
||||
// Subscription data list
|
||||
list<DataItemId> subItemIdList;
|
||||
subItemIdList.push_back(NETWORKINFO_DATA_ITEM_ID);
|
||||
subItemIdList.push_back(MCCMNC_DATA_ITEM_ID);
|
||||
|
||||
if (yes) {
|
||||
mSystemStatusObsrvr->subscribe(subItemIdList, this);
|
||||
|
||||
list<DataItemId> reqItemIdList;
|
||||
reqItemIdList.push_back(TAC_DATA_ITEM_ID);
|
||||
|
||||
mSystemStatusObsrvr->requestData(reqItemIdList, this);
|
||||
|
||||
} else {
|
||||
mSystemStatusObsrvr->unsubscribe(subItemIdList, this);
|
||||
}
|
||||
}
|
||||
|
||||
// IDataItemObserver overrides
|
||||
void XtraSystemStatusObserver::getName(string& name)
|
||||
{
|
||||
name = "XtraSystemStatusObserver";
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
|
||||
{
|
||||
struct HandleOsObserverUpdateMsg : public LocMsg {
|
||||
XtraSystemStatusObserver* mXtraSysStatObj;
|
||||
list <IDataItemCore*> mDataItemList;
|
||||
|
||||
inline HandleOsObserverUpdateMsg(XtraSystemStatusObserver* xtraSysStatObs,
|
||||
const list<IDataItemCore*>& dataItemList) :
|
||||
mXtraSysStatObj(xtraSysStatObs) {
|
||||
for (auto eachItem : dataItemList) {
|
||||
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(
|
||||
eachItem->getId());
|
||||
if (NULL == dataitem) {
|
||||
break;
|
||||
}
|
||||
// Copy the contents of the data item
|
||||
dataitem->copy(eachItem);
|
||||
|
||||
mDataItemList.push_back(dataitem);
|
||||
}
|
||||
}
|
||||
|
||||
inline ~HandleOsObserverUpdateMsg() {
|
||||
for (auto itor = mDataItemList.begin(); itor != mDataItemList.end(); ++itor) {
|
||||
if (*itor != nullptr) {
|
||||
delete *itor;
|
||||
*itor = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void proc() const {
|
||||
for (auto each : mDataItemList) {
|
||||
switch (each->getId())
|
||||
{
|
||||
case NETWORKINFO_DATA_ITEM_ID:
|
||||
{
|
||||
NetworkInfoDataItemBase* networkInfo =
|
||||
static_cast<NetworkInfoDataItemBase*>(each);
|
||||
NetworkInfoType* networkHandleInfo =
|
||||
static_cast<NetworkInfoType*>(networkInfo->getNetworkHandle());
|
||||
mXtraSysStatObj->updateConnections(networkInfo->getAllTypes(),
|
||||
networkHandleInfo);
|
||||
}
|
||||
break;
|
||||
|
||||
case TAC_DATA_ITEM_ID:
|
||||
{
|
||||
TacDataItemBase* tac =
|
||||
static_cast<TacDataItemBase*>(each);
|
||||
mXtraSysStatObj->updateTac(tac->mValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case MCCMNC_DATA_ITEM_ID:
|
||||
{
|
||||
MccmncDataItemBase* mccmnc =
|
||||
static_cast<MccmncDataItemBase*>(each);
|
||||
mXtraSysStatObj->updateMccMnc(mccmnc->mValue);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mMsgTask->sendMsg(new (nothrow) HandleOsObserverUpdateMsg(this, dlist));
|
||||
}
|
||||
112
gps/gnss/XtraSystemStatusObserver.h
Normal file
112
gps/gnss/XtraSystemStatusObserver.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/* Copyright (c) 2017-2020 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef XTRA_SYSTEM_STATUS_OBS_H
|
||||
#define XTRA_SYSTEM_STATUS_OBS_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <MsgTask.h>
|
||||
#include <LocIpc.h>
|
||||
#include <LocTimer.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace loc_util;
|
||||
using loc_core::IOsObserver;
|
||||
using loc_core::IDataItemObserver;
|
||||
using loc_core::IDataItemCore;
|
||||
|
||||
struct StartDgnssNtripParams {
|
||||
GnssNtripConnectionParams ntripParams;
|
||||
string nmea;
|
||||
|
||||
void clear() {
|
||||
ntripParams.hostNameOrIp.clear();
|
||||
ntripParams.mountPoint.clear();
|
||||
ntripParams.username.clear();
|
||||
ntripParams.password.clear();
|
||||
ntripParams.port = 0;
|
||||
ntripParams.useSSL = false;
|
||||
ntripParams.requiresNmeaLocation = false;
|
||||
nmea.clear();
|
||||
}
|
||||
};
|
||||
|
||||
class XtraSystemStatusObserver : public IDataItemObserver {
|
||||
public :
|
||||
// constructor & destructor
|
||||
XtraSystemStatusObserver(IOsObserver* sysStatObs, const MsgTask* msgTask);
|
||||
inline virtual ~XtraSystemStatusObserver() {
|
||||
subscribe(false);
|
||||
mIpc.stopNonBlockingListening();
|
||||
}
|
||||
|
||||
// IDataItemObserver overrides
|
||||
inline virtual void getName(string& name);
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
|
||||
bool updateLockStatus(GnssConfigGpsLock lock);
|
||||
bool updateConnections(uint64_t allConnections,
|
||||
loc_core::NetworkInfoType* networkHandleInfo);
|
||||
bool updateTac(const string& tac);
|
||||
bool updateMccMnc(const string& mccmnc);
|
||||
bool updateXtraThrottle(const bool enabled);
|
||||
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||
void subscribe(bool yes);
|
||||
bool onStatusRequested(int32_t xtraStatusUpdated);
|
||||
void startDgnssSource(const StartDgnssNtripParams& params);
|
||||
void restartDgnssSource();
|
||||
void stopDgnssSource();
|
||||
void updateNmeaToDgnssServer(const string& nmea);
|
||||
|
||||
private:
|
||||
IOsObserver* mSystemStatusObsrvr;
|
||||
const MsgTask* mMsgTask;
|
||||
GnssConfigGpsLock mGpsLock;
|
||||
LocIpc mIpc;
|
||||
uint64_t mConnections;
|
||||
loc_core::NetworkInfoType mNetworkHandle[MAX_NETWORK_HANDLES];
|
||||
string mTac;
|
||||
string mMccmnc;
|
||||
bool mXtraThrottle;
|
||||
bool mReqStatusReceived;
|
||||
bool mIsConnectivityStatusKnown;
|
||||
shared_ptr<LocIpcSender> mSender;
|
||||
string mNtripParamsString;
|
||||
|
||||
class DelayLocTimer : public LocTimer {
|
||||
LocIpcSender& mSender;
|
||||
public:
|
||||
DelayLocTimer(LocIpcSender& sender) : mSender(sender) {}
|
||||
void timeOutCallback() override {
|
||||
LocIpc::send(mSender, (const uint8_t*)"halinit", sizeof("halinit"));
|
||||
}
|
||||
} mDelayLocTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
593
gps/gnss/location_gnss.cpp
Normal file
593
gps/gnss/location_gnss.cpp
Normal file
|
|
@ -0,0 +1,593 @@
|
|||
/* Copyright (c) 2017-2020, 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
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "GnssAdapter.h"
|
||||
#include "location_interface.h"
|
||||
|
||||
static GnssAdapter* gGnssAdapter = NULL;
|
||||
|
||||
static void initialize();
|
||||
static void deinitialize();
|
||||
|
||||
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks);
|
||||
static void removeClient(LocationAPI* client, removeClientCompleteCallback rmClientCb);
|
||||
static void requestCapabilities(LocationAPI* client);
|
||||
|
||||
static uint32_t startTracking(LocationAPI* client, TrackingOptions&);
|
||||
static void updateTrackingOptions(LocationAPI* client, uint32_t id, TrackingOptions&);
|
||||
static void stopTracking(LocationAPI* client, uint32_t id);
|
||||
|
||||
static void gnssNiResponse(LocationAPI* client, uint32_t id, GnssNiResponse response);
|
||||
static uint32_t gnssDeleteAidingData(GnssAidingData& data);
|
||||
static void gnssUpdateXtraThrottle(const bool enabled);
|
||||
|
||||
static void setControlCallbacks(LocationControlCallbacks& controlCallbacks);
|
||||
static uint32_t enable(LocationTechnologyType techType);
|
||||
static void disable(uint32_t id);
|
||||
static uint32_t* gnssUpdateConfig(const GnssConfig& config);
|
||||
static uint32_t* gnssGetConfig(GnssConfigFlagsMask mask);
|
||||
|
||||
static void gnssUpdateSvTypeConfig(GnssSvTypeConfig& config);
|
||||
static void gnssGetSvTypeConfig(GnssSvTypeConfigCallback& callback);
|
||||
static void gnssResetSvTypeConfig();
|
||||
|
||||
static void injectLocation(double latitude, double longitude, float accuracy);
|
||||
static void injectLocationExt(const GnssLocationInfoNotification &locationInfo);
|
||||
static void injectTime(int64_t time, int64_t timeReference, int32_t uncertainty);
|
||||
|
||||
static void agpsInit(const AgpsCbInfo& cbInfo);
|
||||
static void agpsDataConnOpen(AGpsExtType agpsType, const char* apnName, int apnLen, int ipType);
|
||||
static void agpsDataConnClosed(AGpsExtType agpsType);
|
||||
static void agpsDataConnFailed(AGpsExtType agpsType);
|
||||
static void getDebugReport(GnssDebugReport& report);
|
||||
static void updateConnectionStatus(bool connected, int8_t type, bool roaming,
|
||||
NetworkHandle networkHandle, string& apn);
|
||||
static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb);
|
||||
static void enableNfwLocationAccess(bool enable);
|
||||
static void nfwInit(const NfwCbInfo& cbInfo);
|
||||
static void getPowerStateChanges(std::function<void(bool)> powerStateCb);
|
||||
|
||||
static void odcpiInit(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
|
||||
static void odcpiInject(const Location& location);
|
||||
|
||||
static void blockCPI(double latitude, double longitude, float accuracy,
|
||||
int blockDurationMsec, double latLonDiffThreshold);
|
||||
static void updateBatteryStatus(bool charging);
|
||||
static void updateSystemPowerState(PowerStateType systemPowerState);
|
||||
static uint32_t setConstrainedTunc (bool enable, float tuncConstraint,
|
||||
uint32_t energyBudget);
|
||||
static uint32_t setPositionAssistedClockEstimator(bool enable);
|
||||
static uint32_t gnssUpdateSvConfig(const GnssSvTypeConfig& constellationEnablementConfig,
|
||||
const GnssSvIdConfig& blacklistSvConfig);
|
||||
static uint32_t gnssResetSvConfig();
|
||||
static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo);
|
||||
static uint32_t configRobustLocation(bool enable, bool enableForE911);
|
||||
static uint32_t configMinGpsWeek(uint16_t minGpsWeek);
|
||||
static uint32_t configDeadReckoningEngineParams(const DeadReckoningEngineConfig& dreConfig);
|
||||
static uint32_t gnssUpdateSecondaryBandConfig(const GnssSvTypeConfig& secondaryBandConfig);
|
||||
static uint32_t gnssGetSecondaryBandConfig();
|
||||
static void resetNetworkInfo();
|
||||
|
||||
static void updateNTRIPGGAConsent(bool consentAccepted);
|
||||
static void enablePPENtripStream(const GnssNtripConnectionParams& params, bool enableRTKEngine);
|
||||
static void disablePPENtripStream();
|
||||
|
||||
static bool measCorrInit(const measCorrSetCapabilitiesCb setCapabilitiesCb);
|
||||
static bool measCorrSetCorrections(const GnssMeasurementCorrections gnssMeasCorr);
|
||||
static void measCorrClose();
|
||||
static uint32_t antennaInfoInit(const antennaInfoCb antennaInfoCallback);
|
||||
static void antennaInfoClose();
|
||||
static uint32_t configEngineRunState(PositioningEngineMask engType, LocEngineRunState engState);
|
||||
|
||||
static const GnssInterface gGnssInterface = {
|
||||
sizeof(GnssInterface),
|
||||
initialize,
|
||||
deinitialize,
|
||||
addClient,
|
||||
removeClient,
|
||||
requestCapabilities,
|
||||
startTracking,
|
||||
updateTrackingOptions,
|
||||
stopTracking,
|
||||
gnssNiResponse,
|
||||
setControlCallbacks,
|
||||
enable,
|
||||
disable,
|
||||
gnssUpdateConfig,
|
||||
gnssGetConfig,
|
||||
gnssUpdateSvTypeConfig,
|
||||
gnssGetSvTypeConfig,
|
||||
gnssResetSvTypeConfig,
|
||||
gnssDeleteAidingData,
|
||||
gnssUpdateXtraThrottle,
|
||||
injectLocation,
|
||||
injectTime,
|
||||
agpsInit,
|
||||
agpsDataConnOpen,
|
||||
agpsDataConnClosed,
|
||||
agpsDataConnFailed,
|
||||
getDebugReport,
|
||||
updateConnectionStatus,
|
||||
odcpiInit,
|
||||
odcpiInject,
|
||||
blockCPI,
|
||||
getGnssEnergyConsumed,
|
||||
enableNfwLocationAccess,
|
||||
nfwInit,
|
||||
getPowerStateChanges,
|
||||
injectLocationExt,
|
||||
updateBatteryStatus,
|
||||
updateSystemPowerState,
|
||||
setConstrainedTunc,
|
||||
setPositionAssistedClockEstimator,
|
||||
gnssUpdateSvConfig,
|
||||
configLeverArm,
|
||||
measCorrInit,
|
||||
measCorrSetCorrections,
|
||||
measCorrClose,
|
||||
antennaInfoInit,
|
||||
antennaInfoClose,
|
||||
configRobustLocation,
|
||||
configMinGpsWeek,
|
||||
configDeadReckoningEngineParams,
|
||||
updateNTRIPGGAConsent,
|
||||
enablePPENtripStream,
|
||||
disablePPENtripStream,
|
||||
gnssUpdateSecondaryBandConfig,
|
||||
gnssGetSecondaryBandConfig,
|
||||
resetNetworkInfo,
|
||||
configEngineRunState
|
||||
};
|
||||
|
||||
#ifndef DEBUG_X86
|
||||
extern "C" const GnssInterface* getGnssInterface()
|
||||
#else
|
||||
const GnssInterface* getGnssInterface()
|
||||
#endif // DEBUG_X86
|
||||
{
|
||||
gGnssInterface.initialize();
|
||||
return &gGnssInterface;
|
||||
}
|
||||
|
||||
static void initialize()
|
||||
{
|
||||
if (NULL == gGnssAdapter) {
|
||||
gGnssAdapter = new GnssAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
static void deinitialize()
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
delete gGnssAdapter;
|
||||
gGnssAdapter = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->addClientCommand(client, callbacks);
|
||||
}
|
||||
}
|
||||
|
||||
static void removeClient(LocationAPI* client, removeClientCompleteCallback rmClientCb)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->removeClientCommand(client, rmClientCb);
|
||||
}
|
||||
}
|
||||
|
||||
static void requestCapabilities(LocationAPI* client)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->requestCapabilitiesCommand(client);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t startTracking(
|
||||
LocationAPI* client, TrackingOptions& trackingOptions)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->startTrackingCommand(client, trackingOptions);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void updateTrackingOptions(
|
||||
LocationAPI* client, uint32_t id, TrackingOptions& trackingOptions)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->updateTrackingOptionsCommand(
|
||||
client, id, trackingOptions);
|
||||
}
|
||||
}
|
||||
|
||||
static void stopTracking(LocationAPI* client, uint32_t id)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->stopTrackingCommand(client, id);
|
||||
}
|
||||
}
|
||||
|
||||
static void gnssNiResponse(LocationAPI* client, uint32_t id, GnssNiResponse response)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->gnssNiResponseCommand(client, id, response);
|
||||
}
|
||||
}
|
||||
|
||||
static void setControlCallbacks(LocationControlCallbacks& controlCallbacks)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->setControlCallbacksCommand(controlCallbacks);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t enable(LocationTechnologyType techType)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->enableCommand(techType);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void disable(uint32_t id)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->disableCommand(id);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t* gnssUpdateConfig(const GnssConfig& config)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->gnssUpdateConfigCommand(config);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t* gnssGetConfig(GnssConfigFlagsMask mask)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->gnssGetConfigCommand(mask);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void gnssUpdateSvTypeConfig(GnssSvTypeConfig& config)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->gnssUpdateSvTypeConfigCommand(config);
|
||||
}
|
||||
}
|
||||
|
||||
static void gnssGetSvTypeConfig(GnssSvTypeConfigCallback& callback)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->gnssGetSvTypeConfigCommand(callback);
|
||||
}
|
||||
}
|
||||
|
||||
static void gnssResetSvTypeConfig()
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->gnssResetSvTypeConfigCommand();
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t gnssDeleteAidingData(GnssAidingData& data)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->gnssDeleteAidingDataCommand(data);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void gnssUpdateXtraThrottle(const bool enabled)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->gnssUpdateXtraThrottleCommand(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
static void injectLocation(double latitude, double longitude, float accuracy)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->injectLocationCommand(latitude, longitude, accuracy);
|
||||
}
|
||||
}
|
||||
|
||||
static void injectTime(int64_t time, int64_t timeReference, int32_t uncertainty)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->injectTimeCommand(time, timeReference, uncertainty);
|
||||
}
|
||||
}
|
||||
|
||||
static void agpsInit(const AgpsCbInfo& cbInfo) {
|
||||
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->initAgpsCommand(cbInfo);
|
||||
}
|
||||
}
|
||||
static void agpsDataConnOpen(
|
||||
AGpsExtType agpsType, const char* apnName, int apnLen, int ipType) {
|
||||
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->dataConnOpenCommand(
|
||||
agpsType, apnName, apnLen, (AGpsBearerType)ipType);
|
||||
}
|
||||
}
|
||||
static void agpsDataConnClosed(AGpsExtType agpsType) {
|
||||
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->dataConnClosedCommand(agpsType);
|
||||
}
|
||||
}
|
||||
static void agpsDataConnFailed(AGpsExtType agpsType) {
|
||||
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->dataConnFailedCommand(agpsType);
|
||||
}
|
||||
}
|
||||
|
||||
static void getDebugReport(GnssDebugReport& report) {
|
||||
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getDebugReport(report);
|
||||
}
|
||||
}
|
||||
|
||||
static void updateConnectionStatus(bool connected, int8_t type,
|
||||
bool roaming, NetworkHandle networkHandle,
|
||||
string& apn) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getSystemStatus()->eventConnectionStatus(
|
||||
connected, type, roaming, networkHandle, apn);
|
||||
}
|
||||
}
|
||||
|
||||
static void odcpiInit(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->initOdcpiCommand(callback, priority);
|
||||
}
|
||||
}
|
||||
|
||||
static void odcpiInject(const Location& location)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->injectOdcpiCommand(location);
|
||||
}
|
||||
}
|
||||
|
||||
static void blockCPI(double latitude, double longitude, float accuracy,
|
||||
int blockDurationMsec, double latLonDiffThreshold) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->blockCPICommand(latitude, longitude, accuracy,
|
||||
blockDurationMsec, latLonDiffThreshold);
|
||||
}
|
||||
}
|
||||
|
||||
static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getGnssEnergyConsumedCommand(energyConsumedCb);
|
||||
}
|
||||
}
|
||||
|
||||
static void enableNfwLocationAccess(bool enable) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->nfwControlCommand(enable);
|
||||
}
|
||||
}
|
||||
|
||||
static void nfwInit(const NfwCbInfo& cbInfo) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->initNfwCommand(cbInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void getPowerStateChanges(std::function<void(bool)> powerStateCb)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getPowerStateChangesCommand(powerStateCb);
|
||||
}
|
||||
}
|
||||
|
||||
static void injectLocationExt(const GnssLocationInfoNotification &locationInfo)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->injectLocationExtCommand(locationInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void updateBatteryStatus(bool charging) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging);
|
||||
}
|
||||
}
|
||||
|
||||
static void resetNetworkInfo() {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getSystemStatus()->resetNetworkInfo();
|
||||
}
|
||||
}
|
||||
|
||||
static void updateSystemPowerState(PowerStateType systemPowerState) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->updateSystemPowerStateCommand(systemPowerState);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t setConstrainedTunc (bool enable, float tuncConstraint, uint32_t energyBudget) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->setConstrainedTuncCommand(enable, tuncConstraint, energyBudget);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t setPositionAssistedClockEstimator(bool enable) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->setPositionAssistedClockEstimatorCommand(enable);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t gnssUpdateSvConfig(
|
||||
const GnssSvTypeConfig& constellationEnablementConfig,
|
||||
const GnssSvIdConfig& blacklistSvConfig) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->gnssUpdateSvConfigCommand(
|
||||
constellationEnablementConfig, blacklistSvConfig);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo){
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->configLeverArmCommand(configInfo);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static bool measCorrInit(const measCorrSetCapabilitiesCb setCapabilitiesCb) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->openMeasCorrCommand(setCapabilitiesCb);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool measCorrSetCorrections(const GnssMeasurementCorrections gnssMeasCorr) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->measCorrSetCorrectionsCommand(gnssMeasCorr);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void measCorrClose() {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->closeMeasCorrCommand();
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t antennaInfoInit(const antennaInfoCb antennaInfoCallback) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->antennaInfoInitCommand(antennaInfoCallback);
|
||||
} else {
|
||||
return ANTENNA_INFO_ERROR_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
static void antennaInfoClose() {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->antennaInfoCloseCommand();
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t configRobustLocation(bool enable, bool enableForE911){
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->configRobustLocationCommand(enable, enableForE911);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t configMinGpsWeek(uint16_t minGpsWeek){
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->configMinGpsWeekCommand(minGpsWeek);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t configDeadReckoningEngineParams(const DeadReckoningEngineConfig& dreConfig){
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->configDeadReckoningEngineParamsCommand(dreConfig);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t gnssUpdateSecondaryBandConfig(
|
||||
const GnssSvTypeConfig& secondaryBandConfig) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->gnssUpdateSecondaryBandConfigCommand(secondaryBandConfig);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t gnssGetSecondaryBandConfig(){
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->gnssGetSecondaryBandConfigCommand();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void updateNTRIPGGAConsent(bool consentAccepted){
|
||||
if (NULL != gGnssAdapter) {
|
||||
// Call will be enabled once GnssAdapter impl. is ready.
|
||||
gGnssAdapter->updateNTRIPGGAConsentCommand(consentAccepted);
|
||||
}
|
||||
}
|
||||
|
||||
static void enablePPENtripStream(const GnssNtripConnectionParams& params, bool enableRTKEngine){
|
||||
if (NULL != gGnssAdapter) {
|
||||
// Call will be enabled once GnssAdapter impl. is ready.
|
||||
gGnssAdapter->enablePPENtripStreamCommand(params, enableRTKEngine);
|
||||
}
|
||||
}
|
||||
|
||||
static void disablePPENtripStream(){
|
||||
if (NULL != gGnssAdapter) {
|
||||
// Call will be enabled once GnssAdapter impl. is ready.
|
||||
gGnssAdapter->disablePPENtripStreamCommand();
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t configEngineRunState(PositioningEngineMask engType, LocEngineRunState engState) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
return gGnssAdapter->configEngineRunStateCommand(engType, engState);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue