sm8250-common: import location from LA.UM.9.12.r1-13500.01-SMxx50.QSSI12.0

Change-Id: If93ba9b50dc3bb07a4ba81694187e99f58dd172c
This commit is contained in:
SGCMarkus 2022-03-23 21:42:45 +01:00
parent 72410cf795
commit 64ab05b033
103 changed files with 92521 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,57 @@
AM_CFLAGS = \
-DDEBUG \
-I src/ \
-I inc/ \
$(GPSUTILS_CFLAGS) \
$(LOCAPIMSGPROTO_CFLAGS) \
-std=c++11
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -std=c++11
requiredlibs = \
$(GPSUTILS_LIBS) \
$(LOCAPIMSGPROTO_LIBS) \
-lprotobuf
h_sources = \
src/LocationIntegrationApiImpl.h \
inc/LocationIntegrationApi.h
c_sources = \
src/LocationIntegrationApiImpl.cpp \
src/LocationIntegrationApi.cpp
liblocation_integration_api_la_SOURCES = \
$(c_sources) $(h_sources)
liblocation_integration_api_la_h_sources = $(h_sources)
######################
# Build location_integration_api
######################
if USE_EXTERNAL_AP
AM_CFLAGS += $(LOCSOCKET_CFLAGS) -DFEATURE_EXTERNAL_AP
requiredlibs += $(LOCSOCKET_LIBS)
endif
if USE_GLIB
liblocation_integration_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
liblocation_integration_api_la_LDFLAGS = -lstdc++ -g -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
liblocation_integration_api_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
liblocation_integration_api_la_CFLAGS = $(AM_CFLAGS)
liblocation_integration_api_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread -shared -version-info 1:0:0
liblocation_integration_api_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
liblocation_integration_api_la_LIBADD = $(requiredlibs) -lstdc++ -ldl
#Create and Install libraries
library_include_HEADERS = $(h_sources)
lib_LTLIBRARIES = liblocation_integration_api.la
library_includedir = $(pkgincludedir)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = location-integration-api.pc
EXTRA_DIST = $(pkgconfig_DATA)

View file

@ -0,0 +1,11 @@
Location Client Api doc
1. Steps to generate doxygen Api doc:
run
mkclientapidoc.sh [output-path]
default output-path is docs/
default doxgen configuration file is LocationClientApiDoxygen.conf
2. below file will be generated:
html/
-HTML output, where the html/index.html is the home page.

View file

@ -0,0 +1,72 @@
# configure.ac -- Autoconf script for gps location-integration-api
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the location_integration_api package version 1.0.0
AC_INIT([location-integration-api],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign subdir-objects])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# Verifies the --srcdir is correct by checking for the path
AC_CONFIG_SRCDIR([Makefile.am])
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES([GPSUTILS], [gps-utils])
AC_SUBST([GPSUTILS_CFLAGS])
AC_SUBST([GPSUTILS_LIBS])
PKG_CHECK_MODULES([LOCAPIMSGPROTO], [location-api-msg-proto])
AC_SUBST([LOCAPIMSGPROTO_CFLAGS])
AC_SUBST([LOCAPIMSGPROTO_LIBS])
AC_ARG_WITH([external_ap],
AC_HELP_STRING([--with-external_ap=@<:@dir@:>@],
[Using External Application Processor]),
[],
with_external_ap=no)
AM_CONDITIONAL(USE_EXTERNAL_AP, test "x${with_external_ap}" = "xyes")
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building HLOS systems which use glib]))
if (test "x${with_glib}" = "xyes"); then
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GLib >= 2.16 is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
location-integration-api.pc
])
AC_OUTPUT

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,38 @@
/* Copyright (c) 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.
*/
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: location-integration-api
Description: location integration api library
Version: @VERSION@
Libs: -L${libdir} -llocation_integration_api
Cflags: -I${includedir} -I${includedir}/location-integration-api

View file

