replace common qcom sources with samsung ones

This commit is contained in:
SaschaNes
2025-08-12 22:13:00 +02:00
parent ba24dcded9
commit 6f7753de11
5682 changed files with 2450203 additions and 103634 deletions

View File

@@ -0,0 +1,49 @@
cc_library_shared {
name: "liblocation_integration_api",
vendor: true,
//# Libs
shared_libs: [
"libgps.utils",
"liblocation_api_msg",
"libprotobuf-cpp-lite",
"liblog",
],
srcs: [
"src/LocationIntegrationApi.cpp",
"src/LocationIntegrationApiImpl.cpp",
],
cflags: [
"-fno-short-enums",
"-D_ANDROID_",
"-Wno-error=non-virtual-dtor",
] + GNSS_CFLAGS,
local_include_dirs: [
"inc",
"src",
],
//# Includes
ldflags: ["-Wl,--export-dynamic"],
header_libs: [
"libutils_headers",
"libgps.utils_headers",
"libloc_pla_headers",
"liblocation_api_headers",
"liblocation_api_msg.headers",
"liblocation_client_api.impl_headers",
],
}
cc_library_headers {
name: "libloc_integration_api.impl_headers",
export_include_dirs: ["src"] + ["inc"],
vendor: true,
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
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-lite
h_sources = \
src/LocationIntegrationApiImpl.h \
inc/LocationIntegrationApi.h \
src/LocationIntegrationApiDiagLog.h
c_sources = \
src/LocationIntegrationApiImpl.cpp \
src/LocationIntegrationApi.cpp \
src/LocationIntegrationApiDiagLog.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,93 @@
# 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], [qcom-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_ARG_WITH([core_includes],
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
[Specify the location of the core headers]),
[core_incdir=$withval],
with_core_includes=no)
if (test "x$with_core_includes" != "xno"); then
CPPFLAGS="${CPPFLAGS} -I${core_incdir}"
fi
AC_ARG_WITH([locpla_includes],
AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@],
[specify the path to locpla-includes in loc-pla_git.bb]),
[locpla_incdir=$withval],
with_locpla_includes=no)
if test "x$with_locpla_includes" != "xno"; then
AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}")
fi
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"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
/*
Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#include "LocationIntegrationApiDiagLog.h"
#include <log_util.h>
namespace location_integration {
void LocationIntegrationApiDiagLog::fillDiagMmfDataInfo(diagMapMatchedFeedbackData* out,
const mapMatchedFeedbackData& inMmfData) {
if (LOC_HAS_VALID_MMFD_UTC_TIME & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_UTC_TIME;
out->utcTimestampMs = inMmfData.utcTimestampMs;
}
if (LOC_HAS_VALID_MMFD_LAT_DIFF & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_LAT_DIFF;
out->mapMatchedLatitudeDifference = inMmfData.mapMatchedLatitudeDifference;
}
if (LOC_HAS_VALID_MMFD_LONG_DIFF & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_LONG_DIFF;
out->mapMatchedLongitudeDifference = inMmfData.mapMatchedLongitudeDifference;
}
if (LOC_HAS_VALID_MMFD_TUNNEL & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_TUNNEL;
out->isTunnel = inMmfData.isTunnel;
}
if (LOC_HAS_VALID_MMFD_BEARING & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_BEARING;
out->bearing = inMmfData.bearing;
}
if (LOC_HAS_VALID_MMFD_ALTITUDE & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_ALTITUDE;
out->altitude = inMmfData.altitude;
}
if (LOC_HAS_VALID_MMFD_HOR_ACC & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_HOR_ACC;
out->horizontalAccuracy = inMmfData.horizontalAccuracy;
}
if (LOC_HAS_VALID_MMFD_ALT_ACC & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_ALT_ACC;
out->altitudeAccuracy = inMmfData.altitudeAccuracy;
}
if (LOC_HAS_VALID_MMFD_BEARING_ACC & inMmfData.validityMask) {
out->validityMask |= DIAG_MMF_VALID_BEARING_ACC;
out->bearingAccuracy = inMmfData.bearingAccuracy;
}
}
void LocationIntegrationApiDiagLog::diagLogMmfData(const mapMatchedFeedbackData& inMmfData) {
if (mDiagIface) {
size_t size = 0;
diagMapMatchedFeedbackData* mmfDataInfo = NULL;
diagBuffSrc bufferSrc;
size = sizeof(diagMapMatchedFeedbackData);
mmfDataInfo = (diagMapMatchedFeedbackData*)mDiagIface->logAlloc(
LOG_GNSS_LIA_API_MMF_REPORT_C, size, &bufferSrc);
if (mmfDataInfo) {
mmfDataInfo->version = LOG_CLIENT_MMF_DIAG_MSG_VERSION;
fillDiagMmfDataInfo(mmfDataInfo, inMmfData);
mDiagIface->logCommit(mmfDataInfo, bufferSrc,
LOG_GNSS_LIA_API_MMF_REPORT_C,
sizeof(diagMapMatchedFeedbackData));
} else {
LOC_LOGe(" Failed to allocate buffer for MMF data !! ");
}
}
}
LocationIntegrationApiDiagLog::LocationIntegrationApiDiagLog() {
if (NULL == mDiagIface) {
mDiagIface = loadLocDiagIfaceInterface();
if (nullptr == mDiagIface) {
LOC_LOGe("Failed to loadLocDiagIfaceInterface!!");
}
}
}
LocationIntegrationApiDiagLog::~LocationIntegrationApiDiagLog() {
}
} // namespace location_integration {

View File

@@ -0,0 +1,147 @@
/*
Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef LOCATION_INTEGRATION_API_DIAG_LOG_H
#define LOCATION_INTEGRATION_API_DIAG_LOG_H
#include <inttypes.h>
#include "LocationIntegrationApi.h"
#include "LocDiagIfaceApi.h"
/** Packet Versions */
#define LOG_CLIENT_MMF_DIAG_MSG_VERSION (0)
/** Packet Log Codes */
#ifndef LOG_GNSS_LIA_API_MMF_REPORT_C
#define LOG_GNSS_LIA_API_MMF_REPORT_C (0x1E78)
#endif
#ifdef __linux__
#define PACKED
#define PACKED_POST __attribute__((__packed__))
#endif
#if defined(__linux__) || defined(USE_GLIB) || defined(__ANDROID__)
#define TYPEDEF_PACKED_STRUCT typedef PACKED struct PACKED_POST
#else
#define TYPEDEF_PACKED_STRUCT typedef struct
#endif
#ifndef __LOG_HDR_TYPE__
#define __LOG_HDR_TYPE__
typedef struct PACKED_POST {
uint16_t len; /* Specifies the length, in bytes of the
entry, including this header. */
uint16_t code; /* Specifies the log code for the entry as
enumerated above. Note: This is
specified as word to guarantee size. */
/*upper 48 bits represent elapsed time since
6 Jan 1980 00:00:00 in 1.25 ms units. The
low order 16 bits represent elapsed time
since the last 1.25 ms tick in 1/32 chip
units (this 16 bit counter wraps at the
value 49152). */
uint32_t ts_lo; /* Time stamp */
uint32_t ts_hi;
} log_hdr_type;
#endif
enum diagMmfDataValidity {
DIAG_MMF_VALID_UTC_TIME = (1<<0),
DIAG_MMF_VALID_LAT_DIFF = (1<<1),
DIAG_MMF_VALID_LONG_DIFF = (1<<2),
DIAG_MMF_VALID_TUNNEL = (1<<3),
DIAG_MMF_VALID_BEARING = (1<<4),
DIAG_MMF_VALID_ALTITUDE = (1<<5),
DIAG_MMF_VALID_HOR_ACC = (1<<6),
DIAG_MMF_VALID_ALT_ACC = (1<<7),
DIAG_MMF_VALID_BEARING_ACC = (1<<8),
};
typedef PACKED struct PACKED_POST {
/** Used by Logging Module
* Mandatory field */
log_hdr_type logHeader;
/** clientDiag Message Version
* Mandatory field */
uint8_t version;
/** Validity fields for MMF data fields to follow
* Flags defined uisng enum mmfDataValidity */
uint64_t validityMask;
/** Unix epoch time of the location fix for which map-match
* feedback is being sent, since the start of the Unix epoch
* (00:00:00 January 1, 1970 UTC).
* Unit: Milli-seconds */
uint64_t utcTimestampMs;
/** Latitude difference = map matched latitude - reported latitude
* Unit: Degrees
* Range: [-90.0, 90.0] */
double mapMatchedLatitudeDifference;
/** Longitude difference = map matched longitude - reported longitude
* Unit: Degrees
* Range: [-180.0, 180.0] */
double mapMatchedLongitudeDifference;
/** Bearing: The horizontal direction of travel of the device with
* respect to north and is unrelated to the device orientation.
* Unit: Degrees
* range: [0, 360) */
float bearing;
/** Absolute Altitude above the WGS 84 reference ellipsoid
Unit: meters */
double altitude;
/** Horizontal accuracy radius defined with the
* 68th percentile confidence level.
* Unit: meter
* Range: 0 or greater */
float horizontalAccuracy;
/** Altitude accuracy. Defined with 68% confidence level.
* Unit:meter
* Range: 0 or greater */
float altitudeAccuracy;
/** Estimated bearing accuracy defined with
* 68 percentile confidence level (1 sigma).
* Unit: Degrees
* Range [0, 360) */
float bearingAccuracy;
/** Road Type. Decision to use the MMF data depends on isTunnel
* Value: True or False */
bool isTunnel;
} diagMapMatchedFeedbackData;
namespace location_integration {
class LocationIntegrationApiDiagLog {
private:
// Loc-diag-iface handle
LocDiagInterface *mDiagIface = NULL;
/** Convert MMF Data from LIA to Diag structure */
void fillDiagMmfDataInfo(diagMapMatchedFeedbackData* out,
const mapMatchedFeedbackData& inMmfData);
public:
LocationIntegrationApiDiagLog();
~LocationIntegrationApiDiagLog();
void diagLogMmfData(const mapMatchedFeedbackData& inMmfData);
};
} // namespace location_integration
#endif // LOCATION_INTEGRATION_API_DIAG_LOG_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,264 @@
/* Copyright (c) 2019-2021 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.
*/
/*
Changes from Qualcomm Innovation Center are provided under the following license:
Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted (subject to the limitations in the
disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 <loc_pla.h>
#include <LocIpc.h>
#include <ILocationAPI.h>
#include <LocationIntegrationApi.h>
#include <MsgTask.h>
#include <LocationApiMsg.h>
#include <LocationApiPbMsgConv.h>
#include <queue>
#include <unordered_map>
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 std::unordered_map<PositioningEngineMask, uint32_t> LocConfigEngIntegrityRiskMap;
struct TuncConfigInfo{
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
};
struct PaceConfigInfo{
bool isValid;
bool enable;
};
struct SvConfigInfo{
bool isValid;
GnssSvTypeConfig constellationEnablementConfig;
GnssSvIdConfig blacklistSvConfig;
GnssSvTypeConfig secondaryBandConfig;
};
struct RobustLocationConfigInfo{
bool isValid;
bool enable;
bool enableForE911;
};
struct DeadReckoningEngineConfigInfo{
bool isValid;
::DeadReckoningEngineConfig dreConfig;
};
struct GtpUserConsentConfigInfo{
bool isValid;
bool userConsent;
};
struct NmeaConfigInfo{
bool isValid;
GnssNmeaTypesMask enabledNmeaTypes;
GnssGeodeticDatumType nmeaDatumType;
LocReqEngineTypeMask locReqEngMask;
};
struct ProtoMsgInfo{
LocConfigTypeEnum configType;
string protoStr;
inline ProtoMsgInfo() :
configType((LocConfigTypeEnum) 0), protoStr("") {}
inline ProtoMsgInfo(LocConfigTypeEnum inType, string inStr) :
configType(inType), protoStr(std::move(inStr)) {}
};
class IpcListener;
class LocationIntegrationApiImpl : public ILocationControlAPI {
friend IpcListener;
public:
LocationIntegrationApiImpl(LocIntegrationCbs& integrationCbs);
virtual void destroy() override;
// 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(const GnssAidingData& data) override;
virtual uint32_t configMinGpsWeek(uint16_t minGpsWeek) override;
virtual void odcpiInject(const ::Location& location) override;
virtual uint32_t gnssInjectMmfData(const GnssMapMatchedData& mmfData) 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 configEngineIntegrityRisk(PositioningEngineMask engType, uint32_t integrityRisk);
uint32_t setUserConsentForTerrestrialPositioning(bool userConsent);
uint32_t configOutputNmeaTypes(GnssNmeaTypesMask enabledNmeaTypes,
GnssGeodeticDatumType nmeaDatumType,
LocReqEngineTypeMask locReqEngMask) override;
uint32_t configXtraParams(bool enable, const ::XtraConfigParams& configParams);
uint32_t getXtraStatus();
uint32_t registerXtraStatusUpdate(bool registerUpdate);
uint32_t configMerkleTree(const char * merkleTreeXml, int xmlSize);
uint32_t configOsnmaEnablement(bool isEnabled);
uint32_t registerGnssSignalTypesUpdate(bool registerUpdate);
private:
~LocationIntegrationApiImpl();
bool integrationClientAllowed();
bool sendConfigMsgToHalDaemon(LocConfigTypeEnum configType, const string& pbStr,
bool invokeResponseCb = true);
bool sendClientRegMsgToHalDaemon();
void processHalReadyMsg();
void addConfigReq(LocConfigTypeEnum configType);
bool processQueuedReqs(); // return true indicates queue is note empty
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);
void processGetXtraStatusRespCb(
const LocConfigGetXtraStatusRespMsg* pRespMsg);
void processRegisterGnssSignalTypesRespCb(
const LocConfigRegisterGnssSignalTypesUpdateRespMsg* msg);
// 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;
LocConfigEngIntegrityRiskMap mEngIntegrityRiskConfigMap;
GtpUserConsentConfigInfo mGtpUserConsentConfigInfo;
NmeaConfigInfo mNmeaConfigInfo;
bool mRegisterXtraUpdate;
bool mXtraUpdateUponRegisterPending;
LocConfigReqCntMap mConfigReqCntMap;
LocIntegrationCbs mIntegrationCbs;
std::queue<ProtoMsgInfo> mQueuedMsg; // queue of the requests before
// communication with hal daemom
// is established
LocIpc mIpc;
shared_ptr<LocIpcSender> mIpcSender;
MsgTask mMsgTask;
};
} // namespace location_client
#endif /* LOCATION_INTEGRATION_API_IMPL_H */