@ -0,0 +1,86 @@
#!/bin/bash
#==========================================================================
#Copyright (c) 2018-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.
#
#==========================================================================
#==========================================================================
#
# Usage:
# mkintegrationapidoc.sh [output-path]
#
# Note, this script requires the existence of the doxygen tool -
# This script can be called from any directory
#==========================================================================
DIR="$( cd "$( dirname "$0" )" && pwd )"
# the default doxygen configuration is LocationIntegrationApiDoxygen.conf
CONFIG=$DIR/LocationIntegrationApiDoxygen.conf
OUT="docs"
# Show help message if requested, otherwise create output folder
if [ -n "$1" ]
then
if [ "$1" == "-h" ] || [ "$1" == "--help" ]
then
echo "$0 [output-path]"
echo " e.g. $0"
echo " $0 docs"
exit
else
OUT=$1
if [ ! -d $OUT ]
then
mkdir -p $OUT
fi
fi
fi
which doxygen
if [ "$?" == 0 ]
then
# Use ? here to seperate patterns as / in path will be regarded as splitter by default
sed -i "s?^OUTPUT_DIRECTORY .*?OUTPUT_DIRECTORY = $OUT?" $CONFIG
sed -i "s?^INPUT .*?INPUT = $DIR/inc?" $CONFIG
doxygen $CONFIG > /dev/null 2>&1
else
echo "This script requires doxygen tool be to installed. "
echo "You can install is with e.g. sudo apt-get install doxygen"
exit 1
fi
if [ ! -e $OUT/html/index.html ]
then
echo "Error building Location Client Api doc files."
exit 2
fi
echo
echo "doxygen docs for Location Client Api available at: $OUT/html"

View file

@ -0,0 +1,560 @@
/* Copyright (c) 2019-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_LocationIntegrationApi"
#include <LocationDataTypes.h>
#include <LocationIntegrationApi.h>
#include <LocationIntegrationApiImpl.h>
#include <log_util.h>
#include <loc_pla.h>
namespace location_integration {
/******************************************************************************
LocationIntegrationApi
******************************************************************************/
LocationIntegrationApi::LocationIntegrationApi(
const LocConfigPriorityMap& priorityMap,
LocIntegrationCbs& integrationCbs) {
mApiImpl = new LocationIntegrationApiImpl(integrationCbs);
}
LocationIntegrationApi::~LocationIntegrationApi() {
LOC_LOGd("calling destructor of LocationIntegrationApi");
if (mApiImpl) {
mApiImpl->destroy();
}
}
bool LocationIntegrationApi::configConstellations(
const LocConfigBlacklistedSvIdList* blacklistedSvIds){
if (nullptr == mApiImpl) {
LOC_LOGe ("NULL mApiImpl");
return false;
}
GnssSvTypeConfig constellationEnablementConfig = {};
GnssSvIdConfig blacklistSvConfig = {};
if (nullptr == blacklistedSvIds) {
// set size field in constellationEnablementConfig to 0 to indicate
// to restore to modem default
constellationEnablementConfig.size = 0;
// all fields in blacklistSvConfig has already been initialized to 0
blacklistSvConfig.size = sizeof(GnssSvIdConfig);
} else {
constellationEnablementConfig.size = sizeof(constellationEnablementConfig);
constellationEnablementConfig.enabledSvTypesMask =
GNSS_SV_TYPES_MASK_GLO_BIT|GNSS_SV_TYPES_MASK_BDS_BIT|
GNSS_SV_TYPES_MASK_QZSS_BIT|GNSS_SV_TYPES_MASK_GAL_BIT;
blacklistSvConfig.size = sizeof(GnssSvIdConfig);
for (GnssSvIdInfo it : *blacklistedSvIds) {
LOC_LOGv("constellation %d, sv id %f", (int) it.constellation, it.svId);
GnssSvTypesMask svTypeMask = (GnssSvTypesMask) 0;
uint64_t* svMaskPtr = NULL;
GnssSvId initialSvId = 0;
uint16_t svIndexOffset = 0;
switch (it.constellation) {
case GNSS_CONSTELLATION_TYPE_GLONASS:
svTypeMask = (GnssSvTypesMask) GNSS_SV_TYPES_MASK_GLO_BIT;
svMaskPtr = &blacklistSvConfig.gloBlacklistSvMask;
initialSvId = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID;
break;
case GNSS_CONSTELLATION_TYPE_QZSS:
svTypeMask = (GnssSvTypesMask) GNSS_SV_TYPES_MASK_QZSS_BIT;
svMaskPtr = &blacklistSvConfig.qzssBlacklistSvMask;
initialSvId = GNSS_SV_CONFIG_QZSS_INITIAL_SV_ID;
break;
case GNSS_CONSTELLATION_TYPE_BEIDOU:
svTypeMask = (GnssSvTypesMask) GNSS_SV_TYPES_MASK_BDS_BIT;
svMaskPtr = &blacklistSvConfig.bdsBlacklistSvMask;
initialSvId = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID;
break;
case GNSS_CONSTELLATION_TYPE_GALILEO:
svTypeMask = (GnssSvTypesMask) GNSS_SV_TYPES_MASK_GAL_BIT;
svMaskPtr = &blacklistSvConfig.galBlacklistSvMask;
initialSvId = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID;
break;
case GNSS_CONSTELLATION_TYPE_SBAS:
// SBAS does not support enable/disable whole constellation
// so do not set up svTypeMask for SBAS
svMaskPtr = &blacklistSvConfig.sbasBlacklistSvMask;
// SBAS currently has two ranges
// range of SV id: 183 to 191
if (GNSS_SV_ID_BLACKLIST_ALL == it.svId) {
LOC_LOGd("blacklist all SBAS SV");
} else if (it.svId >= GNSS_SV_CONFIG_SBAS_INITIAL2_SV_ID) {
initialSvId = GNSS_SV_CONFIG_SBAS_INITIAL2_SV_ID;
svIndexOffset = GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH;
} else if ((it.svId >= GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID) &&
(it.svId < (GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID +
GNSS_SV_CONFIG_SBAS_INITIAL_SV_LENGTH))){
// range of SV id: 120 to 158
initialSvId = GNSS_SV_CONFIG_SBAS_INITIAL_SV_ID;
} else {
LOC_LOGe("invalid SBAS sv id %d", it.svId);
svMaskPtr = nullptr;
}
break;
case GNSS_CONSTELLATION_TYPE_NAVIC:
svTypeMask = (GnssSvTypesMask) GNSS_SV_TYPES_MASK_NAVIC_BIT;
svMaskPtr = &blacklistSvConfig.navicBlacklistSvMask;
initialSvId = GNSS_SV_CONFIG_NAVIC_INITIAL_SV_ID;
break;
default:
LOC_LOGe("blacklistedSv in constellation %d not supported", it.constellation);
break;
}
if (nullptr == svMaskPtr) {
LOC_LOGe("Invalid constellation %d", it.constellation);
} else {
// SV ID 0 = Blacklist All SVs
if (GNSS_SV_ID_BLACKLIST_ALL == it.svId) {
// blacklist all SVs in this constellation
*svMaskPtr = GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK;
constellationEnablementConfig.enabledSvTypesMask &= ~svTypeMask;
constellationEnablementConfig.blacklistedSvTypesMask |= svTypeMask;
} else if (it.svId < initialSvId || it.svId >= initialSvId + 64) {
LOC_LOGe ("SV TYPE %d, Invalid sv id %d ", it.constellation, it.svId);
} else {
uint32_t shiftCnt = it.svId + svIndexOffset - initialSvId;
*svMaskPtr |= (1ULL << shiftCnt);
}
}
}
}
LOC_LOGd("constellation config size=%d, enabledMask=0x%" PRIx64 ", disabledMask=0x%" PRIx64 ", "
"glo blacklist mask =0x%" PRIx64 ", qzss blacklist mask =0x%" PRIx64 ", "
"bds blacklist mask =0x%" PRIx64 ", gal blacklist mask =0x%" PRIx64 ", "
"sbas blacklist mask =0x%" PRIx64 ", Navic blacklist mask =0x%" PRIx64 ", ",
constellationEnablementConfig.size, constellationEnablementConfig.enabledSvTypesMask,
constellationEnablementConfig.blacklistedSvTypesMask,
blacklistSvConfig.gloBlacklistSvMask, blacklistSvConfig.qzssBlacklistSvMask,
blacklistSvConfig.bdsBlacklistSvMask, blacklistSvConfig.galBlacklistSvMask,
blacklistSvConfig.sbasBlacklistSvMask, blacklistSvConfig.navicBlacklistSvMask);
mApiImpl->configConstellations(constellationEnablementConfig,
blacklistSvConfig);
return true;
}
bool LocationIntegrationApi::configConstellationSecondaryBand(
const ConstellationSet* secondaryBandDisablementSet) {
GnssSvTypeConfig secondaryBandConfig = {};
if (nullptr == mApiImpl) {
LOC_LOGe ("NULL mApiImpl");
return false;
}
if (nullptr != secondaryBandDisablementSet) {
for (GnssConstellationType disabledSecondaryBand : *secondaryBandDisablementSet) {
LOC_LOGd("to disable secondary band for constellation %d", disabledSecondaryBand);
secondaryBandConfig.enabledSvTypesMask =
(GNSS_SV_TYPES_MASK_GLO_BIT | GNSS_SV_TYPES_MASK_QZSS_BIT|
GNSS_SV_TYPES_MASK_BDS_BIT | GNSS_SV_TYPES_MASK_GAL_BIT|
GNSS_SV_TYPES_MASK_NAVIC_BIT | GNSS_SV_TYPES_MASK_GPS_BIT);
switch (disabledSecondaryBand) {
case GNSS_CONSTELLATION_TYPE_GLONASS:
secondaryBandConfig.blacklistedSvTypesMask |= GNSS_SV_TYPES_MASK_GLO_BIT;
break;
case GNSS_CONSTELLATION_TYPE_QZSS:
secondaryBandConfig.blacklistedSvTypesMask |= GNSS_SV_TYPES_MASK_QZSS_BIT;
break;
case GNSS_CONSTELLATION_TYPE_BEIDOU:
secondaryBandConfig.blacklistedSvTypesMask |= GNSS_SV_TYPES_MASK_BDS_BIT;
break;
case GNSS_CONSTELLATION_TYPE_GALILEO:
secondaryBandConfig.blacklistedSvTypesMask |= GNSS_SV_TYPES_MASK_GAL_BIT;
break;
case GNSS_CONSTELLATION_TYPE_NAVIC:
secondaryBandConfig.blacklistedSvTypesMask |= GNSS_SV_TYPES_MASK_NAVIC_BIT;
break;
case GNSS_CONSTELLATION_TYPE_GPS:
secondaryBandConfig.blacklistedSvTypesMask |= GNSS_SV_TYPES_MASK_GPS_BIT;
break;
default:
LOC_LOGd("disabled secondary band for constellation %d not suported",
disabledSecondaryBand);
break;
}
}
}
secondaryBandConfig.size = sizeof (secondaryBandConfig);
secondaryBandConfig.enabledSvTypesMask =
(GNSS_SV_TYPES_MASK_GLO_BIT | GNSS_SV_TYPES_MASK_BDS_BIT |
GNSS_SV_TYPES_MASK_QZSS_BIT | GNSS_SV_TYPES_MASK_GAL_BIT |
GNSS_SV_TYPES_MASK_NAVIC_BIT | GNSS_SV_TYPES_MASK_GPS_BIT);
secondaryBandConfig.enabledSvTypesMask ^= secondaryBandConfig.blacklistedSvTypesMask;
LOC_LOGd("secondary band config size=%d, enableMask=0x%" PRIx64 ", disabledMask=0x%" PRIx64 "",
secondaryBandConfig.size, secondaryBandConfig.enabledSvTypesMask,
secondaryBandConfig.blacklistedSvTypesMask);
mApiImpl->configConstellationSecondaryBand(secondaryBandConfig);
return true;
}
bool LocationIntegrationApi::getConstellationSecondaryBandConfig() {
if (mApiImpl) {
// mApiImpl->getConstellationSecondaryBandConfig returns
// none-zero when there is no callback registered in the contructor
return (mApiImpl->getConstellationSecondaryBandConfig() == 0);
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configConstrainedTimeUncertainty(
bool enable, float tuncThreshold, uint32_t energyBudget) {
if (mApiImpl) {
LOC_LOGd("enable %d, tuncThreshold %f, energyBudget %u",
enable, tuncThreshold, energyBudget);
mApiImpl->configConstrainedTimeUncertainty(
enable, tuncThreshold, energyBudget);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configPositionAssistedClockEstimator(bool enable) {
if (mApiImpl) {
LOC_LOGd("enable %d", enable);
mApiImpl->configPositionAssistedClockEstimator(enable);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::deleteAllAidingData() {
if (mApiImpl) {
GnssAidingData aidingData = {};
aidingData.deleteAll = true;
aidingData.posEngineMask = POSITION_ENGINE_MASK_ALL;
aidingData.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_MASK_ALL;
aidingData.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT;
aidingData.dreAidingDataMask |= DR_ENGINE_AIDING_DATA_CALIBRATION_BIT;
mApiImpl->gnssDeleteAidingData(aidingData);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::deleteAidingData(AidingDataDeletionMask aidingDataMask) {
if (mApiImpl) {
LOC_LOGd("aiding data mask 0x%x", aidingDataMask);
GnssAidingData aidingData = {};
aidingData.deleteAll = false;
if (aidingDataMask & AIDING_DATA_DELETION_EPHEMERIS) {
aidingData.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_MASK_ALL;
aidingData.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT;
aidingData.posEngineMask = POSITION_ENGINE_MASK_ALL;
}
if (aidingDataMask & AIDING_DATA_DELETION_DR_SENSOR_CALIBRATION) {
aidingData.dreAidingDataMask |= DR_ENGINE_AIDING_DATA_CALIBRATION_BIT;
aidingData.posEngineMask |= DEAD_RECKONING_ENGINE;
}
mApiImpl->gnssDeleteAidingData(aidingData);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configLeverArm(const LeverArmParamsMap& configInfo) {
if (mApiImpl) {
LeverArmConfigInfo halLeverArmConfigInfo = {};
for (auto it = configInfo.begin(); it != configInfo.end(); ++it) {
::LeverArmParams* params = nullptr;
LeverArmTypeMask mask = (LeverArmTypeMask) 0;
switch (it->first){
case LEVER_ARM_TYPE_GNSS_TO_VRP:
mask = LEVER_ARM_TYPE_GNSS_TO_VRP_BIT;
params = &halLeverArmConfigInfo.gnssToVRP;
break;
case LEVER_ARM_TYPE_DR_IMU_TO_GNSS:
mask = LEVER_ARM_TYPE_DR_IMU_TO_GNSS_BIT;
params = &halLeverArmConfigInfo.drImuToGnss;
break;
case LEVER_ARM_TYPE_VEPP_IMU_TO_GNSS:
mask = LEVER_ARM_TYPE_VEPP_IMU_TO_GNSS_BIT;
params = &halLeverArmConfigInfo.veppImuToGnss;
break;
default:
break;
}
if (nullptr != params) {
halLeverArmConfigInfo.leverArmValidMask |= mask;
params->forwardOffsetMeters = it->second.forwardOffsetMeters;
params->sidewaysOffsetMeters = it->second.sidewaysOffsetMeters;
params->upOffsetMeters = it->second.upOffsetMeters;
LOC_LOGd("mask 0x%x, forward %f, sidways %f, up %f",
mask, params->forwardOffsetMeters,
params->sidewaysOffsetMeters, params->upOffsetMeters);
}
}
mApiImpl->configLeverArm(halLeverArmConfigInfo);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configRobustLocation(bool enable, bool enableForE911) {
if (mApiImpl) {
LOC_LOGd("enable %d, enableForE911 %d", enable, enableForE911);
mApiImpl->configRobustLocation(enable, enableForE911);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::getRobustLocationConfig() {
if (mApiImpl) {
// mApiImpl->getRobustLocationConfig returns none-zero when
// there is no callback
return (mApiImpl->getRobustLocationConfig() == 0);
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configMinGpsWeek(uint16_t minGpsWeek) {
if (mApiImpl && minGpsWeek != 0) {
LOC_LOGd("min gps week %u", minGpsWeek);
return (mApiImpl->configMinGpsWeek(minGpsWeek) == 0);
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::getMinGpsWeek() {
if (mApiImpl) {
return (mApiImpl->getMinGpsWeek() == 0);
} else {
LOC_LOGe ("NULL mApiImpl or callback");
return false;
}
}
bool LocationIntegrationApi::configBodyToSensorMountParams(
const BodyToSensorMountParams& b2sParams) {
return false;
}
bool LocationIntegrationApi::configDeadReckoningEngineParams(
const DeadReckoningEngineConfig& dreConfig) {
if (mApiImpl) {
LOC_LOGd("mask 0x%x, roll offset %f, pitch offset %f, yaw offset %f, offset unc %f",
dreConfig.validMask,
dreConfig.bodyToSensorMountParams.rollOffset,
dreConfig.bodyToSensorMountParams.pitchOffset,
dreConfig.bodyToSensorMountParams.yawOffset,
dreConfig.bodyToSensorMountParams.offsetUnc,
dreConfig.vehicleSpeedScaleFactor,
dreConfig.vehicleSpeedScaleFactorUnc,
dreConfig.gyroScaleFactor, dreConfig.gyroScaleFactorUnc);
::DeadReckoningEngineConfig halConfig = {};
if (dreConfig.validMask & BODY_TO_SENSOR_MOUNT_PARAMS_VALID) {
if (dreConfig.bodyToSensorMountParams.rollOffset < -180.0 ||
dreConfig.bodyToSensorMountParams.rollOffset > 180.0 ||
dreConfig.bodyToSensorMountParams.pitchOffset < -180.0 ||
dreConfig.bodyToSensorMountParams.pitchOffset > 180.0 ||
dreConfig.bodyToSensorMountParams.yawOffset < -180.0 ||
dreConfig.bodyToSensorMountParams.yawOffset > 180.0 ||
dreConfig.bodyToSensorMountParams.offsetUnc < -180.0 ||
dreConfig.bodyToSensorMountParams.offsetUnc > 180.0 ) {
LOC_LOGe("invalid b2s parameter, range is [-180.0, 180.0]");
return false;
}
halConfig.validMask |= ::BODY_TO_SENSOR_MOUNT_PARAMS_VALID;
halConfig.bodyToSensorMountParams.rollOffset =
dreConfig.bodyToSensorMountParams.rollOffset;
halConfig.bodyToSensorMountParams.pitchOffset =
dreConfig.bodyToSensorMountParams.pitchOffset;
halConfig.bodyToSensorMountParams.yawOffset =
dreConfig.bodyToSensorMountParams.yawOffset;
halConfig.bodyToSensorMountParams.offsetUnc =
dreConfig.bodyToSensorMountParams.offsetUnc;
}
if (dreConfig.validMask & VEHICLE_SPEED_SCALE_FACTOR_VALID) {
if (dreConfig.vehicleSpeedScaleFactor < 0.9 ||
dreConfig.vehicleSpeedScaleFactor > 1.1) {
LOC_LOGe("invalid vehicle speed scale factor, range is [0.9, 1,1]");
return false;
}
halConfig.validMask |= ::VEHICLE_SPEED_SCALE_FACTOR_VALID;
halConfig.vehicleSpeedScaleFactor = dreConfig.vehicleSpeedScaleFactor;
}
if (dreConfig.validMask & VEHICLE_SPEED_SCALE_FACTOR_UNC_VALID) {
if (dreConfig.vehicleSpeedScaleFactorUnc < 0.0 ||
dreConfig.vehicleSpeedScaleFactorUnc > 0.1) {
LOC_LOGe("invalid vehicle speed scale factor uncertainty, range is [0.0, 0.1]");
return false;
}
halConfig.validMask |= ::VEHICLE_SPEED_SCALE_FACTOR_UNC_VALID;
halConfig.vehicleSpeedScaleFactorUnc = dreConfig.vehicleSpeedScaleFactorUnc;
}
if (dreConfig.validMask & GYRO_SCALE_FACTOR_VALID) {
if (dreConfig.gyroScaleFactor < 0.9 ||
dreConfig.gyroScaleFactor > 1.1) {
LOC_LOGe("invalid gyro scale factor, range is [0.9, 1,1]");
return false;
}
halConfig.validMask |= ::GYRO_SCALE_FACTOR_VALID;
halConfig.gyroScaleFactor = dreConfig.gyroScaleFactor;
}
if (dreConfig.validMask & GYRO_SCALE_FACTOR_UNC_VALID) {
if (dreConfig.gyroScaleFactorUnc < 0.0 ||
dreConfig.gyroScaleFactorUnc > 0.1) {
LOC_LOGe("invalid gyro scale factor uncertainty, range is [0.0, 0.1]");
return false;
}
halConfig.validMask |= ::GYRO_SCALE_FACTOR_UNC_VALID;
halConfig.gyroScaleFactorUnc = dreConfig.gyroScaleFactorUnc;
}
LOC_LOGd("mask 0x%" PRIx64 ", roll offset %f, pitch offset %f, "
"yaw offset %f, offset unc %f", halConfig.validMask,
halConfig.bodyToSensorMountParams.rollOffset,
halConfig.bodyToSensorMountParams.pitchOffset,
halConfig.bodyToSensorMountParams.yawOffset,
halConfig.bodyToSensorMountParams.offsetUnc,
halConfig.vehicleSpeedScaleFactor,
halConfig.vehicleSpeedScaleFactorUnc,
halConfig.gyroScaleFactor, halConfig.gyroScaleFactorUnc);
mApiImpl->configDeadReckoningEngineParams(halConfig);
return true;
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configMinSvElevation(uint8_t minSvElevation) {
if (mApiImpl) {
if (minSvElevation <= 90) {
LOC_LOGd("min sv elevation %u", minSvElevation);
GnssConfig gnssConfig = {};
gnssConfig.flags = GNSS_CONFIG_FLAGS_MIN_SV_ELEVATION_BIT;
gnssConfig.minSvElevation = minSvElevation;
mApiImpl->configMinSvElevation(minSvElevation);
return true;
} else {
LOC_LOGe("invalid minSvElevation: %u, valid range is [0, 90]", minSvElevation);
return false;
}
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::getMinSvElevation() {
if (mApiImpl) {
return (mApiImpl->getMinSvElevation() == 0);
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::configEngineRunState(LocIntegrationEngineType engType,
LocIntegrationEngineRunState engState) {
if (mApiImpl) {
PositioningEngineMask halEngType = (PositioningEngineMask)0;
LocEngineRunState halEngState = (LocEngineRunState)0;
switch (engType) {
case LOC_INT_ENGINE_SPE:
halEngType = STANDARD_POSITIONING_ENGINE;
break;
case LOC_INT_ENGINE_DRE:
halEngType = DEAD_RECKONING_ENGINE;
break;
case LOC_INT_ENGINE_PPE:
halEngType = PRECISE_POSITIONING_ENGINE;
break;
case LOC_INT_ENGINE_VPE:
halEngType = VP_POSITIONING_ENGINE;
break;
default:
LOC_LOGe("unknown engine type of %d", engType);
return false;
}
if (engState == LOC_INT_ENGINE_RUN_STATE_PAUSE) {
halEngState = LOC_ENGINE_RUN_STATE_PAUSE;
} else if (engState == LOC_INT_ENGINE_RUN_STATE_RESUME) {
halEngState = LOC_ENGINE_RUN_STATE_RESUME;
} else {
LOC_LOGe("unknown engine state %d", engState);
return false;
}
return (mApiImpl->configEngineRunState(halEngType, halEngState) == 0);
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
bool LocationIntegrationApi::setUserConsentForTerrestrialPositioning(bool userConsent) {
if (mApiImpl) {
return (mApiImpl->setUserConsentForTerrestrialPositioning(userConsent) == 0);
} else {
LOC_LOGe ("NULL mApiImpl");
return false;
}
}
} // namespace location_integration

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,191 @@
/* Copyright (c) 2019-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 LOCATION_INTEGRATION_API_IMPL_H
#define LOCATION_INTEGRATION_API_IMPL_H
#include <mutex>
#include <LocIpc.h>
#include <LocationDataTypes.h>
#include <ILocationAPI.h>
#include <LocationIntegrationApi.h>
#include <MsgTask.h>
#include <LocationApiMsg.h>
#include <LocationApiPbMsgConv.h>
#ifdef NO_UNORDERED_SET_OR_MAP
#include <map>
#else
#include <unordered_map>
#endif
using namespace std;
using namespace loc_util;
using namespace location_integration;
namespace location_integration
{
typedef std::unordered_map<LocConfigTypeEnum, int32_t> LocConfigReqCntMap;
typedef std::unordered_map<PositioningEngineMask, LocEngineRunState> LocConfigEngRunStateMap;
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;
GnssSvTypeConfig constellationEnablementConfig;
GnssSvIdConfig blacklistSvConfig;
GnssSvTypeConfig secondaryBandConfig;
} SvConfigInfo;
typedef struct {
bool isValid;
bool enable;
bool enableForE911;
} RobustLocationConfigInfo;
typedef struct {
bool isValid;
::DeadReckoningEngineConfig dreConfig;
} DeadReckoningEngineConfigInfo;
typedef struct {
bool isValid;
bool userConsent;
} GtpUserConsentConfigInfo;
class IpcListener;
class LocationIntegrationApiImpl : public ILocationControlAPI {
friend IpcListener;
public:
LocationIntegrationApiImpl(LocIntegrationCbs& integrationCbs);
void destroy();
// convenient methods
inline bool sendMessage(const uint8_t* data, uint32_t length) const {
return (mIpcSender != nullptr) && LocIpc::send(*mIpcSender, data, length);
}
// reset to defaut will apply to enable/disable SV constellation and
// blacklist/unblacklist SVs
virtual uint32_t configConstellations(
const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig) override;
virtual uint32_t configConstellationSecondaryBand(
const GnssSvTypeConfig& secondaryBandConfig) override;
virtual uint32_t configConstrainedTimeUncertainty(
bool enable, float tuncThreshold, uint32_t energyBudget) override;
virtual uint32_t configPositionAssistedClockEstimator(bool enable) override;
virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) override;
virtual uint32_t configRobustLocation(bool enable, bool enableForE911) override;
virtual uint32_t configDeadReckoningEngineParams(
const ::DeadReckoningEngineConfig& dreConfig) override;
virtual uint32_t* gnssUpdateConfig(const GnssConfig& config) override;
virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) override;
virtual uint32_t configMinGpsWeek(uint16_t minGpsWeek) override;
uint32_t getRobustLocationConfig();
uint32_t getMinGpsWeek();
uint32_t configMinSvElevation(uint8_t minSvElevation);
uint32_t getMinSvElevation();
uint32_t getConstellationSecondaryBandConfig();
uint32_t configEngineRunState(PositioningEngineMask engType, LocEngineRunState engState);
uint32_t setUserConsentForTerrestrialPositioning(bool userConsent);
private:
~LocationIntegrationApiImpl();
bool integrationClientAllowed();
void sendConfigMsgToHalDaemon(LocConfigTypeEnum configType,
uint8_t* pMsg,
size_t msgSize,
bool invokeResponseCb = true);
void sendClientRegMsgToHalDaemon();
void processHalReadyMsg();
void addConfigReq(LocConfigTypeEnum configType);
void flushConfigReqs();
void processConfigRespCb(const LocAPIGenericRespMsg* pRespMsg);
void processGetRobustLocationConfigRespCb(
const LocConfigGetRobustLocationConfigRespMsg* pRespMsg);
void processGetMinGpsWeekRespCb(const LocConfigGetMinGpsWeekRespMsg* pRespMsg);
void processGetMinSvElevationRespCb(const LocConfigGetMinSvElevationRespMsg* pRespMsg);
void processGetConstellationSecondaryBandConfigRespCb(
const LocConfigGetConstellationSecondaryBandConfigRespMsg* pRespMsg);
// protobuf conversion util class
LocationApiPbMsgConv mPbufMsgConv;
// internal session parameter
static mutex mMutex;
static bool mClientRunning; // allow singleton int client
bool mHalRegistered;
// For client on different processor, socket name will start with
// defined constant of SOCKET_TO_EXTERANL_AP_LOCATION_CLIENT_BASE.
// For client on same processor, socket name will start with
// SOCKET_LOC_CLIENT_DIR + LOC_INTAPI_NAME_PREFIX.
char mSocketName[MAX_SOCKET_PATHNAME_LENGTH];
// cached configuration to be used when hal daemon crashes
// and restarts
TuncConfigInfo mTuncConfigInfo;
PaceConfigInfo mPaceConfigInfo;
SvConfigInfo mSvConfigInfo;
LeverArmConfigInfo mLeverArmConfigInfo;
RobustLocationConfigInfo mRobustLocationConfigInfo;
DeadReckoningEngineConfigInfo mDreConfigInfo;
LocConfigEngRunStateMap mEngRunStateConfigMap;
GtpUserConsentConfigInfo mGtpUserConsentConfigInfo;
LocConfigReqCntMap mConfigReqCntMap;
LocIntegrationCbs mIntegrationCbs;
LocIpc mIpc;
shared_ptr<LocIpcSender> mIpcSender;
MsgTask mMsgTask;
};
} // namespace location_client
#endif /* LOCATION_INTEGRATION_API_IMPL_H */