davinci: gps: Update to LA.UM.9.1.r1-06700-SMxxx0.0

Change-Id: I7441cf1b3d067969dad0ad3d57c27bb87a276189
This commit is contained in:
Arian
2020-10-23 19:22:47 +02:00
parent e6ae9c1b27
commit f2fb47a4a0
131 changed files with 8722 additions and 2361 deletions

View File

@@ -91,7 +91,7 @@ TARGET_USES_FOD_ZPOS := true
# GPS
BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default
LOC_HIDL_VERSION := 3.0
LOC_HIDL_VERSION := 4.0
# HIDL
DEVICE_MANIFEST_FILE := $(DEVICE_PATH)/configs/hidl/manifest.xml

View File

@@ -169,8 +169,8 @@ PRODUCT_COPY_FILES += \
# GPS
PRODUCT_PACKAGES += \
android.hardware.gnss@2.0-impl-qti \
android.hardware.gnss@2.0-service-qti
android.hardware.gnss@2.1-impl-qti \
android.hardware.gnss@2.1-service-qti
PRODUCT_PACKAGES += \
libbatching \

45
gps/Android.bp Normal file
View File

@@ -0,0 +1,45 @@
GNSS_CFLAGS = [
"-Werror",
"-Wno-error=unused-parameter",
"-Wno-error=macro-redefined",
"-Wno-error=reorder",
"-Wno-error=missing-braces",
"-Wno-error=self-assign",
"-Wno-error=enum-conversion",
"-Wno-error=logical-op-parentheses",
"-Wno-error=null-arithmetic",
"-Wno-error=null-conversion",
"-Wno-error=parentheses-equality",
"-Wno-error=undefined-bool-conversion",
"-Wno-error=tautological-compare",
"-Wno-error=switch",
"-Wno-error=date-time",
]
/* Activate the following for regression testing */
GNSS_SANITIZE = {
/* address: true,*/
cfi: true,
misc_undefined: [
"bounds",
"null",
"unreachable",
"integer",
],
}
/* Activate the following for debug purposes only,
comment out for production */
GNSS_SANITIZE_DIAG = {
/*
diag: {
cfi: true,
misc_undefined: [
"bounds",
"null",
"unreachable",
"integer",
],
},
*/
}

View File

@@ -1,22 +1,26 @@
#
# Copyright (C) 2020 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
LOCAL_PATH := $(call my-dir)
include $(call first-makefiles-under,$(LOCAL_PATH))
# Set required flags
GNSS_CFLAGS := \
-Werror \
-Wno-error=unused-parameter \
-Wno-error=macro-redefined \
-Wno-error=reorder \
-Wno-error=missing-braces \
-Wno-error=self-assign \
-Wno-error=enum-conversion \
-Wno-error=logical-op-parentheses \
-Wno-error=null-arithmetic \
-Wno-error=null-conversion \
-Wno-error=parentheses-equality \
-Wno-error=undefined-bool-conversion \
-Wno-error=tautological-compare \
-Wno-error=switch \
-Wno-error=date-time
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
LOCAL_PATH := $(call my-dir)
include $(call all-makefiles-under,$(LOCAL_PATH))
GNSS_SANITIZE := cfi bounds null unreachable integer
endif # ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)

View File

@@ -1,4 +0,0 @@
service gnss_service /vendor/bin/hw/android.hardware.gnss@2.0-service-qti
class hal
user gps
group system gps radio

View File

@@ -1,278 +0,0 @@
/* Copyright (c) 2017-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.
*
*/
#include <LocationUtil.h>
#include <log_util.h>
#include <inttypes.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V2_0::GnssLocation;
using ::android::hardware::gnss::V2_0::GnssConstellationType;
using ::android::hardware::gnss::V1_0::GnssLocationFlags;
void convertGnssLocation(Location& in, V1_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V1_0::GnssLocation));
if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
out.latitudeDegrees = in.latitude;
out.longitudeDegrees = in.longitude;
}
if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
out.altitudeMeters = in.altitude;
}
if (in.flags & LOCATION_HAS_SPEED_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
out.speedMetersPerSec = in.speed;
}
if (in.flags & LOCATION_HAS_BEARING_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
out.bearingDegrees = in.bearing;
}
if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
out.horizontalAccuracyMeters = in.accuracy;
}
if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
out.verticalAccuracyMeters = in.verticalAccuracy;
}
if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
out.speedAccuracyMetersPerSecond = in.speedAccuracy;
}
if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
out.bearingAccuracyDegrees = in.bearingAccuracy;
}
out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
}
void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V2_0::GnssLocation));
convertGnssLocation(in, out.v1_0);
struct timespec sinceBootTime;
struct timespec currentTime;
if (0 == clock_gettime(CLOCK_BOOTTIME,&sinceBootTime) &&
0 == clock_gettime(CLOCK_REALTIME,&currentTime)) {
int64_t sinceBootTimeNanos = sinceBootTime.tv_sec*1000000000 + sinceBootTime.tv_nsec;
int64_t currentTimeNanos = currentTime.tv_sec*1000000000 + currentTime.tv_nsec;
int64_t locationTimeNanos = in.timestamp*1000000;
LOC_LOGD("%s]: sinceBootTimeNanos:%" PRIi64 " currentTimeNanos:%" PRIi64 ""
" locationTimeNanos:%" PRIi64 "",
__FUNCTION__, sinceBootTimeNanos, currentTimeNanos, locationTimeNanos);
if (currentTimeNanos >= locationTimeNanos) {
int64_t ageTimeNanos = currentTimeNanos - locationTimeNanos;
LOC_LOGD("%s]: ageTimeNanos:%" PRIi64 ")", __FUNCTION__, ageTimeNanos);
if (ageTimeNanos >= 0 && ageTimeNanos <= sinceBootTimeNanos) {
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
out.elapsedRealtime.timestampNs = sinceBootTimeNanos - ageTimeNanos;
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
// time uncertainty is 1 ms since it is calculated from utc time that is in ms
out.elapsedRealtime.timeUncertaintyNs = 1000000;
LOC_LOGD("%s]: timestampNs:%" PRIi64 ")",
__FUNCTION__, out.elapsedRealtime.timestampNs);
}
}
}
}
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) {
out.flags |= LOCATION_HAS_LAT_LONG_BIT;
out.latitude = in.latitudeDegrees;
out.longitude = in.longitudeDegrees;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
out.flags |= LOCATION_HAS_ALTITUDE_BIT;
out.altitude = in.altitudeMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
out.flags |= LOCATION_HAS_SPEED_BIT;
out.speed = in.speedMetersPerSec;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
out.flags |= LOCATION_HAS_BEARING_BIT;
out.bearing = in.bearingDegrees;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
out.flags |= LOCATION_HAS_ACCURACY_BIT;
out.accuracy = in.horizontalAccuracyMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
out.verticalAccuracy = in.verticalAccuracyMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
out.speedAccuracy = in.speedAccuracyMetersPerSecond;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
out.bearingAccuracy = in.bearingAccuracyDegrees;
}
out.timestamp = static_cast<uint64_t>(in.timestamp);
}
void convertGnssLocation(const V2_0::GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
convertGnssLocation(in.v1_0, out);
}
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = V1_0::GnssConstellationType::GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = V1_0::GnssConstellationType::SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = V1_0::GnssConstellationType::GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = V1_0::GnssConstellationType::QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = V1_0::GnssConstellationType::BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = V1_0::GnssConstellationType::GALILEO;
break;
case GNSS_SV_TYPE_UNKNOWN:
default:
out = V1_0::GnssConstellationType::UNKNOWN;
break;
}
}
void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = V2_0::GnssConstellationType::GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = V2_0::GnssConstellationType::SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = V2_0::GnssConstellationType::GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = V2_0::GnssConstellationType::QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = V2_0::GnssConstellationType::BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = V2_0::GnssConstellationType::GALILEO;
break;
case GNSS_SV_TYPE_NAVIC:
out = V2_0::GnssConstellationType::IRNSS;
break;
case GNSS_SV_TYPE_UNKNOWN:
default:
out = V2_0::GnssConstellationType::UNKNOWN;
break;
}
}
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
{
switch(in) {
case GNSS_EPH_TYPE_EPHEMERIS:
out = GnssDebug::SatelliteEphemerisType::EPHEMERIS;
break;
case GNSS_EPH_TYPE_ALMANAC:
out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY;
break;
case GNSS_EPH_TYPE_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE;
break;
}
}
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out)
{
switch(in) {
case GNSS_EPH_SOURCE_DEMODULATED:
out = GnssDebug::SatelliteEphemerisSource::DEMODULATED;
break;
case GNSS_EPH_SOURCE_SUPL_PROVIDED:
out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED;
break;
case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED:
out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED;
break;
case GNSS_EPH_SOURCE_LOCAL:
case GNSS_EPH_SOURCE_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisSource::OTHER;
break;
}
}
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out)
{
switch(in) {
case GNSS_EPH_HEALTH_GOOD:
out = GnssDebug::SatelliteEphemerisHealth::GOOD;
break;
case GNSS_EPH_HEALTH_BAD:
out = GnssDebug::SatelliteEphemerisHealth::BAD;
break;
case GNSS_EPH_HEALTH_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN;
break;
}
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
static AGnss* spAGnss = nullptr;
@@ -107,7 +107,7 @@ Return<void> AGnss::setCallback(const sp<V2_0::IAGnssCallback>& callback) {
AgpsCbInfo cbInfo = {};
cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb;
cbInfo.cbPriority = AGPS_CB_PRIORITY_HIGH;
cbInfo.atlType = AGPS_ATL_TYPE_SUPL | AGPS_ATL_TYPE_SUPL_ES;
mGnss->getGnssInterface()->agpsInit(cbInfo);
return Void();
@@ -203,7 +203,7 @@ Return<bool> AGnss::setServer(V2_0::IAGnssCallback::AGnssType type,
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -28,7 +28,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
@@ -36,6 +36,7 @@ using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
using ::android::hardware::gnss::V2_0::IAGnssCallback;
struct Gnss;
struct AGnss : public V2_0::IAGnss {
@@ -65,11 +66,11 @@ struct AGnss : public V2_0::IAGnss {
private:
Gnss* mGnss = nullptr;
sp<IAGnssCallback> mAGnssCbIface = nullptr;
sp<V2_0::IAGnssCallback> mAGnssCbIface = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -36,7 +36,7 @@ typedef void* (getLocationInterface)();
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
@@ -127,7 +127,7 @@ Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttr
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -28,7 +28,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
@@ -76,7 +76,7 @@ struct AGnssRil : public V2_0::IAGnssRil {
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,7 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.gnss@2.0-impl-qti
LOCAL_MODULE := android.hardware.gnss@2.1-impl-qti
LOCAL_SANITIZE += $(GNSS_SANITIZE)
# activate the following line for debug purposes only, comment out for production
#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := \
@@ -14,8 +17,9 @@ LOCAL_SRC_FILES := \
GnssGeofencing.cpp \
GnssNi.cpp \
GnssDebug.cpp \
../measurement_corrections/1.0/MeasurementCorrections.cpp \
../visibility_control/1.0/GnssVisibilityControl.cpp
GnssAntennaInfo.cpp \
MeasurementCorrections.cpp \
GnssVisibilityControl.cpp
LOCAL_SRC_FILES += \
location_api/GnssAPIClient.cpp \
@@ -30,9 +34,8 @@ LOCAL_CFLAGS += \
endif
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/location_api \
$(LOCAL_PATH)/../measurement_corrections/1.0 \
$(LOCAL_PATH)/../visibility_control/1.0
$(LOCAL_PATH)/location_api
LOCAL_HEADER_LIBRARIES := \
libgps.utils_headers \
libloc_core_headers \
@@ -48,10 +51,13 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.gnss@1.0 \
android.hardware.gnss@1.1 \
android.hardware.gnss@2.0 \
android.hardware.gnss@2.1 \
android.hardware.gnss.measurement_corrections@1.0 \
android.hardware.gnss.measurement_corrections@1.1 \
android.hardware.gnss.visibility_control@1.0 \
android.hardware.health@1.0 \
android.hardware.health@2.0 \
android.hardware.health@2.1 \
android.hardware.power@1.2 \
libbase
@@ -67,11 +73,14 @@ LOCAL_STATIC_LIBRARIES += libhealthhalutils
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.gnss@2.0-service-qti
LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@2.0-service-qti.xml
LOCAL_MODULE := android.hardware.gnss@2.1-service-qti
LOCAL_SANITIZE += $(GNSS_SANITIZE)
# activate the following line for debug purposes only, comment out for production
#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@2.1-service-qti.xml
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_INIT_RC := android.hardware.gnss@2.0-service-qti.rc
LOCAL_INIT_RC := android.hardware.gnss@2.1-service-qti.rc
LOCAL_SRC_FILES := \
service.cpp \
@@ -96,6 +105,7 @@ LOCAL_SHARED_LIBRARIES += \
android.hardware.gnss@1.0 \
android.hardware.gnss@1.1 \
android.hardware.gnss@2.0 \
android.hardware.gnss@2.1 \
LOCAL_CFLAGS += $(GNSS_CFLAGS)

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,6 +28,7 @@
#include "Gnss.h"
#include "LocationUtil.h"
#include "battery_listener.h"
#include "loc_misc_utils.h"
typedef const GnssInterface* (getLocationInterface)();
@@ -37,10 +38,12 @@ typedef const GnssInterface* (getLocationInterface)();
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl;
using ::android::hardware::gnss::measurement_corrections::V1_1::
implementation::MeasurementCorrections;
static sp<Gnss> sGnss;
static std::string getVersionString() {
static std::string version;
@@ -96,6 +99,8 @@ void location_on_battery_status_changed(bool charging) {
Gnss::Gnss() {
ENTRY_LOG_CALLFLOW();
sGnss = this;
// initilize gnss interface at first in case needing notify battery status
sGnss->getGnssInterface()->initialize();
// register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig
@@ -106,7 +111,7 @@ Gnss::Gnss() {
Gnss::~Gnss() {
ENTRY_LOG_CALLFLOW();
if (mApi != nullptr) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
sGnss = nullptr;
@@ -117,7 +122,9 @@ GnssAPIClient* Gnss::getApi() {
return mApi;
}
if (mGnssCbIface_2_0 != nullptr) {
if (mGnssCbIface_2_1 != nullptr) {
mApi = new GnssAPIClient(mGnssCbIface_2_1);
} else if (mGnssCbIface_2_0 != nullptr) {
mApi = new GnssAPIClient(mGnssCbIface_2_0);
} else if (mGnssCbIface_1_1 != nullptr) {
mApi = new GnssAPIClient(mGnssCbIface_1_1, mGnssNiCbIface);
@@ -143,26 +150,14 @@ GnssAPIClient* Gnss::getApi() {
const GnssInterface* Gnss::getGnssInterface() {
static bool getGnssInterfaceFailed = false;
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
getLocationInterface* getter = NULL;
const char *error = NULL;
dlerror();
void *handle = dlopen("libgnss.so", RTLD_NOW);
if (NULL == handle || (error = dlerror()) != NULL) {
LOC_LOGW("dlopen for libgnss.so failed, error = %s", error);
} else {
getter = (getLocationInterface*)dlsym(handle, "getGnssInterface");
if ((error = dlerror()) != NULL) {
LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error);
getter = NULL;
}
}
if (mGnssInterface == nullptr && !getGnssInterfaceFailed) {
void * libHandle = nullptr;
getLocationInterface* getter = (getLocationInterface*)
dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
if (NULL == getter) {
getGnssInterfaceFailed = true;
} else {
mGnssInterface = (const GnssInterface*)(*getter)();
mGnssInterface = (GnssInterface*)(*getter)();
}
}
return mGnssInterface;
@@ -171,11 +166,12 @@ const GnssInterface* Gnss::getGnssInterface() {
Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
ENTRY_LOG_CALLFLOW();
// In case where previous call to setCallback_1_1 or setCallback_2_0, then
// In case where previous call to setCallback_1_1/setCallback_2_0/setCallback_2_1, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks_2_0(nullptr);
mApi->gnssUpdateCallbacks_2_1(nullptr);
}
if (mGnssCbIface_1_1 != nullptr) {
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
@@ -185,6 +181,10 @@ Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_0 = nullptr;
}
if (mGnssCbIface_2_1 != nullptr) {
mGnssCbIface_2_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_1 = nullptr;
}
if (mGnssCbIface != nullptr) {
@@ -244,7 +244,7 @@ Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) {
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
mPendingConfig.lppProfile = gnssConfig.lppProfile;
mPendingConfig.lppProfileMask = gnssConfig.lppProfileMask;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
@@ -328,14 +328,7 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
int32_t uncertaintyMs) {
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
return true;
} else {
return false;
}
return true;
}
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) {
@@ -376,38 +369,49 @@ Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
ENTRY_LOG_CALLFLOW();
if (mGnssMeasurement == nullptr)
if (mGnssMeasurement == nullptr) {
mGnssMeasurement = new GnssMeasurement();
}
return mGnssMeasurement;
}
Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
ENTRY_LOG_CALLFLOW();
mGnssConfig = new GnssConfiguration(this);
if (mGnssConfig == nullptr) {
mGnssConfig = new GnssConfiguration(this);
}
return mGnssConfig;
}
Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
ENTRY_LOG_CALLFLOW();
mGnssGeofencingIface = new GnssGeofencing();
if (mGnssGeofencingIface == nullptr) {
mGnssGeofencingIface = new GnssGeofencing();
}
return mGnssGeofencingIface;
}
Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
ENTRY_LOG_CALLFLOW();
mGnssBatching = new GnssBatching();
if (mGnssBatching == nullptr) {
mGnssBatching = new GnssBatching();
}
return mGnssBatching;
}
Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
ENTRY_LOG_CALLFLOW();
mGnssDebug = new GnssDebug(this);
if (mGnssDebug == nullptr) {
mGnssDebug = new GnssDebug(this);
}
return mGnssDebug;
}
Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
ENTRY_LOG_CALLFLOW();
mGnssRil = new AGnssRil(this);
if (mGnssRil == nullptr) {
mGnssRil = new AGnssRil(this);
}
return mGnssRil;
}
@@ -420,11 +424,12 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
__func__, r.description().c_str());
}
// In case where previous call to setCallback or setCallback_2_1, then
// In case where previous call to setCallback/setCallback_2_0/setCallback_2_1, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks_2_0(nullptr);
mApi->gnssUpdateCallbacks_2_1(nullptr);
}
if (mGnssCbIface != nullptr) {
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
@@ -434,6 +439,10 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_0 = nullptr;
}
if (mGnssCbIface_2_1 != nullptr) {
mGnssCbIface_2_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_1 = nullptr;
}
if (mGnssCbIface_1_1 != nullptr) {
@@ -449,7 +458,7 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
odcpiRequestCb(odcpiRequest);
};
gnssInterface->odcpiInit(cb);
gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW);
}
GnssAPIClient* api = getApi();
@@ -511,8 +520,23 @@ Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
ENTRY_LOG_CALLFLOW();
if (mGnssCbIface_2_0 != nullptr) {
if (ODCPI_REQUEST_TYPE_STOP == request.type) {
return;
}
if (mGnssCbIface_2_1 != nullptr) {
// For emergency mode, request DBH (Device based hybrid) location
// Mark Independent from GNSS flag to false.
if (ODCPI_REQUEST_TYPE_START == request.type) {
LOC_LOGd("gnssRequestLocationCb_2_1 isUserEmergency = %d", request.isEmergencyMode);
auto r = mGnssCbIface_2_1->gnssRequestLocationCb_2_0(!request.isEmergencyMode,
request.isEmergencyMode);
if (!r.isOk()) {
LOC_LOGe("Error invoking gnssRequestLocationCb_2_0 %s", r.description().c_str());
}
} else {
LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
}
} else if (mGnssCbIface_2_0 != nullptr) {
// For emergency mode, request DBH (Device based hybrid) location
// Mark Independent from GNSS flag to false.
if (ODCPI_REQUEST_TYPE_START == request.type) {
@@ -550,11 +574,12 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
__func__, r.description().c_str());
}
// In case where previous call to setCallback or setCallback_1_1, then
// In case where previous call to setCallback/setCallback_1_1/setCallback_2_1, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks(nullptr, nullptr);
mApi->gnssUpdateCallbacks_2_1(nullptr);
}
mGnssNiCbIface = nullptr;
if (mGnssCbIface != nullptr) {
@@ -565,6 +590,11 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_1_1 = nullptr;
}
if (mGnssCbIface_2_1 != nullptr) {
mGnssCbIface_2_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_1 = nullptr;
}
if (mGnssCbIface_2_0 != nullptr) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
@@ -579,7 +609,7 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
odcpiRequestCb(odcpiRequest);
};
gnssInterface->odcpiInit(cb);
gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW);
}
GnssAPIClient* api = getApi();
@@ -594,17 +624,24 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() {
ENTRY_LOG_CALLFLOW();
mAGnssIface_2_0 = new AGnss(this);
if (mAGnssIface_2_0 == nullptr) {
mAGnssIface_2_0 = new AGnss(this);
}
return mAGnssIface_2_0;
}
Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
mGnssRil = new AGnssRil(this);
if (mGnssRil == nullptr) {
mGnssRil = new AGnssRil(this);
}
return mGnssRil;
}
Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() {
ENTRY_LOG_CALLFLOW();
mGnssConfig = new GnssConfiguration(this);
if (mGnssConfig == nullptr) {
mGnssConfig = new GnssConfiguration(this);
}
return mGnssConfig;
}
Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
@@ -617,11 +654,25 @@ Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
return mGnssMeasurement;
#endif
}
Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections>>
Return<sp<IMeasurementCorrectionsV1_0>>
Gnss::getExtensionMeasurementCorrections() {
// We do not support, so return nullptr to pass VTS
return nullptr;
ENTRY_LOG_CALLFLOW();
if (mGnssMeasCorr == nullptr) {
mGnssMeasCorr = new MeasurementCorrections(this);
}
return mGnssMeasCorr;
}
Return<sp<IMeasurementCorrectionsV1_1>>
Gnss::getExtensionMeasurementCorrections_1_1() {
ENTRY_LOG_CALLFLOW();
if (mGnssMeasCorr == nullptr) {
mGnssMeasCorr = new MeasurementCorrections(this);
}
return mGnssMeasCorr;
}
Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>>
Gnss::getExtensionVisibilityControl() {
ENTRY_LOG_CALLFLOW();
@@ -644,14 +695,91 @@ Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation
Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() {
ENTRY_LOG_CALLFLOW();
mGnssDebug = new GnssDebug(this);
if (mGnssDebug == nullptr) {
mGnssDebug = new GnssDebug(this);
}
return mGnssDebug;
}
Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() {
return nullptr;
}
// Methods from ::android::hardware::gnss::V2_1::IGnss follow.
Return<bool> Gnss::setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) {
ENTRY_LOG_CALLFLOW();
mGnssBatching = new GnssBatching();
return mGnssBatching;
auto r = callback->gnssNameCb(getVersionString());
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssNameCb description=%s",
__func__, r.description().c_str());
}
// In case where previous call to setCallback/setCallback_1_1/setCallback_2_0, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks(nullptr, nullptr);
mApi->gnssUpdateCallbacks_2_0(nullptr);
}
mGnssNiCbIface = nullptr;
if (mGnssCbIface != nullptr) {
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface = nullptr;
}
if (mGnssCbIface_1_1 != nullptr) {
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_1_1 = nullptr;
}
if (mGnssCbIface_2_0 != nullptr) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_0 = nullptr;
}
if (mGnssCbIface_2_1 != nullptr) {
mGnssCbIface_2_1->unlinkToDeath(mGnssDeathRecipient);
}
mGnssCbIface_2_1 = callback;
if (mGnssCbIface_2_1 != nullptr) {
mGnssCbIface_2_1->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
}
const GnssInterface* gnssInterface = getGnssInterface();
if (gnssInterface != nullptr) {
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
odcpiRequestCb(odcpiRequest);
};
gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW);
}
GnssAPIClient* api = getApi();
if (api != nullptr) {
api->gnssUpdateCallbacks_2_1(mGnssCbIface_2_1);
api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
api->requestCapabilities();
}
return true;
}
Return<sp<V2_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_1() {
ENTRY_LOG_CALLFLOW();
if (mGnssMeasurement == nullptr) {
mGnssMeasurement = new GnssMeasurement();
}
return mGnssMeasurement;
}
Return<sp<V2_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_1() {
ENTRY_LOG_CALLFLOW();
if (mGnssConfig == nullptr) {
mGnssConfig = new GnssConfiguration(this);
}
return mGnssConfig;
}
Return<sp<V2_1::IGnssAntennaInfo>> Gnss::getExtensionGnssAntennaInfo() {
ENTRY_LOG_CALLFLOW();
if (mGnssAntennaInfo == nullptr) {
mGnssAntennaInfo = new GnssAntennaInfo(this);
}
return mGnssAntennaInfo;
}
V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
@@ -665,7 +793,7 @@ V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,8 +18,8 @@
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSS_H
#define ANDROID_HARDWARE_GNSS_V2_1_GNSS_H
#include <AGnss.h>
#include <AGnssRil.h>
@@ -29,8 +29,10 @@
#include <GnssGeofencing.h>
#include <GnssNi.h>
#include <GnssDebug.h>
#include <GnssAntennaInfo.h>
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.1/IGnss.h>
#include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h>
#include <MeasurementCorrections.h>
#include <GnssVisibilityControl.h>
#include <hidl/MQDescriptor.h>
@@ -41,7 +43,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::hidl_array;
@@ -52,14 +54,17 @@ using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
using ::android::hardware::gnss::measurement_corrections::V1_0::implementation::MeasurementCorrections;
using IMeasurementCorrectionsV1_0 =
::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
using IMeasurementCorrectionsV1_1 =
::android::hardware::gnss::measurement_corrections::V1_1::IMeasurementCorrections;
using ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl;
struct Gnss : public IGnss {
Gnss();
~Gnss();
/*
* Methods from ::android::hardware::gnss::V1_0::IGnss follow.
* These declarations were generated from Gnss.hal.
@@ -115,24 +120,23 @@ struct Gnss : public IGnss {
Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override;
Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections>>
getExtensionMeasurementCorrections() override;
Return<sp<IMeasurementCorrectionsV1_0>> getExtensionMeasurementCorrections() override;
Return<sp<IMeasurementCorrectionsV1_1>> getExtensionMeasurementCorrections_1_1() override;
Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
Return<bool> injectBestLocation_2_0(const ::android::hardware::gnss::V2_0::GnssLocation& location) override;
Return<bool> injectBestLocation_2_0(
const ::android::hardware::gnss::V2_0::GnssLocation& location) override;
Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override;
Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override;
/**
* This method returns the IGnssVisibilityControl interface.
*
* @return visibilityControlIface Handle to the IGnssVisibilityControl interface.
*/
Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>>
getExtensionVisibilityControl() override;
// Methods from ::android::hardware::gnss::V2_1::IGnss follow.
Return<bool> setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) override;
Return<sp<V2_1::IGnssMeasurement>> getExtensionGnssMeasurement_2_1() override;
Return<sp<V2_1::IGnssConfiguration>> getExtensionGnssConfiguration_2_1() override;
Return<sp<V2_1::IGnssAntennaInfo>> getExtensionGnssAntennaInfo() override;
// These methods are not part of the IGnss base class.
GnssAPIClient* getApi();
@@ -163,12 +167,14 @@ struct Gnss : public IGnss {
sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
sp<V2_0::IAGnss> mAGnssIface_2_0 = nullptr;
sp<V2_0::IAGnssRil> mGnssRil = nullptr;
sp<V2_0::IGnssMeasurement> mGnssMeasurement = nullptr;
sp<V2_0::IGnssConfiguration> mGnssConfig = nullptr;
sp<V2_0::IGnssBatching> mGnssBatching = nullptr;
sp<V2_0::IGnssDebug> mGnssDebug = nullptr;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0 = nullptr;
sp<IMeasurementCorrections> mGnssMeasCorr = nullptr;
sp<V2_1::IGnssCallback> mGnssCbIface_2_1 = nullptr;
sp<V2_1::IGnssMeasurement> mGnssMeasurement = nullptr;
sp<V2_1::IGnssConfiguration> mGnssConfig = nullptr;
sp<V2_1::IGnssAntennaInfo> mGnssAntennaInfo = nullptr;
sp<IMeasurementCorrectionsV1_1> mGnssMeasCorr = nullptr;
sp<IGnssVisibilityControl> mVisibCtrl = nullptr;
GnssAPIClient* mApi = nullptr;
@@ -179,9 +185,9 @@ struct Gnss : public IGnss {
extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
#endif // ANDROID_HARDWARE_GNSS_V2_1_GNSS_H

View File

@@ -0,0 +1,202 @@
/*
* 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_GnssAntennaInfoInterface"
#include <log_util.h>
#include "Gnss.h"
#include "GnssAntennaInfo.h"
#include <android/hardware/gnss/1.0/types.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_1 {
namespace implementation {
static GnssAntennaInfo* spGnssAntennaInfo = nullptr;
static void convertGnssAntennaInfo(std::vector<GnssAntennaInformation>& in,
hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& antennaInfos);
void GnssAntennaInfo::GnssAntennaInfoDeathRecipient::serviceDied(uint64_t cookie,
const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
// we do nothing here
// Gnss::GnssDeathRecipient will stop the session
// However, we need to inform the adapter that the service has died
if (nullptr == spGnssAntennaInfo) {
LOC_LOGE("%s]: spGnssAntennaInfo is nullptr", __FUNCTION__);
return;
}
if (nullptr == spGnssAntennaInfo->mGnss) {
LOC_LOGE("%s]: spGnssAntennaInfo->mGnss is nullptr", __FUNCTION__);
return;
}
spGnssAntennaInfo->mGnss->getGnssInterface()->antennaInfoClose();
}
static void convertGnssAntennaInfo(std::vector<GnssAntennaInformation>& in,
hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& out) {
uint32_t vecSize, numberOfRows, numberOfColumns;
vecSize = in.size();
out.resize(vecSize);
for (uint32_t i = 0; i < vecSize; i++) {
out[i].carrierFrequencyMHz = in[i].carrierFrequencyMHz;
out[i].phaseCenterOffsetCoordinateMillimeters.x =
in[i].phaseCenterOffsetCoordinateMillimeters.x;
out[i].phaseCenterOffsetCoordinateMillimeters.xUncertainty =
in[i].phaseCenterOffsetCoordinateMillimeters.xUncertainty;
out[i].phaseCenterOffsetCoordinateMillimeters.y =
in[i].phaseCenterOffsetCoordinateMillimeters.y;
out[i].phaseCenterOffsetCoordinateMillimeters.yUncertainty =
in[i].phaseCenterOffsetCoordinateMillimeters.yUncertainty;
out[i].phaseCenterOffsetCoordinateMillimeters.z =
in[i].phaseCenterOffsetCoordinateMillimeters.z;
out[i].phaseCenterOffsetCoordinateMillimeters.zUncertainty =
in[i].phaseCenterOffsetCoordinateMillimeters.zUncertainty;
numberOfRows = in[i].phaseCenterVariationCorrectionMillimeters.size();
out[i].phaseCenterVariationCorrectionMillimeters.resize(numberOfRows);
for (uint32_t j = 0; j < numberOfRows; j++) {
numberOfColumns = in[i].phaseCenterVariationCorrectionMillimeters[j].size();
out[i].phaseCenterVariationCorrectionMillimeters[j].row.resize(numberOfColumns);
for (uint32_t k = 0; k < numberOfColumns; k++) {
out[i].phaseCenterVariationCorrectionMillimeters[j].row[k] =
in[i].phaseCenterVariationCorrectionMillimeters[j][k];
}
}
numberOfRows = in[i].phaseCenterVariationCorrectionUncertaintyMillimeters.size();
out[i].phaseCenterVariationCorrectionUncertaintyMillimeters.resize(numberOfRows);
for (uint32_t j = 0; j < numberOfRows; j++) {
numberOfColumns = in[i].phaseCenterVariationCorrectionUncertaintyMillimeters[j].size();
out[i].phaseCenterVariationCorrectionUncertaintyMillimeters[j].
row.resize(numberOfColumns);
for (uint32_t k = 0; k < numberOfColumns; k++) {
out[i].phaseCenterVariationCorrectionUncertaintyMillimeters[j].row[k] =
in[i].phaseCenterVariationCorrectionUncertaintyMillimeters[j][k];
}
}
numberOfRows = in[i].signalGainCorrectionDbi.size();
out[i].signalGainCorrectionDbi.resize(numberOfRows);
for (uint32_t j = 0; j < numberOfRows; j++) {
numberOfColumns = in[i].signalGainCorrectionDbi[j].size();
out[i].signalGainCorrectionDbi[j].row.resize(numberOfColumns);
for (uint32_t k = 0; k < numberOfColumns; k++) {
out[i].signalGainCorrectionDbi[j].row[k] = in[i].signalGainCorrectionDbi[j][k];
}
}
numberOfRows = in[i].signalGainCorrectionUncertaintyDbi.size();
out[i].signalGainCorrectionUncertaintyDbi.resize(numberOfRows);
for (uint32_t j = 0; j < numberOfRows; j++) {
numberOfColumns = in[i].signalGainCorrectionUncertaintyDbi[j].size();
out[i].signalGainCorrectionUncertaintyDbi[j].row.resize(numberOfColumns);
for (uint32_t k = 0; k < numberOfColumns; k++) {
out[i].signalGainCorrectionUncertaintyDbi[j].row[k] =
in[i].signalGainCorrectionUncertaintyDbi[j][k];
}
}
}
}
GnssAntennaInfo::GnssAntennaInfo(Gnss* gnss) : mGnss(gnss) {
mGnssAntennaInfoDeathRecipient = new GnssAntennaInfoDeathRecipient(this);
spGnssAntennaInfo = this;
}
GnssAntennaInfo::~GnssAntennaInfo() {
spGnssAntennaInfo = nullptr;
}
// Methods from ::android::hardware::gnss::V2_1::IGnssAntennaInfo follow.
Return<GnssAntennaInfo::GnssAntennaInfoStatus>
GnssAntennaInfo::setCallback(const sp<IGnssAntennaInfoCallback>& callback) {
uint32_t retValue;
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return GnssAntennaInfoStatus::ERROR_GENERIC;
}
mGnssAntennaInfoCbIface = callback;
retValue = mGnss->getGnssInterface()->antennaInfoInit(aiGnssAntennaInfoCb);
switch (retValue) {
case ANTENNA_INFO_SUCCESS: return GnssAntennaInfoStatus::SUCCESS;
case ANTENNA_INFO_ERROR_ALREADY_INIT: return GnssAntennaInfoStatus::ERROR_ALREADY_INIT;
case ANTENNA_INFO_ERROR_GENERIC:
default: return GnssAntennaInfoStatus::ERROR_GENERIC;
}
}
Return<void> GnssAntennaInfo::close(void) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return Void();
}
mGnss->getGnssInterface()->antennaInfoClose();
return Void();
}
void GnssAntennaInfo::aiGnssAntennaInfoCb
(std::vector<GnssAntennaInformation> gnssAntennaInformations) {
if (nullptr != spGnssAntennaInfo) {
spGnssAntennaInfo->gnssAntennaInfoCb(gnssAntennaInformations);
}
}
void GnssAntennaInfo::gnssAntennaInfoCb
(std::vector<GnssAntennaInformation> gnssAntennaInformations) {
if (mGnssAntennaInfoCbIface != nullptr) {
hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo> antennaInfos;
// Convert from one structure to another
convertGnssAntennaInfo(gnssAntennaInformations, antennaInfos);
auto r = mGnssAntennaInfoCbIface->gnssAntennaInfoCb(antennaInfos);
if (!r.isOk()) {
LOC_LOGw("Error antenna info cb %s", r.description().c_str());
}
} else {
LOC_LOGw("setCallback has not been called yet");
}
}
} // namespace implementation
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* 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
@@ -27,50 +27,64 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#define ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrectionsCallback.h>
#include <hidl/MQDescriptor.h>
#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H
#define ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H
#include <android/hardware/gnss/2.1/IGnssAntennaInfo.h>
#include <hidl/Status.h>
#include <location_interface.h>
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::gnss::V2_1::IGnssAntennaInfo;
using ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
struct MeasurementCorrections : public IMeasurementCorrections {
MeasurementCorrections();
~MeasurementCorrections();
struct Gnss;
struct GnssAntennaInfo : public IGnssAntennaInfo {
GnssAntennaInfo(Gnss* gnss);
~GnssAntennaInfo();
// Methods from ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections follow.
Return<bool> setCorrections(const ::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections& corrections) override;
/*
* Methods from ::android::hardware::gnss::V1_1::IGnssAntennaInfo follow.
* These declarations were generated from IGnssAntennaInfo.hal.
*/
Return<GnssAntennaInfoStatus>
setCallback(const sp<IGnssAntennaInfoCallback>& callback) override;
Return<void> close(void) override;
Return<bool> setCallback(const sp<IMeasurementCorrectionsCallback>& callback) override;
void gnssAntennaInfoCb(std::vector<GnssAntennaInformation> gnssAntennaInformations);
static void aiGnssAntennaInfoCb(std::vector<GnssAntennaInformation> gnssAntennaInformations);
private:
struct GnssAntennaInfoDeathRecipient : hidl_death_recipient {
GnssAntennaInfoDeathRecipient(sp<GnssAntennaInfo> gnssAntennaInfo) :
mGnssAntennaInfo(gnssAntennaInfo) {
}
~GnssAntennaInfoDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<GnssAntennaInfo> mGnssAntennaInfo;
};
private:
sp<GnssAntennaInfoDeathRecipient> mGnssAntennaInfoDeathRecipient = nullptr;
sp<IGnssAntennaInfoCallback> mGnssAntennaInfoCbIface = nullptr;
Gnss* mGnss = nullptr;
};
} // namespace implementation
} // namespace V1_0
} // namespace measurement_corrections
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
@@ -46,7 +46,7 @@ GnssBatching::GnssBatching() : mApi(nullptr) {
GnssBatching::~GnssBatching() {
if (mApi != nullptr) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
}
@@ -56,7 +56,7 @@ GnssBatching::~GnssBatching() {
Return<bool> GnssBatching::init(const sp<V1_0::IGnssBatchingCallback>& callback) {
if (mApi != nullptr) {
LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
delete mApi;
mApi->destroy();
mApi = nullptr;
}
@@ -135,7 +135,7 @@ Return<void> GnssBatching::cleanup() {
Return<bool> GnssBatching::init_2_0(const sp<V2_0::IGnssBatchingCallback>& callback) {
if (mApi != nullptr) {
LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
delete mApi;
mApi->destroy();
mApi = nullptr;
}
@@ -157,7 +157,7 @@ Return<bool> GnssBatching::init_2_0(const sp<V2_0::IGnssBatchingCallback>& callb
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -28,7 +28,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnssBatching;
@@ -76,7 +76,7 @@ struct GnssBatching : public IGnssBatching {
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,10 +29,10 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V1_0::GnssConstellationType;
using ::android::hardware::gnss::V2_0::GnssConstellationType;
using namespace loc_core;
GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) {
@@ -55,6 +55,9 @@ Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
switch (version) {
case 0x00020004:
config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4;
break;
case 0x00020002:
config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2;
break;
@@ -67,7 +70,6 @@ Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
default:
LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version);
return false;
break;
}
return mGnss->updateConfiguration(config);
@@ -99,13 +101,12 @@ Return<bool> GnssConfiguration::setSuplMode(uint8_t mode) {
default:
LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode);
return false;
break;
}
return mGnss->updateConfiguration(config);
}
Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfileMask) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
@@ -114,23 +115,19 @@ Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
GnssConfig config = {};
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
switch (lppProfile) {
case 0:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE;
break;
case 1:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_USER_PLANE;
break;
case 2:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE;
break;
case 3:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE;
break;
default:
LOC_LOGE("%s]: invalid lppProfile: %d.", __FUNCTION__, lppProfile);
return false;
break;
config.lppProfileMask = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; //default
if (lppProfileMask & (1<<0)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_BIT;
}
if (lppProfileMask & (1<<1)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_BIT;
}
if (lppProfileMask & (1<<2)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_OVER_NR5G_SA_BIT;
}
if (lppProfileMask & (1<<3)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_OVER_NR5G_SA_BIT;
}
return mGnss->updateConfiguration(config);
@@ -189,7 +186,6 @@ Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
default:
LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock);
return false;
break;
}
mGnss->updateConfiguration(config);
@@ -216,7 +212,7 @@ Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setBlacklist(
const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) {
const hidl_vec<V1_1::IGnssConfiguration::BlacklistedSource>& blacklist) {
ENTRY_LOG_CALLFLOW();
if (nullptr == mGnss) {
@@ -238,7 +234,8 @@ Return<bool> GnssConfiguration::setBlacklist(
GnssSvIdSource source = {};
for (int idx = 0; idx < (int)blacklist.size(); idx++) {
// Set blValid true if any one source is valid
blValid = setBlacklistedSource(source, blacklist[idx]) || blValid;
blValid = setBlacklistedSource(source, (GnssConstellationType)blacklist[idx].constellation,
blacklist[idx].svid) || blValid;
config.blacklistedSvIds.push_back(source);
}
@@ -247,6 +244,60 @@ Return<bool> GnssConfiguration::setBlacklist(
return (blValid && mGnss->updateConfiguration(config));
}
bool GnssConfiguration::setBlacklistedSource(
GnssSvIdSource& copyToSource, const GnssConstellationType& constellation,
const int16_t svid) {
bool retVal = true;
uint16_t svIdOffset = 0;
copyToSource.size = sizeof(GnssSvIdSource);
copyToSource.svId = svid;
switch(constellation) {
case GnssConstellationType::GPS:
copyToSource.constellation = GNSS_SV_TYPE_GPS;
LOC_LOGe("GPS SVs can't be blacklisted.");
retVal = false;
break;
case GnssConstellationType::SBAS:
copyToSource.constellation = GNSS_SV_TYPE_SBAS;
LOC_LOGe("SBAS SVs can't be blacklisted.");
retVal = false;
break;
case GnssConstellationType::GLONASS:
copyToSource.constellation = GNSS_SV_TYPE_GLONASS;
svIdOffset = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::QZSS:
copyToSource.constellation = GNSS_SV_TYPE_QZSS;
svIdOffset = 0;
break;
case GnssConstellationType::BEIDOU:
copyToSource.constellation = GNSS_SV_TYPE_BEIDOU;
svIdOffset = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::GALILEO:
copyToSource.constellation = GNSS_SV_TYPE_GALILEO;
svIdOffset = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::IRNSS:
copyToSource.constellation = GNSS_SV_TYPE_NAVIC;
svIdOffset = 0;
break;
default:
copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN;
LOC_LOGe("Invalid constellation %hhu", constellation);
retVal = false;
break;
}
if (copyToSource.svId > 0 && svIdOffset > 0) {
copyToSource.svId += svIdOffset;
}
return retVal;
}
bool GnssConfiguration::setBlacklistedSource(
GnssSvIdSource& copyToSource,
const GnssConfiguration::BlacklistedSource& copyFromSource) {
@@ -273,7 +324,7 @@ bool GnssConfiguration::setBlacklistedSource(
break;
case GnssConstellationType::QZSS:
copyToSource.constellation = GNSS_SV_TYPE_QZSS;
svIdOffset = 0;
svIdOffset = GNSS_SV_CONFIG_QZSS_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::BEIDOU:
copyToSource.constellation = GNSS_SV_TYPE_BEIDOU;
@@ -283,6 +334,10 @@ bool GnssConfiguration::setBlacklistedSource(
copyToSource.constellation = GNSS_SV_TYPE_GALILEO;
svIdOffset = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::IRNSS:
copyToSource.constellation = GNSS_SV_TYPE_NAVIC;
svIdOffset = GNSS_SV_CONFIG_NAVIC_INITIAL_SV_ID - 1;
break;
default:
copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN;
LOC_LOGe("Invalid constellation %hhu", copyFromSource.constellation);
@@ -314,8 +369,40 @@ Return<bool> GnssConfiguration::setEsExtensionSec(uint32_t emergencyExtensionSec
return mGnss->updateConfiguration(config);
}
// Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setBlacklist_2_1(
const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& blacklist) {
ENTRY_LOG_CALLFLOW();
if (nullptr == mGnss) {
LOC_LOGe("mGnss is null");
return false;
}
// blValid is true if blacklist is empty, i.e. clearing the BL;
// if blacklist is not empty, blValid is initialied to false, and later
// updated in the for loop to become true only if there is at least
// one {constellation, svid} in the list that is valid.
bool blValid = (0 == blacklist.size());
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
config.blacklistedSvIds.clear();
GnssSvIdSource source = {};
for (int idx = 0; idx < (int)blacklist.size(); idx++) {
// Set blValid true if any one source is valid
blValid = setBlacklistedSource(source, blacklist[idx]) || blValid;
config.blacklistedSvIds.push_back(source);
}
// Update configuration only if blValid is true
// i.e. only if atleast one source is valid for blacklisting
return (blValid && mGnss->updateConfiguration(config));
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,32 +19,34 @@
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
#define ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
#include <android/hardware/gnss/2.0/IGnssConfiguration.h>
#include <android/hardware/gnss/2.1/IGnssConfiguration.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::hardware::gnss::V2_0::GnssConstellationType;
using ::android::sp;
/*
* Interface for passing GNSS configuration info from platform to HAL.
*/
struct Gnss;
struct GnssConfiguration : public V2_0::IGnssConfiguration {
struct GnssConfiguration : public V2_1::IGnssConfiguration {
GnssConfiguration(Gnss* gnss);
~GnssConfiguration() = default;
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
* These declarations were generated from IGnssConfiguration.hal.
@@ -52,29 +54,35 @@ struct GnssConfiguration : public V2_0::IGnssConfiguration {
Return<bool> setSuplVersion(uint32_t version) override;
Return<bool> setSuplMode(uint8_t mode) override;
Return<bool> setSuplEs(bool enabled) override;
Return<bool> setLppProfile(uint8_t lppProfile) override;
Return<bool> setLppProfile(uint8_t lppProfileMask) override;
Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
Return<bool> setEmergencySuplPdn(bool enable) override;
Return<bool> setGpsLock(uint8_t lock) override;
// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
Return<bool> setBlacklist(
const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) override;
const hidl_vec<V1_1::IGnssConfiguration::BlacklistedSource>& blacklist) override;
// Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow.
Return<bool> setEsExtensionSec(uint32_t emergencyExtensionSeconds) override;
// Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow.
Return<bool> setBlacklist_2_1(
const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& blacklist) override;
private:
Gnss* mGnss = nullptr;
bool setBlacklistedSource(
GnssSvIdSource& copyToSource,
const GnssConfiguration::BlacklistedSource& copyFromSource);
bool setBlacklistedSource(
GnssSvIdSource& copyToSource, const GnssConstellationType& constellation,
const int16_t svid);
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
#endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -29,7 +29,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::hidl_vec;
@@ -293,7 +293,7 @@ Return<void> GnssDebug::getDebugData_2_0(getDebugData_2_0_cb _hidl_cb)
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -28,7 +28,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnssDebug;
@@ -54,7 +54,7 @@ private:
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
@@ -45,7 +45,7 @@ GnssGeofencing::GnssGeofencing() : mApi(nullptr) {
GnssGeofencing::~GnssGeofencing() {
if (mApi != nullptr) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
}
@@ -135,7 +135,7 @@ Return<void> GnssGeofencing::removeAllGeofences() {
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
@@ -83,7 +83,7 @@ struct GnssGeofencing : public IGnssGeofencing {
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
@@ -46,7 +46,7 @@ GnssMeasurement::GnssMeasurement() {
GnssMeasurement::~GnssMeasurement() {
if (mApi) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
}
@@ -71,18 +71,15 @@ Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
return ret;
}
clearInterfaces();
mGnssMeasurementCbIface = callback;
mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0);
return mApi->measurementSetCallback(callback);
}
Return<void> GnssMeasurement::close() {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return Void();
}
void GnssMeasurement::clearInterfaces() {
if (mGnssMeasurementCbIface != nullptr) {
mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface = nullptr;
@@ -95,6 +92,19 @@ Return<void> GnssMeasurement::close() {
mGnssMeasurementCbIface_2_0->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface_2_0 = nullptr;
}
if (mGnssMeasurementCbIface_2_1 != nullptr) {
mGnssMeasurementCbIface_2_1->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface_2_1 = nullptr;
}
}
Return<void> GnssMeasurement::close() {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return Void();
}
clearInterfaces();
mApi->measurementClose();
return Void();
@@ -120,6 +130,8 @@ Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_1_1(
return ret;
}
clearInterfaces();
mGnssMeasurementCbIface_1_1 = callback;
mGnssMeasurementCbIface_1_1->linkToDeath(mGnssMeasurementDeathRecipient, 0);
@@ -149,6 +161,8 @@ Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallba
return ret;
}
clearInterfaces();
mGnssMeasurementCbIface_2_0 = callback;
mGnssMeasurementCbIface_2_0->linkToDeath(mGnssMeasurementDeathRecipient, 0);
@@ -158,8 +172,40 @@ Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallba
return mApi->measurementSetCallback_2_0(callback, powerMode);
}
// Methods from ::android::hardware::gnss::V2_1::IGnssMeasurement follow.
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_2_1(
const sp<::android::hardware::gnss::V2_1::IGnssMeasurementCallback>& callback,
bool enableFullTracking) {
Return<GnssMeasurement::GnssMeasurementStatus> ret =
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
if (mGnssMeasurementCbIface_2_1 != nullptr) {
LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__);
return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT;
}
if (callback == nullptr) {
LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
return ret;
}
if (nullptr == mApi) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return ret;
}
clearInterfaces();
mGnssMeasurementCbIface_2_1 = callback;
mGnssMeasurementCbIface_2_1->linkToDeath(mGnssMeasurementDeathRecipient, 0);
GnssPowerMode powerMode = enableFullTracking ?
GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2;
return mApi->measurementSetCallback_2_1(callback, powerMode);
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,17 +18,17 @@
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSMEASUREMENT_H
#define ANDROID_HARDWARE_GNSS_V2_1_GNSSMEASUREMENT_H
#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
#include <android/hardware/gnss/2.1/IGnssMeasurement.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
@@ -38,7 +38,7 @@ using ::android::hardware::hidl_string;
using ::android::sp;
class MeasurementAPIClient;
struct GnssMeasurement : public V2_0::IGnssMeasurement {
struct GnssMeasurement : public V2_1::IGnssMeasurement {
GnssMeasurement();
~GnssMeasurement();
@@ -46,19 +46,24 @@ struct GnssMeasurement : public V2_0::IGnssMeasurement {
* Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
* These declarations were generated from IGnssMeasurement.hal.
*/
Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) override;
Return<void> close() override;
// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
const sp<V1_1::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
// Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
const sp<V2_0::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
// Methods from ::android::hardware::gnss::V2_1::IGnssMeasurement follow.
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> setCallback_2_1(
const sp<::android::hardware::gnss::V2_1::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
private:
struct GnssMeasurementDeathRecipient : hidl_death_recipient {
GnssMeasurementDeathRecipient(sp<GnssMeasurement> gnssMeasurement) :
@@ -74,13 +79,15 @@ struct GnssMeasurement : public V2_0::IGnssMeasurement {
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0 = nullptr;
sp<V2_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_1 = nullptr;
MeasurementAPIClient* mApi;
void clearInterfaces();
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSMEASUREMENT_H

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
@@ -79,7 +79,7 @@ Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseT
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssNi;
@@ -67,7 +67,7 @@ struct GnssNi : public IGnssNi {
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -52,7 +52,7 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V2_0::implementation::Gnss;
using ::android::hardware::gnss::V2_1::implementation::Gnss;
struct GnssVisibilityControl : public IGnssVisibilityControl {
GnssVisibilityControl(Gnss* gnss);

View File

@@ -0,0 +1,199 @@
/*
* 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_MeasurementCorrectionsInterface"
#include <log_util.h>
#include "MeasurementCorrections.h"
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_1 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
using MeasurementCorrectionsV1_0 =
::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections;
using MeasurementCorrectionsV1_1 =
::android::hardware::gnss::measurement_corrections::V1_1::MeasurementCorrections;
static MeasurementCorrections* spMeasurementCorrections = nullptr;
void MeasurementCorrections::GnssMeasurementCorrectionsDeathRecipient::serviceDied(uint64_t cookie,
const wp<IBase>& who) {
LOC_LOGe("service died. cookie: %llu, who: %p", static_cast<unsigned long long>(cookie), &who);
// Gnss::GnssDeathrecipient will stop the session
// we inform the adapter that service has died
if (nullptr == spMeasurementCorrections) {
LOC_LOGe("spMeasurementCorrections is nullptr");
return;
}
if (nullptr == spMeasurementCorrections->mGnss ||
nullptr == spMeasurementCorrections->mGnss->getGnssInterface()) {
LOC_LOGe("Null GNSS interface");
return;
}
spMeasurementCorrections->mGnss->getGnssInterface()->measCorrClose();
}
MeasurementCorrections::MeasurementCorrections(Gnss* gnss) : mGnss(gnss) {
mGnssMeasurementCorrectionsDeathRecipient = new GnssMeasurementCorrectionsDeathRecipient(this);
spMeasurementCorrections = this;
}
MeasurementCorrections::~MeasurementCorrections() {
spMeasurementCorrections = nullptr;
}
void MeasurementCorrections::measCorrSetCapabilitiesCb(
GnssMeasurementCorrectionsCapabilitiesMask capabilities) {
if (nullptr != spMeasurementCorrections) {
spMeasurementCorrections->setCapabilitiesCb(capabilities);
}
}
void MeasurementCorrections::setCapabilitiesCb(
GnssMeasurementCorrectionsCapabilitiesMask capabilities) {
if (mMeasurementCorrectionsCbIface != nullptr) {
uint32_t measCorrCapabilities = 0;
// Convert from one enum to another
if (capabilities & GNSS_MEAS_CORR_LOS_SATS) {
measCorrCapabilities |=
IMeasurementCorrectionsCallback::Capabilities::LOS_SATS;
}
if (capabilities & GNSS_MEAS_CORR_EXCESS_PATH_LENGTH) {
measCorrCapabilities |=
IMeasurementCorrectionsCallback::Capabilities::EXCESS_PATH_LENGTH;
}
if (capabilities & GNSS_MEAS_CORR_REFLECTING_PLANE) {
measCorrCapabilities |=
IMeasurementCorrectionsCallback::Capabilities::REFLECTING_PLANE;
}
auto r = mMeasurementCorrectionsCbIface->setCapabilitiesCb(measCorrCapabilities);
if (!r.isOk()) {
LOC_LOGw("Error invoking setCapabilitiesCb %s", r.description().c_str());
}
} else {
LOC_LOGw("setCallback has not been called yet");
}
}
Return<bool> MeasurementCorrections::setCorrections(
const MeasurementCorrectionsV1_0& corrections) {
GnssMeasurementCorrections gnssMeasurementCorrections = {};
V2_1::implementation::convertMeasurementCorrections(corrections, gnssMeasurementCorrections);
return mGnss->getGnssInterface()->measCorrSetCorrections(gnssMeasurementCorrections);
}
Return<bool> MeasurementCorrections::setCorrections_1_1(
const MeasurementCorrectionsV1_1& corrections) {
GnssMeasurementCorrections gnssMeasurementCorrections = {};
V2_1::implementation::convertMeasurementCorrections(
corrections.v1_0, gnssMeasurementCorrections);
gnssMeasurementCorrections.hasEnvironmentBearing = corrections.hasEnvironmentBearing;
gnssMeasurementCorrections.environmentBearingDegrees =
corrections.environmentBearingDegrees;
gnssMeasurementCorrections.environmentBearingUncertaintyDegrees =
corrections.environmentBearingUncertaintyDegrees;
for (int i = 0; i < corrections.satCorrections.size(); i++) {
GnssSingleSatCorrection gnssSingleSatCorrection = {};
V2_1::implementation::convertSingleSatCorrections(
corrections.satCorrections[i].v1_0, gnssSingleSatCorrection);
switch (corrections.satCorrections[i].constellation) {
case (::android::hardware::gnss::V2_0::GnssConstellationType::GPS):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_GPS;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::SBAS):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_SBAS;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::GLONASS):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_GLONASS;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::QZSS):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_QZSS;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::BEIDOU):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_BEIDOU;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::GALILEO):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_GALILEO;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::IRNSS):
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_NAVIC;
break;
case (::android::hardware::gnss::V2_0::GnssConstellationType::UNKNOWN):
default:
gnssSingleSatCorrection.svType = GNSS_SV_TYPE_UNKNOWN;
break;
}
gnssMeasurementCorrections.satCorrections.push_back(gnssSingleSatCorrection);
}
return mGnss->getGnssInterface()->measCorrSetCorrections(gnssMeasurementCorrections);
}
Return<bool> MeasurementCorrections::setCallback(
const sp<V1_0::IMeasurementCorrectionsCallback>& callback) {
if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) {
LOC_LOGe("Null GNSS interface");
return false;
}
mMeasurementCorrectionsCbIface = callback;
return mGnss->getGnssInterface()->measCorrInit(measCorrSetCapabilitiesCb);
}
} // namespace implementation
} // namespace V1_1
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,106 @@
/*
* 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 ANDROID_HARDWARE_GNSS_V1_1_MeasurementCorrections_H
#define ANDROID_HARDWARE_GNSS_V1_1_MeasurementCorrections_H
#include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrectionsCallback.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <gps_extended_c.h>
#include <location_interface.h>
#include "Gnss.h"
#include <LocationUtil.h>
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_1 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
using ::android::hardware::gnss::V2_1::implementation::Gnss;
using MeasurementCorrectionsV1_0 =
::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections;
using MeasurementCorrectionsV1_1 =
::android::hardware::gnss::measurement_corrections::V1_1::MeasurementCorrections;
struct MeasurementCorrections : public V1_1::IMeasurementCorrections {
MeasurementCorrections(Gnss* gnss);
~MeasurementCorrections();
Return<bool> setCorrections(const MeasurementCorrectionsV1_0& corrections) override;
// Methods from
// ::android::hardware::gnss::measurement_corrections::V1_1::IMeasurementCorrections follow.
Return<bool> setCorrections_1_1(const MeasurementCorrectionsV1_1& corrections);
Return<bool> setCallback(const sp<IMeasurementCorrectionsCallback>& callback) override;
void setCapabilitiesCb(GnssMeasurementCorrectionsCapabilitiesMask capabilities);
/* Data call setup callback passed down to GNSS HAL implementation */
static void measCorrSetCapabilitiesCb(GnssMeasurementCorrectionsCapabilitiesMask capabilities);
private:
struct GnssMeasurementCorrectionsDeathRecipient : hidl_death_recipient {
GnssMeasurementCorrectionsDeathRecipient(
sp<MeasurementCorrections> gnssMeasurementCorrections) :
mGnssMeasurementCorrections(gnssMeasurementCorrections) {
}
~GnssMeasurementCorrectionsDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<MeasurementCorrections> mGnssMeasurementCorrections;
};
Gnss* mGnss = nullptr;
sp<GnssMeasurementCorrectionsDeathRecipient> mGnssMeasurementCorrectionsDeathRecipient =
nullptr;
sp<IMeasurementCorrectionsCallback> mMeasurementCorrectionsCbIface = nullptr;
};
} // namespace implementation
} // namespace V1_1
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V1_1_MeasurementCorrections_H

View File

@@ -0,0 +1,4 @@
service gnss_service /vendor/bin/hw/android.hardware.gnss@2.1-service-qti
class hal
user gps
group system gps radio vendor_qti_diag

View File

@@ -1,4 +1,4 @@
<!-- Copyright (c) 2019, The Linux Foundation. All rights reserved.
<!-- 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
@@ -30,7 +30,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<name>android.hardware.gnss</name>
<transport>hwbinder</transport>
<fqname>@1.1::IGnss/default</fqname>
<fqname>@2.0::IGnss/default</fqname>
<fqname>@2.1::IGnss/default</fqname>
</hal>
</manifest>

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -42,7 +42,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnssBatching;
@@ -212,7 +212,7 @@ void BatchingAPIClient::onBatchingCb(size_t count, Location* location,
}
auto r = gnssBatchingCbIface_2_0->gnssLocationBatchCb(locationVec);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssLocationBatchCb 2.0 description=%s",
LOC_LOGE("%s] Error from gnssLocationBatchCb 2_0 description=%s",
__func__, r.description().c_str());
}
} else if (gnssBatchingCbIface != nullptr && count > 0) {
@@ -244,7 +244,7 @@ static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -40,7 +40,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
class BatchingAPIClient : public LocationAPIClientBase
@@ -50,7 +50,6 @@ public:
BatchingAPIClient(const sp<V2_0::IGnssBatchingCallback>& callback);
void gnssUpdateCallbacks(const sp<V1_0::IGnssBatchingCallback>& callback);
void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssBatchingCallback>& callback);
~BatchingAPIClient();
int getBatchSize();
int startSession(const V1_0::IGnssBatching::Options& options);
int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
@@ -65,6 +64,8 @@ public:
void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
private:
~BatchingAPIClient();
void setCallbacks();
std::mutex mMutex;
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
@@ -74,7 +75,7 @@ private:
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -39,7 +39,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
@@ -269,7 +269,7 @@ void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors,
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -37,7 +37,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::sp;
@@ -46,7 +46,6 @@ class GeofenceAPIClient : public LocationAPIClientBase
{
public:
GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
virtual ~GeofenceAPIClient() = default;
void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int32_t last_transition, int32_t monitor_transitions,
@@ -65,11 +64,13 @@ public:
void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
private:
virtual ~GeofenceAPIClient() = default;
sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -41,17 +41,19 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnss;
using ::android::hardware::gnss::V2_0::IGnssCallback;
using ::android::hardware::gnss::V2_1::IGnss;
using ::android::hardware::gnss::V2_1::IGnssCallback;
using ::android::hardware::gnss::V1_0::IGnssNiCallback;
using ::android::hardware::gnss::V2_0::GnssLocation;
static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::GnssSvStatus& out);
static void convertGnssSvStatus(GnssSvNotification& in,
hidl_vec<V2_0::IGnssCallback::GnssSvInfo>& out);
static void convertGnssSvStatus(GnssSvNotification& in,
hidl_vec<V2_1::IGnssCallback::GnssSvInfo>& out);
GnssAPIClient::GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb) :
@@ -86,6 +88,22 @@ GnssAPIClient::GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb) :
gnssUpdateCallbacks_2_0(gpsCb);
}
GnssAPIClient::GnssAPIClient(const sp<V2_1::IGnssCallback>& gpsCb) :
LocationAPIClientBase(),
mGnssCbIface(nullptr),
mGnssNiCbIface(nullptr),
mControlClient(new LocationAPIControlClient()),
mLocationCapabilitiesMask(0),
mLocationCapabilitiesCached(false),
mTracking(false),
mGnssCbIface_2_1(nullptr)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb);
initLocationOptions();
gnssUpdateCallbacks_2_1(gpsCb);
}
GnssAPIClient::~GnssAPIClient()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
@@ -178,6 +196,19 @@ void GnssAPIClient::gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb
}
}
void GnssAPIClient::gnssUpdateCallbacks_2_1(const sp<V2_1::IGnssCallback>& gpsCb)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb);
mMutex.lock();
mGnssCbIface_2_1 = gpsCb;
mMutex.unlock();
if (mGnssCbIface_2_1 != nullptr) {
setCallbacks();
}
}
bool GnssAPIClient::gnssStart()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
@@ -223,7 +254,6 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
// For MSA, we always treat it as SINGLE mode.
mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC;
}
mTrackingOptions.minDistance = preferredAccuracyMeters;
if (mode == IGnss::GnssPositionMode::STANDALONE)
mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
else if (mode == IGnss::GnssPositionMode::MS_BASED)
@@ -279,7 +309,9 @@ void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags)
GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT |
GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT |
GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT |
GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT;
GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT |
GNSS_AIDING_DATA_SV_TYPE_NAVIC_BIT;
data.posEngineMask = STANDARD_POSITIONING_ENGINE;
if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL)
data.deleteAll = true;
@@ -357,10 +389,23 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
auto gnssCbIface_2_1(mGnssCbIface_2_1);
mMutex.unlock();
if (gnssCbIface_2_0 != nullptr || gnssCbIface != nullptr) {
if (gnssCbIface_2_1 != nullptr ||gnssCbIface_2_0 != nullptr || gnssCbIface != nullptr) {
uint32_t antennaInfoVectorSize = 0;
uint32_t data = 0;
loc_param_s_type ant_info_vector_table[] =
{
{ "ANTENNA_INFO_VECTOR_SIZE", &antennaInfoVectorSize, NULL, 'n' }
};
UTIL_READ_CONF(LOC_PATH_ANT_CORR, ant_info_vector_table);
if (0 != antennaInfoVectorSize) {
data |= V2_1::IGnssCallback::Capabilities::ANTENNA_INFO;
}
if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) ||
@@ -378,23 +423,41 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
data |= IGnssCallback::Capabilities::LOW_POWER_MODE;
if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT)
data |= IGnssCallback::Capabilities::SATELLITE_BLACKLIST;
if (capabilitiesMask & LOCATION_CAPABILITIES_MEASUREMENTS_CORRECTION_BIT)
data |= V2_0::IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS;
IGnssCallback::GnssSystemInfo gnssInfo;
if (capabilitiesMask & LOCATION_CAPABILITIES_PRIVACY_BIT) {
gnssInfo.yearOfHw = 2019;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
gnssInfo.yearOfHw = 2018;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
gnssInfo.yearOfHw = 2017;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
gnssInfo.yearOfHw = 2016;
} else {
gnssInfo.yearOfHw = 2015;
IGnssCallback::GnssSystemInfo gnssInfo = { .yearOfHw = 2015 };
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
gnssInfo.yearOfHw++; // 2016
if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
gnssInfo.yearOfHw++; // 2017
if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
gnssInfo.yearOfHw++; // 2018
if (capabilitiesMask & LOCATION_CAPABILITIES_PRIVACY_BIT) {
gnssInfo.yearOfHw++; // 2019
if (capabilitiesMask & LOCATION_CAPABILITIES_MEASUREMENTS_CORRECTION_BIT) {
gnssInfo.yearOfHw++; // 2020
}
}
}
}
}
LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw);
if (gnssCbIface_2_0 != nullptr) {
if (gnssCbIface_2_1 != nullptr) {
auto r = gnssCbIface_2_1->gnssSetCapabilitiesCb_2_1(data);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetCapabilitiesCb_2_1 description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_1->gnssSetSystemInfoCb(gnssInfo);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssSetCapabilitiesCb_2_0(data);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetCapabilitiesCb_2_0 description=%s",
@@ -427,6 +490,7 @@ void GnssAPIClient::onTrackingCb(Location location)
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
auto gnssCbIface_2_1(mGnssCbIface_2_1);
bool isTracking = mTracking;
mMutex.unlock();
@@ -436,7 +500,15 @@ void GnssAPIClient::onTrackingCb(Location location)
return;
}
if (gnssCbIface_2_0 != nullptr) {
if (gnssCbIface_2_1 != nullptr) {
V2_0::GnssLocation gnssLocation;
convertGnssLocation(location, gnssLocation);
auto r = gnssCbIface_2_1->gnssLocationCb_2_0(gnssLocation);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssLocationCb_2_0 description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface_2_0 != nullptr) {
V2_0::GnssLocation gnssLocation;
convertGnssLocation(location, gnssLocation);
auto r = gnssCbIface_2_0->gnssLocationCb_2_0(gnssLocation);
@@ -539,9 +611,18 @@ void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
auto gnssCbIface_2_1(mGnssCbIface_2_1);
mMutex.unlock();
if (gnssCbIface_2_0 != nullptr) {
if (gnssCbIface_2_1 != nullptr) {
hidl_vec<V2_1::IGnssCallback::GnssSvInfo> svInfoList;
convertGnssSvStatus(gnssSvNotification, svInfoList);
auto r = gnssCbIface_2_1->gnssSvStatusCb_2_1(svInfoList);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSvStatusCb_2_1 description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface_2_0 != nullptr) {
hidl_vec<V2_0::IGnssCallback::GnssSvInfo> svInfoList;
convertGnssSvStatus(gnssSvNotification, svInfoList);
auto r = gnssCbIface_2_0->gnssSvStatusCb_2_0(svInfoList);
@@ -565,9 +646,10 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
auto gnssCbIface_2_1(mGnssCbIface_2_1);
mMutex.unlock();
if (gnssCbIface != nullptr || gnssCbIface_2_0 != nullptr) {
if (gnssCbIface != nullptr || gnssCbIface_2_0 != nullptr| gnssCbIface_2_1 != nullptr) {
const std::string s(gnssNmeaNotification.nmea);
std::stringstream ss(s);
std::string each;
@@ -575,7 +657,15 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
each += '\n';
android::hardware::hidl_string nmeaString;
nmeaString.setToExternal(each.c_str(), each.length());
if (gnssCbIface_2_0 != nullptr) {
if (gnssCbIface_2_1 != nullptr) {
auto r = gnssCbIface_2_1->gnssNmeaCb(
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssCbIface_2_1 nmea=%s length=%u description=%s",
__func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length,
r.description().c_str());
}
} else if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssNmeaCb(
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
if (!r.isOk()) {
@@ -602,18 +692,30 @@ void GnssAPIClient::onStartTrackingCb(LocationError error)
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
auto gnssCbIface_2_1(mGnssCbIface_2_1);
mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS) {
if (gnssCbIface_2_0 != nullptr) {
if (gnssCbIface_2_1 != nullptr) {
auto r = gnssCbIface_2_1->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2_0 ENGINE_ON description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_1->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2_0 SESSION_BEGIN description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 ENGINE_ON description=%s",
LOC_LOGE("%s] Error from gnssStatusCb 2_0 ENGINE_ON description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 SESSION_BEGIN description=%s",
LOC_LOGE("%s] Error from gnssStatusCb 2_0 SESSION_BEGIN description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
@@ -637,18 +739,30 @@ void GnssAPIClient::onStopTrackingCb(LocationError error)
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
auto gnssCbIface_2_1(mGnssCbIface_2_1);
mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS) {
if (gnssCbIface_2_0 != nullptr) {
if (gnssCbIface_2_1 != nullptr) {
auto r = gnssCbIface_2_1->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2_0 SESSION_END description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_1->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2_0 ENGINE_OFF description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 SESSION_END description=%s",
LOC_LOGE("%s] Error from gnssStatusCb 2_0 SESSION_END description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 ENGINE_OFF description=%s",
LOC_LOGE("%s] Error from gnssStatusCb 2_0 ENGINE_OFF description=%s",
__func__, r.description().c_str());
}
@@ -677,7 +791,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::Gns
out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
}
for (size_t i = 0; i < out.numSvs; i++) {
out.gnssSvList[i].svid = in.gnssSvs[i].svId;
convertGnssSvid(in.gnssSvs[i], out.gnssSvList[i].svid);
convertGnssConstellationType(in.gnssSvs[i].type, out.gnssSvList[i].constellation);
out.gnssSvList[i].cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out.gnssSvList[i].elevationDegrees = in.gnssSvs[i].elevation;
@@ -700,7 +814,7 @@ static void convertGnssSvStatus(GnssSvNotification& in,
{
out.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
out[i].v1_0.svid = in.gnssSvs[i].svId;
convertGnssSvid(in.gnssSvs[i], out[i].v1_0.svid);
out[i].v1_0.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out[i].v1_0.elevationDegrees = in.gnssSvs[i].elevation;
out[i].v1_0.azimuthDegrees = in.gnssSvs[i].azimuth;
@@ -719,8 +833,33 @@ static void convertGnssSvStatus(GnssSvNotification& in,
}
}
static void convertGnssSvStatus(GnssSvNotification& in,
hidl_vec<V2_1::IGnssCallback::GnssSvInfo>& out)
{
out.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
convertGnssSvid(in.gnssSvs[i], out[i].v2_0.v1_0.svid);
out[i].v2_0.v1_0.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out[i].v2_0.v1_0.elevationDegrees = in.gnssSvs[i].elevation;
out[i].v2_0.v1_0.azimuthDegrees = in.gnssSvs[i].azimuth;
out[i].v2_0.v1_0.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
out[i].v2_0.v1_0.svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
out[i].v2_0.v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
out[i].v2_0.v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
out[i].v2_0.v1_0.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
out[i].v2_0.v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
convertGnssConstellationType(in.gnssSvs[i].type, out[i].v2_0.constellation);
out[i].basebandCN0DbHz = in.gnssSvs[i].basebandCarrierToNoiseDbHz;
}
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -32,14 +32,14 @@
#include <mutex>
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.0/IGnssCallback.h>
#include <android/hardware/gnss/2.1/IGnss.h>
#include <android/hardware/gnss/2.1/IGnssCallback.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::sp;
@@ -50,7 +50,7 @@ public:
GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb);
virtual ~GnssAPIClient();
GnssAPIClient(const sp<V2_1::IGnssCallback>& gpsCb);
GnssAPIClient(const GnssAPIClient&) = delete;
GnssAPIClient& operator=(const GnssAPIClient&) = delete;
@@ -58,6 +58,7 @@ public:
void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb);
void gnssUpdateCallbacks_2_1(const sp<V2_1::IGnssCallback>& gpsCb);
bool gnssStart();
bool gnssStop();
bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
@@ -93,8 +94,10 @@ public:
void onStopTrackingCb(LocationError error) final;
private:
virtual ~GnssAPIClient();
void setCallbacks();
void initLocationOptions();
sp<V1_0::IGnssCallback> mGnssCbIface;
sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
std::mutex mMutex;
@@ -104,10 +107,11 @@ private:
TrackingOptions mTrackingOptions;
bool mTracking;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0;
sp<V2_1::IGnssCallback> mGnssCbIface_2_1;
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,492 @@
/* 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 <LocationUtil.h>
#include <log_util.h>
#include <inttypes.h>
#include <loc_misc_utils.h>
#include <gps_extended_c.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V2_0::GnssLocation;
using ::android::hardware::gnss::V2_0::ElapsedRealtimeFlags;
using ::android::hardware::gnss::V2_0::GnssConstellationType;
using ::android::hardware::gnss::V1_0::GnssLocationFlags;
using ::android::hardware::gnss::measurement_corrections::V1_0::GnssSingleSatCorrectionFlags;
void convertGnssLocation(Location& in, V1_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V1_0::GnssLocation));
if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
out.latitudeDegrees = in.latitude;
out.longitudeDegrees = in.longitude;
}
if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
out.altitudeMeters = in.altitude;
}
if (in.flags & LOCATION_HAS_SPEED_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
out.speedMetersPerSec = in.speed;
}
if (in.flags & LOCATION_HAS_BEARING_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
out.bearingDegrees = in.bearing;
}
if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
out.horizontalAccuracyMeters = in.accuracy;
}
if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
out.verticalAccuracyMeters = in.verticalAccuracy;
}
if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
out.speedAccuracyMetersPerSecond = in.speedAccuracy;
}
if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
out.bearingAccuracyDegrees = in.bearingAccuracy;
}
out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
}
bool getCurrentTime(struct timespec& currentTime, int64_t& sinceBootTimeNanos)
{
struct timespec sinceBootTime;
struct timespec sinceBootTimeTest;
bool clockGetTimeSuccess = false;
const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 10000;
const uint32_t MAX_GET_TIME_COUNT = 20;
/* Attempt to get CLOCK_REALTIME and CLOCK_BOOTIME in succession without an interruption
or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */
for (uint32_t i = 0; i < MAX_GET_TIME_COUNT; i++) {
if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTime) != 0) {
break;
};
if (clock_gettime(CLOCK_REALTIME, &currentTime) != 0) {
break;
}
if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTimeTest) != 0) {
break;
};
sinceBootTimeNanos = sinceBootTime.tv_sec * 1000000000 + sinceBootTime.tv_nsec;
int64_t sinceBootTimeTestNanos =
sinceBootTimeTest.tv_sec * 1000000000 + sinceBootTimeTest.tv_nsec;
int64_t sinceBootTimeDeltaNanos = sinceBootTimeTestNanos - sinceBootTimeNanos;
/* sinceBootTime and sinceBootTimeTest should have a close value if there was no
interruption or context switch between clock_gettime for CLOCK_BOOTIME and
clock_gettime for CLOCK_REALTIME */
if (sinceBootTimeDeltaNanos < MAX_TIME_DELTA_VALUE_NANOS) {
clockGetTimeSuccess = true;
break;
} else {
LOC_LOGd("Delta:%" PRIi64 "ns time too large, retry number #%u...",
sinceBootTimeDeltaNanos, i + 1);
}
}
return clockGetTimeSuccess;
}
void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V2_0::GnssLocation));
convertGnssLocation(in, out.v1_0);
struct timespec currentTime;
int64_t sinceBootTimeNanos;
if (getCurrentTime(currentTime, sinceBootTimeNanos)) {
if (in.flags & LOCATION_HAS_ELAPSED_REAL_TIME) {
uint64_t qtimerDiff = 0;
uint64_t qTimerTickCount = getQTimerTickCount();
if (qTimerTickCount >= in.elapsedRealTime) {
qtimerDiff = qTimerTickCount - in.elapsedRealTime;
}
LOC_LOGv("sinceBootTimeNanos:%" PRIi64 " in.elapsedRealTime=%" PRIi64 ""
" qTimerTickCount=%" PRIi64 " qtimerDiff=%" PRIi64 "",
sinceBootTimeNanos, in.elapsedRealTime, qTimerTickCount, qtimerDiff);
uint64_t qTimerDiffNanos = qTimerTicksToNanos(double(qtimerDiff));
/* If the time difference between Qtimer on modem side and Qtimer on AP side
is greater than one second we assume this is a dual-SoC device such as
Kona and will try to get Qtimer on modem side and on AP side and
will adjust our difference accordingly */
if (qTimerDiffNanos > 1000000000) {
uint64_t qtimerDelta = getQTimerDeltaNanos();
if (qTimerDiffNanos >= qtimerDelta) {
qTimerDiffNanos -= qtimerDelta;
}
}
if (sinceBootTimeNanos >= qTimerDiffNanos) {
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
out.elapsedRealtime.timestampNs = sinceBootTimeNanos - qTimerDiffNanos;
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
out.elapsedRealtime.timeUncertaintyNs = in.elapsedRealTimeUnc;
}
} else {
int64_t currentTimeNanos = currentTime.tv_sec*1000000000 + currentTime.tv_nsec;
int64_t locationTimeNanos = in.timestamp*1000000;
LOC_LOGv("sinceBootTimeNanos:%" PRIi64 " currentTimeNanos:%" PRIi64 ""
" locationTimeNanos:%" PRIi64 "",
sinceBootTimeNanos, currentTimeNanos, locationTimeNanos);
if (currentTimeNanos >= locationTimeNanos) {
int64_t ageTimeNanos = currentTimeNanos - locationTimeNanos;
LOC_LOGv("ageTimeNanos:%" PRIi64 ")", ageTimeNanos);
// the max trusted propagation time 100ms for ageTimeNanos to avoid user setting
// wrong time, it will affect elapsedRealtimeNanos
if (ageTimeNanos <= 100000000) {
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
out.elapsedRealtime.timestampNs = sinceBootTimeNanos - ageTimeNanos;
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
// time uncertainty is the max value between abs(AP_UTC - MP_UTC) and 100ms, to
// verify if user change the sys time
out.elapsedRealtime.timeUncertaintyNs =
std::max(ageTimeNanos, (int64_t)100000000);
}
}
}
}
LOC_LOGv("out.elapsedRealtime.timestampNs=%" PRIi64 ""
" out.elapsedRealtime.timeUncertaintyNs=%" PRIi64 ""
" out.elapsedRealtime.flags=0x%X",
out.elapsedRealtime.timestampNs,
out.elapsedRealtime.timeUncertaintyNs, out.elapsedRealtime.flags);
}
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) {
out.flags |= LOCATION_HAS_LAT_LONG_BIT;
out.latitude = in.latitudeDegrees;
out.longitude = in.longitudeDegrees;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
out.flags |= LOCATION_HAS_ALTITUDE_BIT;
out.altitude = in.altitudeMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
out.flags |= LOCATION_HAS_SPEED_BIT;
out.speed = in.speedMetersPerSec;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
out.flags |= LOCATION_HAS_BEARING_BIT;
out.bearing = in.bearingDegrees;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
out.flags |= LOCATION_HAS_ACCURACY_BIT;
out.accuracy = in.horizontalAccuracyMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
out.verticalAccuracy = in.verticalAccuracyMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
out.speedAccuracy = in.speedAccuracyMetersPerSecond;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
out.bearingAccuracy = in.bearingAccuracyDegrees;
}
out.timestamp = static_cast<uint64_t>(in.timestamp);
}
void convertGnssLocation(const V2_0::GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
convertGnssLocation(in.v1_0, out);
}
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = V1_0::GnssConstellationType::GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = V1_0::GnssConstellationType::SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = V1_0::GnssConstellationType::GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = V1_0::GnssConstellationType::QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = V1_0::GnssConstellationType::BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = V1_0::GnssConstellationType::GALILEO;
break;
case GNSS_SV_TYPE_UNKNOWN:
default:
out = V1_0::GnssConstellationType::UNKNOWN;
break;
}
}
void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = V2_0::GnssConstellationType::GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = V2_0::GnssConstellationType::SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = V2_0::GnssConstellationType::GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = V2_0::GnssConstellationType::QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = V2_0::GnssConstellationType::BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = V2_0::GnssConstellationType::GALILEO;
break;
case GNSS_SV_TYPE_NAVIC:
out = V2_0::GnssConstellationType::IRNSS;
break;
case GNSS_SV_TYPE_UNKNOWN:
default:
out = V2_0::GnssConstellationType::UNKNOWN;
break;
}
}
void convertGnssSvid(GnssSv& in, int16_t& out)
{
switch (in.type) {
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
out = in.svId - GLO_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_NAVIC:
/*Android doesn't define Navic svid range yet, use Naviv svid [1, 14] now
will update this once Android give Navic svid definiitons */
out = in.svId - NAVIC_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
{
switch (in.svType) {
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
if (in.svId != 255) { // OSN is known
out = in.svId - GLO_SV_PRN_MIN + 1;
} else { // OSN is not known, report FCN
out = in.gloFrequency + 92;
}
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_NAVIC:
/*Android doesn't define Navic svid range yet, use Naviv svid [1, 14] now
will update this once Android give Navic svid definiitons */
out = in.svId - NAVIC_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
{
switch(in) {
case GNSS_EPH_TYPE_EPHEMERIS:
out = GnssDebug::SatelliteEphemerisType::EPHEMERIS;
break;
case GNSS_EPH_TYPE_ALMANAC:
out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY;
break;
case GNSS_EPH_TYPE_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE;
break;
}
}
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out)
{
switch(in) {
case GNSS_EPH_SOURCE_DEMODULATED:
out = GnssDebug::SatelliteEphemerisSource::DEMODULATED;
break;
case GNSS_EPH_SOURCE_SUPL_PROVIDED:
out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED;
break;
case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED:
out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED;
break;
case GNSS_EPH_SOURCE_LOCAL:
case GNSS_EPH_SOURCE_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisSource::OTHER;
break;
}
}
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out)
{
switch(in) {
case GNSS_EPH_HEALTH_GOOD:
out = GnssDebug::SatelliteEphemerisHealth::GOOD;
break;
case GNSS_EPH_HEALTH_BAD:
out = GnssDebug::SatelliteEphemerisHealth::BAD;
break;
case GNSS_EPH_HEALTH_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN;
break;
}
}
void convertSingleSatCorrections(const SingleSatCorrection& in, GnssSingleSatCorrection& out)
{
out.flags = GNSS_MEAS_CORR_UNKNOWN_BIT;
if (in.singleSatCorrectionFlags & (GnssSingleSatCorrectionFlags::HAS_SAT_IS_LOS_PROBABILITY)) {
out.flags |= GNSS_MEAS_CORR_HAS_SAT_IS_LOS_PROBABILITY_BIT;
}
if (in.singleSatCorrectionFlags & (GnssSingleSatCorrectionFlags::HAS_EXCESS_PATH_LENGTH)) {
out.flags |= GNSS_MEAS_CORR_HAS_EXCESS_PATH_LENGTH_BIT;
}
if (in.singleSatCorrectionFlags & (GnssSingleSatCorrectionFlags::HAS_EXCESS_PATH_LENGTH_UNC)) {
out.flags |= GNSS_MEAS_CORR_HAS_EXCESS_PATH_LENGTH_UNC_BIT;
}
if (in.singleSatCorrectionFlags & (GnssSingleSatCorrectionFlags::HAS_REFLECTING_PLANE)) {
out.flags |= GNSS_MEAS_CORR_HAS_REFLECTING_PLANE_BIT;
}
switch (in.constellation) {
case (::android::hardware::gnss::V1_0::GnssConstellationType::GPS):
out.svType = GNSS_SV_TYPE_GPS;
break;
case (::android::hardware::gnss::V1_0::GnssConstellationType::SBAS):
out.svType = GNSS_SV_TYPE_SBAS;
break;
case (::android::hardware::gnss::V1_0::GnssConstellationType::GLONASS):
out.svType = GNSS_SV_TYPE_GLONASS;
break;
case (::android::hardware::gnss::V1_0::GnssConstellationType::QZSS):
out.svType = GNSS_SV_TYPE_QZSS;
break;
case (::android::hardware::gnss::V1_0::GnssConstellationType::BEIDOU):
out.svType = GNSS_SV_TYPE_BEIDOU;
break;
case (::android::hardware::gnss::V1_0::GnssConstellationType::GALILEO):
out.svType = GNSS_SV_TYPE_GALILEO;
break;
case (::android::hardware::gnss::V1_0::GnssConstellationType::UNKNOWN):
default:
out.svType = GNSS_SV_TYPE_UNKNOWN;
break;
}
out.svId = in.svid;
out.carrierFrequencyHz = in.carrierFrequencyHz;
out.probSatIsLos = in.probSatIsLos;
out.excessPathLengthMeters = in.excessPathLengthMeters;
out.excessPathLengthUncertaintyMeters = in.excessPathLengthUncertaintyMeters;
out.reflectingPlane.latitudeDegrees = in.reflectingPlane.latitudeDegrees;
out.reflectingPlane.longitudeDegrees = in.reflectingPlane.longitudeDegrees;
out.reflectingPlane.altitudeMeters = in.reflectingPlane.altitudeMeters;
out.reflectingPlane.azimuthDegrees = in.reflectingPlane.azimuthDegrees;
}
void convertMeasurementCorrections(const MeasurementCorrectionsV1_0& in,
GnssMeasurementCorrections& out)
{
memset(&out, 0, sizeof(GnssMeasurementCorrections));
out.latitudeDegrees = in.latitudeDegrees;
out.longitudeDegrees = in.longitudeDegrees;
out.altitudeMeters = in.altitudeMeters;
out.horizontalPositionUncertaintyMeters = in.horizontalPositionUncertaintyMeters;
out.verticalPositionUncertaintyMeters = in.verticalPositionUncertaintyMeters;
out.toaGpsNanosecondsOfWeek = in.toaGpsNanosecondsOfWeek;
for (int i = 0; i < in.satCorrections.size(); i++) {
GnssSingleSatCorrection gnssSingleSatCorrection = {};
convertSingleSatCorrections(in.satCorrections[i], gnssSingleSatCorrection);
out.satCorrections.push_back(gnssSingleSatCorrection);
}
}
} // namespace implementation
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -31,27 +31,38 @@
#define LOCATION_UTIL_H
#include <android/hardware/gnss/2.0/types.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <LocationAPI.h>
#include <GnssDebug.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using MeasurementCorrectionsV1_0 =
::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections;
using ::android::hardware::gnss::measurement_corrections::V1_0::SingleSatCorrection;
void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
void convertGnssLocation(Location& in, V2_0::GnssLocation& out);
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
void convertGnssLocation(const V2_0::GnssLocation& in, Location& out);
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out);
void convertGnssSvid(GnssSv& in, int16_t& out);
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
bool getCurrentTime(struct timespec& currentTime, int64_t& sinceBootTimeNanos);
void convertSingleSatCorrections(const SingleSatCorrection& in, GnssSingleSatCorrection& out);
void convertMeasurementCorrections(const MeasurementCorrectionsV1_0& in,
GnssMeasurementCorrections& out);
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -32,14 +32,16 @@
#include <log_util.h>
#include <loc_cfg.h>
#include <inttypes.h>
#include "LocationUtil.h"
#include "MeasurementAPIClient.h"
#include <loc_misc_utils.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssMeasurement;
@@ -51,16 +53,30 @@ static void convertGnssData_1_1(GnssMeasurementsNotification& in,
V1_1::IGnssMeasurementCallback::GnssData& out);
static void convertGnssData_2_0(GnssMeasurementsNotification& in,
V2_0::IGnssMeasurementCallback::GnssData& out);
static void convertGnssData_2_1(GnssMeasurementsNotification& in,
V2_1::IGnssMeasurementCallback::GnssData& out);
static void convertGnssMeasurement(GnssMeasurementsData& in,
V1_0::IGnssMeasurementCallback::GnssMeasurement& out);
static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out);
static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
static void convertGnssClock_2_1(GnssMeasurementsClock& in,
V2_1::IGnssMeasurementCallback::GnssClock& out);
static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& inCodeType,
char* inOtherCodeTypeName,
::android::hardware::hidl_string& out);
static void convertGnssMeasurementsAccumulatedDeltaRangeState(GnssMeasurementsAdrStateMask& in,
::android::hardware::hidl_bitfield
<V1_1::IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState>& out);
static void convertGnssMeasurementsState(GnssMeasurementsStateMask& in,
::android::hardware::hidl_bitfield
<V2_0::IGnssMeasurementCallback::GnssMeasurementState>& out);
static void convertElapsedRealtimeNanos(GnssMeasurementsNotification& in,
::android::hardware::gnss::V2_0::ElapsedRealtime& elapsedRealtimeNanos);
MeasurementAPIClient::MeasurementAPIClient() :
mGnssMeasurementCbIface(nullptr),
mGnssMeasurementCbIface_1_1(nullptr),
mGnssMeasurementCbIface_2_0(nullptr),
mGnssMeasurementCbIface_2_1(nullptr),
mTracking(false)
{
LOC_LOGD("%s]: ()", __FUNCTION__);
@@ -71,6 +87,14 @@ MeasurementAPIClient::~MeasurementAPIClient()
LOC_LOGD("%s]: ()", __FUNCTION__);
}
void MeasurementAPIClient::clearInterfaces()
{
mGnssMeasurementCbIface = nullptr;
mGnssMeasurementCbIface_1_1 = nullptr;
mGnssMeasurementCbIface_2_0 = nullptr;
mGnssMeasurementCbIface_2_1 = nullptr;
}
// for GpsInterface
Return<IGnssMeasurement::GnssMeasurementStatus>
MeasurementAPIClient::measurementSetCallback(const sp<V1_0::IGnssMeasurementCallback>& callback)
@@ -78,6 +102,7 @@ MeasurementAPIClient::measurementSetCallback(const sp<V1_0::IGnssMeasurementCall
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
mMutex.lock();
clearInterfaces();
mGnssMeasurementCbIface = callback;
mMutex.unlock();
@@ -93,6 +118,7 @@ MeasurementAPIClient::measurementSetCallback_1_1(
__FUNCTION__, &callback, (int)powerMode, timeBetweenMeasurement);
mMutex.lock();
clearInterfaces();
mGnssMeasurementCbIface_1_1 = callback;
mMutex.unlock();
@@ -108,12 +134,26 @@ MeasurementAPIClient::measurementSetCallback_2_0(
__FUNCTION__, &callback, (int)powerMode, timeBetweenMeasurement);
mMutex.lock();
clearInterfaces();
mGnssMeasurementCbIface_2_0 = callback;
mMutex.unlock();
return startTracking(powerMode, timeBetweenMeasurement);
}
Return<IGnssMeasurement::GnssMeasurementStatus> MeasurementAPIClient::measurementSetCallback_2_1(
const sp<V2_1::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode, uint32_t timeBetweenMeasurement) {
LOC_LOGD("%s]: (%p) (powermode: %d) (tbm: %d)",
__FUNCTION__, &callback, (int)powerMode, timeBetweenMeasurement);
mMutex.lock();
clearInterfaces();
mGnssMeasurementCbIface_2_1 = callback;
mMutex.unlock();
return startTracking(powerMode, timeBetweenMeasurement);
}
Return<IGnssMeasurement::GnssMeasurementStatus>
MeasurementAPIClient::startTracking(
GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
@@ -132,7 +172,8 @@ MeasurementAPIClient::startTracking(
locationCallbacks.gnssNmeaCb = nullptr;
locationCallbacks.gnssMeasurementsCb = nullptr;
if (mGnssMeasurementCbIface_2_0 != nullptr ||
if (mGnssMeasurementCbIface_2_1 != nullptr ||
mGnssMeasurementCbIface_2_0 != nullptr ||
mGnssMeasurementCbIface_1_1 != nullptr ||
mGnssMeasurementCbIface != nullptr) {
locationCallbacks.gnssMeasurementsCb =
@@ -177,7 +218,10 @@ void MeasurementAPIClient::onGnssMeasurementsCb(
sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr;
sp<V1_1::IGnssMeasurementCallback> gnssMeasurementCbIface_1_1 = nullptr;
sp<V2_0::IGnssMeasurementCallback> gnssMeasurementCbIface_2_0 = nullptr;
if (mGnssMeasurementCbIface_2_0 != nullptr) {
sp<V2_1::IGnssMeasurementCallback> gnssMeasurementCbIface_2_1 = nullptr;
if (mGnssMeasurementCbIface_2_1 != nullptr) {
gnssMeasurementCbIface_2_1 = mGnssMeasurementCbIface_2_1;
} else if (mGnssMeasurementCbIface_2_0 != nullptr) {
gnssMeasurementCbIface_2_0 = mGnssMeasurementCbIface_2_0;
} else if (mGnssMeasurementCbIface_1_1 != nullptr) {
gnssMeasurementCbIface_1_1 = mGnssMeasurementCbIface_1_1;
@@ -186,7 +230,15 @@ void MeasurementAPIClient::onGnssMeasurementsCb(
}
mMutex.unlock();
if (gnssMeasurementCbIface_2_0 != nullptr) {
if (gnssMeasurementCbIface_2_1 != nullptr) {
V2_1::IGnssMeasurementCallback::GnssData gnssData;
convertGnssData_2_1(gnssMeasurementsNotification, gnssData);
auto r = gnssMeasurementCbIface_2_1->gnssMeasurementCb_2_1(gnssData);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssMeasurementCb description=%s",
__func__, r.description().c_str());
}
} else if (gnssMeasurementCbIface_2_0 != nullptr) {
V2_0::IGnssMeasurementCallback::GnssData gnssData;
convertGnssData_2_0(gnssMeasurementsNotification, gnssData);
auto r = gnssMeasurementCbIface_2_0->gnssMeasurementCb_2_0(gnssData);
@@ -230,7 +282,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in,
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
out.svid = in.svId;
convertGnssSvid(in, out.svid);
convertGnssConstellationType(in.svType, out.constellation);
out.timeOffsetNs = in.timeOffsetNs;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
@@ -295,7 +347,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in,
static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out)
{
memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssClock));
memset(&out, 0, sizeof(out));
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
@@ -321,9 +373,24 @@ static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback
out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount;
}
static void convertGnssClock_2_1(GnssMeasurementsClock& in,
V2_1::IGnssMeasurementCallback::GnssClock& out)
{
memset(&out, 0, sizeof(out));
convertGnssClock(in, out.v1_0);
convertGnssConstellationType(in.referenceSignalTypeForIsb.svType,
out.referenceSignalTypeForIsb.constellation);
out.referenceSignalTypeForIsb.carrierFrequencyHz =
in.referenceSignalTypeForIsb.carrierFrequencyHz;
convertGnssMeasurementsCodeType(in.referenceSignalTypeForIsb.codeType,
in.referenceSignalTypeForIsb.otherCodeTypeName,
out.referenceSignalTypeForIsb.codeType);
}
static void convertGnssData(GnssMeasurementsNotification& in,
V1_0::IGnssMeasurementCallback::GnssData& out)
{
memset(&out, 0, sizeof(out));
out.measurementCount = in.count;
if (out.measurementCount > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.",
@@ -339,21 +406,12 @@ static void convertGnssData(GnssMeasurementsNotification& in,
static void convertGnssData_1_1(GnssMeasurementsNotification& in,
V1_1::IGnssMeasurementCallback::GnssData& out)
{
memset(&out, 0, sizeof(out));
out.measurements.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_0);
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
convertGnssMeasurementsAccumulatedDeltaRangeState(in.measurements[i].adrStateMask,
out.measurements[i].accumulatedDeltaRangeState);
}
convertGnssClock(in.clock, out.clock);
}
@@ -361,65 +419,27 @@ static void convertGnssData_1_1(GnssMeasurementsNotification& in,
static void convertGnssData_2_0(GnssMeasurementsNotification& in,
V2_0::IGnssMeasurementCallback::GnssData& out)
{
memset(&out, 0, sizeof(out));
out.measurements.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_1.v1_0);
convertGnssConstellationType(in.measurements[i].svType, out.measurements[i].constellation);
convertGnssMeasurementsCodeType(in.measurements[i].codeType, out.measurements[i].codeType);
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_TOW_KNOWN_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_KNOWN;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_KNOWN_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_KNOWN;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_2ND_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_2ND_CODE_LOCK;
convertGnssMeasurementsCodeType(in.measurements[i].codeType,
in.measurements[i].otherCodeTypeName,
out.measurements[i].codeType);
convertGnssMeasurementsAccumulatedDeltaRangeState(in.measurements[i].adrStateMask,
out.measurements[i].v1_1.accumulatedDeltaRangeState);
convertGnssMeasurementsState(in.measurements[i].stateMask, out.measurements[i].state);
}
convertGnssClock(in.clock, out.clock);
convertElapsedRealtimeNanos(in, out.elapsedRealtime);
}
static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
::android::hardware::hidl_string& out)
static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& inCodeType,
char* inOtherCodeTypeName, ::android::hardware::hidl_string& out)
{
switch(in) {
memset(&out, 0, sizeof(out));
switch(inCodeType) {
case GNSS_MEASUREMENTS_CODE_TYPE_A:
out = "A";
break;
@@ -462,13 +482,225 @@ static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
case GNSS_MEASUREMENTS_CODE_TYPE_N:
out = "N";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_OTHER:
default:
out = "UNKNOWN";
out = inOtherCodeTypeName;
break;
}
}
static void convertGnssMeasurementsAccumulatedDeltaRangeState(GnssMeasurementsAdrStateMask& in,
::android::hardware::hidl_bitfield
<V1_1::IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState>& out)
{
memset(&out, 0, sizeof(out));
if (in & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out |= IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
if (in & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out |= IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
if (in & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out |= IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
if (in & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
out |= IGnssMeasurementCallback::
GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
}
static void convertGnssMeasurementsState(GnssMeasurementsStateMask& in,
::android::hardware::hidl_bitfield
<V2_0::IGnssMeasurementCallback::GnssMeasurementState>& out)
{
memset(&out, 0, sizeof(out));
if (in & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
if (in & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
if (in & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
if (in & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
if (in & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
if (in & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
if (in & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
if (in & GNSS_MEASUREMENTS_STATE_TOW_KNOWN_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_KNOWN;
if (in & GNSS_MEASUREMENTS_STATE_GLO_TOD_KNOWN_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_KNOWN;
if (in & GNSS_MEASUREMENTS_STATE_2ND_CODE_LOCK_BIT)
out |= IGnssMeasurementCallback::GnssMeasurementState::STATE_2ND_CODE_LOCK;
}
static void convertGnssData_2_1(GnssMeasurementsNotification& in,
V2_1::IGnssMeasurementCallback::GnssData& out)
{
memset(&out, 0, sizeof(out));
out.measurements.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
out.measurements[i].flags = 0;
convertGnssMeasurement(in.measurements[i], out.measurements[i].v2_0.v1_1.v1_0);
convertGnssConstellationType(in.measurements[i].svType,
out.measurements[i].v2_0.constellation);
convertGnssMeasurementsCodeType(in.measurements[i].codeType,
in.measurements[i].otherCodeTypeName,
out.measurements[i].v2_0.codeType);
convertGnssMeasurementsAccumulatedDeltaRangeState(in.measurements[i].adrStateMask,
out.measurements[i].v2_0.v1_1.accumulatedDeltaRangeState);
convertGnssMeasurementsState(in.measurements[i].stateMask,
out.measurements[i].v2_0.state);
out.measurements[i].basebandCN0DbHz = in.measurements[i].basebandCarrierToNoiseDbHz;
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT) {
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT) {
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT) {
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT) {
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT) {
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::
GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT) {
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_FULL_ISB_BIT) {
out.measurements[i].fullInterSignalBiasNs = in.measurements[i].fullInterSignalBiasNs;
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_FULL_ISB;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_FULL_ISB_UNCERTAINTY_BIT) {
out.measurements[i].fullInterSignalBiasUncertaintyNs =
in.measurements[i].fullInterSignalBiasUncertaintyNs;
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::
GnssMeasurementFlags::HAS_FULL_ISB_UNCERTAINTY;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_SATELLITE_ISB_BIT) {
out.measurements[i].satelliteInterSignalBiasNs =
in.measurements[i].satelliteInterSignalBiasNs;
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SATELLITE_ISB;
}
if (in.measurements[i].flags & GNSS_MEASUREMENTS_DATA_SATELLITE_ISB_UNCERTAINTY_BIT) {
out.measurements[i].satelliteInterSignalBiasUncertaintyNs =
in.measurements[i].satelliteInterSignalBiasUncertaintyNs;
out.measurements[i].flags |=
V2_1::IGnssMeasurementCallback::
GnssMeasurementFlags::HAS_SATELLITE_ISB_UNCERTAINTY;
}
}
convertGnssClock_2_1(in.clock, out.clock);
convertElapsedRealtimeNanos(in, out.elapsedRealtime);
}
static void convertElapsedRealtimeNanos(GnssMeasurementsNotification& in,
::android::hardware::gnss::V2_0::ElapsedRealtime& elapsedRealtime)
{
struct timespec currentTime;
int64_t sinceBootTimeNanos;
if (getCurrentTime(currentTime, sinceBootTimeNanos)) {
if (in.clock.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_ELAPSED_REAL_TIME_BIT) {
uint64_t qtimerDiff = 0;
uint64_t qTimerTickCount = getQTimerTickCount();
if (qTimerTickCount >= in.clock.elapsedRealTime) {
qtimerDiff = qTimerTickCount - in.clock.elapsedRealTime;
}
LOC_LOGv("sinceBootTimeNanos:%" PRIi64 " in.clock.elapsedRealTime=%" PRIi64 ""
" qTimerTickCount=%" PRIi64 " qtimerDiff=%" PRIi64 "",
sinceBootTimeNanos, in.clock.elapsedRealTime, qTimerTickCount, qtimerDiff);
uint64_t qTimerDiffNanos = qTimerTicksToNanos(double(qtimerDiff));
/* If the time difference between Qtimer on modem side and Qtimer on AP side
is greater than one second we assume this is a dual-SoC device such as
Kona and will try to get Qtimer on modem side and on AP side and
will adjust our difference accordingly */
if (qTimerDiffNanos > 1000000000) {
uint64_t qtimerDelta = getQTimerDeltaNanos();
if (qTimerDiffNanos >= qtimerDelta) {
qTimerDiffNanos -= qtimerDelta;
}
}
if (sinceBootTimeNanos >= qTimerDiffNanos) {
elapsedRealtime.flags |= V2_0::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
elapsedRealtime.timestampNs = sinceBootTimeNanos - qTimerDiffNanos;
elapsedRealtime.flags |= V2_0::ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
elapsedRealtime.timeUncertaintyNs = in.clock.elapsedRealTimeUnc;
}
} else {
const uint32_t UTC_TO_GPS_SECONDS = 315964800;
if (in.clock.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT &&
in.clock.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT &&
in.clock.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT &&
in.clock.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT) {
int64_t currentTimeNanos = currentTime.tv_sec * 1000000000 + currentTime.tv_nsec;
int64_t measTimeNanos = (int64_t)in.clock.timeNs - (int64_t)in.clock.fullBiasNs
- (int64_t)in.clock.biasNs - (int64_t)in.clock.leapSecond * 1000000000
+ (int64_t)UTC_TO_GPS_SECONDS * 1000000000;
LOC_LOGv("sinceBootTimeNanos:%" PRIi64 " currentTimeNanos:%" PRIi64 ""
" measTimeNanos:%" PRIi64 "",
sinceBootTimeNanos, currentTimeNanos, measTimeNanos);
if (currentTimeNanos >= measTimeNanos) {
int64_t ageTimeNanos = currentTimeNanos - measTimeNanos;
LOC_LOGv("ageTimeNanos:%" PRIi64 ")", ageTimeNanos);
// the max trusted propagation time 100ms for ageTimeNanos to avoid user
// setting wrong time, it will affect elapsedRealtimeNanos
if (ageTimeNanos <= 100000000) {
elapsedRealtime.flags |= V2_0::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
elapsedRealtime.timestampNs = sinceBootTimeNanos - ageTimeNanos;
elapsedRealtime.flags |=
V2_0::ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
// time uncertainty is 1 ms since it is calculated from utc time that
// is in ms
// time uncertainty is the max value between abs(AP_UTC - MP_UTC) and 100ms,
// to verify if user change the sys time
elapsedRealtime.timeUncertaintyNs =
std::max(ageTimeNanos, (int64_t)100000000);
}
}
} else {
LOC_LOGe("Failed to calculate elapsedRealtimeNanos timestamp");
}
}
}
LOC_LOGv("elapsedRealtime.timestampNs=%" PRIi64 ""
" elapsedRealtime.timeUncertaintyNs=%" PRIi64 " elapsedRealtime.flags=0x%X",
elapsedRealtime.timestampNs,
elapsedRealtime.timeUncertaintyNs, elapsedRealtime.flags);
}
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -31,8 +31,9 @@
#define MEASUREMENT_API_CLINET_H
#include <mutex>
#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
#include <android/hardware/gnss/2.1/IGnssMeasurement.h>
//#include <android/hardware/gnss/1.1/IGnssMeasurementCallback.h>
#include <android/hardware/gnss/2.1/IGnssMeasurementCallback.h>
#include <LocationAPIClientBase.h>
#include <hidl/Status.h>
#include <gps_extended_c.h>
@@ -40,7 +41,7 @@
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace V2_1 {
namespace implementation {
using ::android::sp;
@@ -49,7 +50,6 @@ class MeasurementAPIClient : public LocationAPIClientBase
{
public:
MeasurementAPIClient();
virtual ~MeasurementAPIClient();
MeasurementAPIClient(const MeasurementAPIClient&) = delete;
MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;
@@ -64,6 +64,10 @@ public:
const sp<V2_0::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback_2_1(
const sp<V2_1::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
void measurementClose();
Return<IGnssMeasurement::GnssMeasurementStatus> startTracking(
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
@@ -73,16 +77,19 @@ public:
void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
private:
virtual ~MeasurementAPIClient();
std::mutex mMutex;
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;
sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1;
sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0;
sp<V2_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_1;
bool mTracking;
void clearInterfaces();
};
} // namespace implementation
} // namespace V2_0
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -1,15 +1,15 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2_0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2_0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,9 +18,9 @@
* limitations under the License.
*/
#define LOG_TAG "android.hardware.gnss@2.0-service-qti"
#define LOG_TAG "android.hardware.gnss@2.1-service-qti"
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.1/IGnss.h>
#include <hidl/LegacySupport.h>
#include "loc_cfg.h"
#include "loc_misc_utils.h"
@@ -33,7 +33,7 @@ extern "C" {
#define DEFAULT_HW_BINDER_MEM_SIZE 65536
#endif
using android::hardware::gnss::V2_0::IGnss;
using android::hardware::gnss::V2_1::IGnss;
using android::hardware::configureRpcThreadpool;
using android::hardware::registerPassthroughServiceImplementation;
@@ -60,25 +60,21 @@ int main() {
status = registerPassthroughServiceImplementation<IGnss>();
if (status == OK) {
if (vendorEnhanced) {
#ifdef LOC_HIDL_VERSION
#define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
#define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
void* libHandle = NULL;
vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
if (NULL != vendorEnhancedMainMethod) {
(*vendorEnhancedMainMethod)(0, NULL);
}
#else
ALOGE("LOC_HIDL_VERSION not defined.");
#endif
void* libHandle = NULL;
vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
if (NULL != vendorEnhancedMainMethod) {
(*vendorEnhancedMainMethod)(0, NULL);
}
#else
ALOGI("LOC_HIDL_VERSION not defined.");
#endif
joinRpcThreadpool();
} else {
ALOGE("Error while registering IGnss 2.0 service: %d", status);
ALOGE("Error while registering IGnss 2.1 service: %d", status);
}
return 0;

View File

@@ -1,7 +1,2 @@
LOCAL_PATH := $(call my-dir)
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
include $(CLEAR_VARS)
DIR_LIST := $(LOCAL_PATH)
include $(DIR_LIST)/utils/Android.mk
include $(DIR_LIST)/2.0/Android.mk
endif #BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
include $(call all-subdir-makefiles)

View File

@@ -0,0 +1,37 @@
cc_library_static {
name: "liblocbatterylistener",
vendor: true,
sanitize: GNSS_SANITIZE,
cflags: GNSS_CFLAGS + ["-DBATTERY_LISTENER_ENABLED"],
local_include_dirs: ["."],
srcs: ["battery_listener.cpp"],
shared_libs: [
"liblog",
"libhidlbase",
"libcutils",
"libutils",
"android.hardware.health@1.0",
"android.hardware.health@2.0",
"android.hardware.health@2.1",
"android.hardware.power@1.2",
"libbase",
],
static_libs: ["libhealthhalutils"],
header_libs: [
"libgps.utils_headers",
"libloc_pla_headers",
],
}
cc_library_headers {
name: "liblocbatterylistener_headers",
export_include_dirs: ["."],
}

View File

@@ -1,33 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := liblocbatterylistener
LOCAL_VENDOR_MODULE := true
LOCAL_CFLAGS += $(GNSS_CFLAGS)
LOCAL_C_INCLUDES += \
$(LOCAL_PATH) \
LOCAL_SRC_FILES:= \
battery_listener.cpp
LOCAL_SHARED_LIBRARIES := \
liblog \
libhidlbase \
libcutils \
libutils \
android.hardware.health@1.0 \
android.hardware.health@2.0 \
android.hardware.power@1.2 \
libbase
LOCAL_STATIC_LIBRARIES := libhealthhalutils
LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblocbatterylistener_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_HEADER_LIBRARY)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* 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
@@ -31,20 +31,25 @@
#undef LOG_TAG
#endif
#define LOG_TAG "LocSvc_BatteryListener"
#define LOG_NDEBUG 0
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hardware/health/2.0/IHealth.h>
#include <android/hardware/health/2.1/IHealth.h>
#include <android/hardware/health/2.1/IHealthInfoCallback.h>
#include <healthhalutils/HealthHalUtils.h>
#include <hidl/HidlTransportSupport.h>
#include <thread>
#include <log_util.h>
using android::hardware::interfacesEqual;
using android::hardware::Return;
using android::hardware::Void;
using android::hardware::health::V1_0::BatteryStatus;
using android::hardware::health::V1_0::toString;
using android::hardware::health::V2_0::get_health_service;
using android::hardware::health::V2_0::HealthInfo;
using android::hardware::health::V2_0::IHealth;
using android::hardware::health::V2_1::HealthInfo;
using android::hardware::health::V2_1::IHealthInfoCallback;
using android::hardware::health::V2_1::IHealth;
using android::hardware::health::V2_0::Result;
using android::hidl::manager::V1_0::IServiceManager;
using namespace std::literals::chrono_literals;
@@ -55,13 +60,15 @@ namespace android {
#define GET_HEALTH_SVC_RETRY_CNT 5
#define GET_HEALTH_SVC_WAIT_TIME_MS 500
struct BatteryListenerImpl : public hardware::health::V2_0::IHealthInfoCallback,
struct BatteryListenerImpl : public hardware::health::V2_1::IHealthInfoCallback,
public hardware::hidl_death_recipient {
typedef std::function<void(bool)> cb_fn_t;
BatteryListenerImpl(cb_fn_t cb);
virtual ~BatteryListenerImpl ();
virtual hardware::Return<void> healthInfoChanged(
const hardware::health::V2_0::HealthInfo& info);
const hardware::health::V2_0::HealthInfo& info);
virtual hardware::Return<void> healthInfoChanged_2_1(
const hardware::health::V2_1::HealthInfo& info);
virtual void serviceDied(uint64_t cookie,
const wp<hidl::base::V1_0::IBase>& who);
bool isCharging() {
@@ -69,7 +76,7 @@ struct BatteryListenerImpl : public hardware::health::V2_0::IHealthInfoCallback,
return statusToBool(mStatus);
}
private:
sp<hardware::health::V2_0::IHealth> mHealth;
sp<hardware::health::V2_1::IHealth> mHealth;
status_t init();
BatteryStatus mStatus;
cb_fn_t mCb;
@@ -91,7 +98,7 @@ status_t BatteryListenerImpl::init()
return INVALID_OPERATION;
do {
mHealth = hardware::health::V2_0::get_health_service();
mHealth = IHealth::getService("default", true);
if (mHealth != NULL)
break;
usleep(GET_HEALTH_SVC_WAIT_TIME_MS * 1000);
@@ -99,24 +106,25 @@ status_t BatteryListenerImpl::init()
} while(tries < GET_HEALTH_SVC_RETRY_CNT);
if (mHealth == NULL) {
ALOGE("no health service found, retries %d", tries);
LOC_LOGe("no health service found, retries %d", tries);
return NO_INIT;
} else {
ALOGI("Get health service in %d tries", tries);
LOC_LOGi("Get health service in %d tries", tries);
}
mStatus = BatteryStatus::UNKNOWN;
auto ret = mHealth->getChargeStatus([&](Result r, BatteryStatus status) {
if (r != Result::SUCCESS) {
ALOGE("batterylistener: cannot get battery status");
LOC_LOGe("batterylistener: cannot get battery status");
return;
}
mStatus = status;
});
if (!ret.isOk())
ALOGE("batterylistener: get charge status transaction error");
if (mStatus == BatteryStatus::UNKNOWN)
ALOGW("batterylistener: init: invalid battery status");
if (!ret.isOk()) {
LOC_LOGe("batterylistener: get charge status transaction error");
}
if (mStatus == BatteryStatus::UNKNOWN) {
LOC_LOGw("batterylistener: init: invalid battery status");
}
mDone = false;
mThread = std::make_unique<std::thread>([this]() {
std::unique_lock<std::mutex> l(mLock);
@@ -146,7 +154,7 @@ status_t BatteryListenerImpl::init()
}
default:
bool c = statusToBool(local_status);
ALOGI("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING");
LOC_LOGi("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING");
l.unlock();
mCb(c);
l.lock();
@@ -156,13 +164,14 @@ status_t BatteryListenerImpl::init()
});
auto reg = mHealth->registerCallback(this);
if (!reg.isOk()) {
ALOGE("Transaction error in registeringCb to HealthHAL death: %s",
LOC_LOGe("Transaction error in registeringCb to HealthHAL death: %s",
reg.description().c_str());
}
auto linked = mHealth->linkToDeath(this, 0 /* cookie */);
if (!linked.isOk() || linked == false) {
ALOGE("Transaction error in linking to HealthHAL death: %s", linked.description().c_str());
LOC_LOGe("Transaction error in linking to HealthHAL death: %s",
linked.description().c_str());
}
return NO_ERROR;
}
@@ -178,10 +187,10 @@ BatteryListenerImpl::~BatteryListenerImpl()
{
std::lock_guard<std::mutex> _l(mLock);
if (mHealth != NULL)
mHealth->unlinkToDeath(this);
mHealth->unregisterCallback(this);
auto r = mHealth->unlinkToDeath(this);
if (!r.isOk() || r == false) {
ALOGE("Transaction error in unregister to HealthHAL death: %s",
LOC_LOGe("Transaction error in unregister to HealthHAL death: %s",
r.description().c_str());
}
}
@@ -195,12 +204,14 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
{
std::lock_guard<std::mutex> _l(mLock);
if (mHealth == NULL || !interfacesEqual(mHealth, who.promote())) {
ALOGE("health not initialized or unknown interface died");
LOC_LOGe("health not initialized or unknown interface died");
return;
}
ALOGI("health service died, reinit");
LOC_LOGi("health service died, reinit");
mDone = true;
}
mHealth = NULL;
mCond.notify_one();
mThread->join();
std::lock_guard<std::mutex> _l(mLock);
init();
@@ -212,9 +223,8 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
// NOT_CHARGING and CHARGING concurrencies.
// Replace single var by a list if this assumption is broken
Return<void> BatteryListenerImpl::healthInfoChanged(
const hardware::health::V2_0::HealthInfo& info)
{
ALOGV("healthInfoChanged: %d", info.legacy.batteryStatus);
const hardware::health::V2_0::HealthInfo& info) {
LOC_LOGv("healthInfoChanged: %d", info.legacy.batteryStatus);
std::unique_lock<std::mutex> l(mLock);
if (info.legacy.batteryStatus != mStatus) {
mStatus = info.legacy.batteryStatus;
@@ -223,30 +233,38 @@ Return<void> BatteryListenerImpl::healthInfoChanged(
return Void();
}
Return<void> BatteryListenerImpl::healthInfoChanged_2_1(
const hardware::health::V2_1::HealthInfo& info) {
LOC_LOGv("healthInfoChanged_2_1: %d", info.legacy.legacy.batteryStatus);
healthInfoChanged(info.legacy);
return Void();
}
static sp<BatteryListenerImpl> batteryListener;
status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb)
{
ALOGV("batteryPropertiesListenerInit entry");
bool batteryPropertiesListenerIsCharging() {
return batteryListener->isCharging();
}
status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb) {
batteryListener = new BatteryListenerImpl(cb);
bool isCharging = batteryPropertiesListenerIsCharging();
LOC_LOGv("charging status: %s charging", isCharging ? "" : "not");;
if (isCharging) {
cb(isCharging);
}
return NO_ERROR;
}
status_t batteryPropertiesListenerDeinit()
{
status_t batteryPropertiesListenerDeinit() {
batteryListener.clear();
return OK;
}
bool batteryPropertiesListenerIsCharging()
{
return batteryListener->isCharging();
}
} // namespace android
void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn)
{
ALOGV("loc_extn_battery_properties_listener_init entry");
void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn) {
LOC_LOGv("loc_extn_battery_properties_listener_init entry");
if (!sIsBatteryListened) {
std::thread t1(android::batteryPropertiesListenerInit,
[=](bool charging) { fn(charging); });
@@ -255,12 +273,10 @@ void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn)
}
}
void loc_extn_battery_properties_listener_deinit()
{
void loc_extn_battery_properties_listener_deinit() {
android::batteryPropertiesListenerDeinit();
}
bool loc_extn_battery_properties_is_charging()
{
bool loc_extn_battery_properties_is_charging() {
return android::batteryPropertiesListenerIsCharging();
}

31
gps/batching/Android.bp Normal file
View File

@@ -0,0 +1,31 @@
cc_library_shared {
name: "libbatching",
vendor: true,
sanitize: GNSS_SANITIZE,
shared_libs: [
"libutils",
"libcutils",
"liblog",
"libloc_core",
"libgps.utils",
"libdl",
],
srcs: [
"location_batching.cpp",
"BatchingAdapter.cpp",
],
header_libs: [
"libgps.utils_headers",
"libloc_core_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
cflags: GNSS_CFLAGS,
}

View File

@@ -1,36 +0,0 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libbatching
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
liblog \
libloc_core \
libgps.utils \
libdl
LOCAL_SRC_FILES += \
location_batching.cpp \
BatchingAdapter.cpp
LOCAL_HEADER_LIBRARIES := \
libgps.utils_headers \
libloc_core_headers \
libloc_pla_headers \
liblocation_api_headers
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS += $(GNSS_CFLAGS)
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

View File

@@ -22,8 +22,7 @@ libbatching_la_SOURCES = \
if USE_GLIB
libbatching_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
#libbatching_la_LDFLAGS = -lstdc++ -g -Wl,-z,defs -lpthread $(requiredlibs) @GLIB_LIBS@ -shared -avoid-version
libbatching_la_LDFLAGS = -lstdc++ -g -Wl,-z,defs -lpthread $(requiredlibs) @GLIB_LIBS@ -avoid-version
libbatching_la_LDFLAGS = -lstdc++ -g -Wl,-z,defs -lpthread $(requiredlibs) @GLIB_LIBS@ -shared -version-info 1:0:0
libbatching_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libbatching_la_CFLAGS = $(AM_CFLAGS)

View File

@@ -7,7 +7,7 @@ AC_PREREQ(2.61)
# Initialize the gps location-batching package version 1.0.0
AC_INIT([location-batching],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
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
@@ -37,10 +37,6 @@ PKG_CHECK_MODULES([LOCCORE], [loc-core])
AC_SUBST([LOCCORE_CFLAGS])
AC_SUBST([LOCCORE_LIBS])
PKG_CHECK_MODULES([GEOFENCE], [location-geofence])
AC_SUBST([GEOFENCE_CFLAGS])
AC_SUBST([GEOFENCE_LIBS])
AC_ARG_WITH([locpla_includes],
AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@],
[specify the path to locpla-includes in loc-pla_git.bb]),

56
gps/core/Android.bp Normal file
View File

@@ -0,0 +1,56 @@
cc_library_shared {
name: "libloc_core",
vendor: true,
sanitize: GNSS_SANITIZE,
shared_libs: [
"liblog",
"libutils",
"libcutils",
"libgps.utils",
"libdl",
"liblog",
],
srcs: [
"LocApiBase.cpp",
"LocAdapterBase.cpp",
"ContextBase.cpp",
"LocContext.cpp",
"loc_core_log.cpp",
"data-items/DataItemsFactoryProxy.cpp",
"SystemStatusOsObserver.cpp",
"SystemStatus.cpp",
],
cflags: [
"-fno-short-enums",
"-D_ANDROID_",
] + GNSS_CFLAGS,
local_include_dirs: [
"data-items",
"observer",
],
header_libs: [
"libutils_headers",
"libgps.utils_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
}
cc_library_headers {
name: "libloc_core_headers",
vendor: true,
export_include_dirs: ["."] + [
"data-items",
"observer",
],
}

View File

@@ -1,59 +0,0 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_core
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
liblog \
libutils \
libcutils \
libgps.utils \
libdl \
liblog
LOCAL_SRC_FILES += \
LocApiBase.cpp \
LocAdapterBase.cpp \
ContextBase.cpp \
LocContext.cpp \
loc_core_log.cpp \
data-items/DataItemsFactoryProxy.cpp \
SystemStatusOsObserver.cpp \
SystemStatus.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/data-items \
$(LOCAL_PATH)/data-items/common \
$(LOCAL_PATH)/observer \
LOCAL_HEADER_LIBRARIES := \
libutils_headers \
libgps.utils_headers \
libloc_pla_headers \
liblocation_api_headers
LOCAL_CFLAGS += $(GNSS_CFLAGS)
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_core_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/data-items \
$(LOCAL_PATH)/data-items/common \
$(LOCAL_PATH)/observer
include $(BUILD_HEADER_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014,2016-2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014,2016-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
@@ -30,7 +30,6 @@
#define LOG_TAG "LocSvc_CtxBase"
#include <dlfcn.h>
#include <cutils/sched_policy.h>
#include <unistd.h>
#include <ContextBase.h>
#include <msg_q.h>
@@ -40,12 +39,17 @@
namespace loc_core {
#define SLL_LOC_API_LIB_NAME "libsynergy_loc_api.so"
#define LOC_APIV2_0_LIB_NAME "libloc_api_v02.so"
#define IS_SS5_HW_ENABLED 1
loc_gps_cfg_s_type ContextBase::mGps_conf {};
loc_sap_cfg_s_type ContextBase::mSap_conf {};
bool ContextBase::sIsEngineCapabilitiesKnown = false;
uint64_t ContextBase::sSupportedMsgMask = 0;
bool ContextBase::sGnssMeasurementSupported = false;
uint8_t ContextBase::sFeaturesSupported[MAX_FEATURE_LENGTH];
GnssNMEARptRate ContextBase::sNmeaReportRate = GNSS_NMEA_REPORT_RATE_NHZ;
const loc_param_s_type ContextBase::mGps_conf_table[] =
{
@@ -61,12 +65,13 @@ const loc_param_s_type ContextBase::mGps_conf_table[] =
{"INTERMEDIATE_POS", &mGps_conf.INTERMEDIATE_POS, NULL, 'n'},
{"ACCURACY_THRES", &mGps_conf.ACCURACY_THRES, NULL, 'n'},
{"NMEA_PROVIDER", &mGps_conf.NMEA_PROVIDER, NULL, 'n'},
{"NMEA_REPORT_RATE", &mGps_conf.NMEA_REPORT_RATE, NULL, 's'},
{"CAPABILITIES", &mGps_conf.CAPABILITIES, NULL, 'n'},
{"XTRA_VERSION_CHECK", &mGps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
{"XTRA_SERVER_1", &mGps_conf.XTRA_SERVER_1, NULL, 's'},
{"XTRA_SERVER_2", &mGps_conf.XTRA_SERVER_2, NULL, 's'},
{"XTRA_SERVER_3", &mGps_conf.XTRA_SERVER_3, NULL, 's'},
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL",
&mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
{"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'},
{"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'},
{"SUPL_HOST", &mGps_conf.SUPL_HOST, NULL, 's'},
@@ -74,12 +79,21 @@ const loc_param_s_type ContextBase::mGps_conf_table[] =
{"MODEM_TYPE", &mGps_conf.MODEM_TYPE, NULL, 'n' },
{"MO_SUPL_HOST", &mGps_conf.MO_SUPL_HOST, NULL, 's' },
{"MO_SUPL_PORT", &mGps_conf.MO_SUPL_PORT, NULL, 'n' },
{"CONSTRAINED_TIME_UNCERTAINTY_ENABLED", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED, NULL, 'n'},
{"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, NULL, 'f'},
{"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'},
{"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED", &mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'},
{"CONSTRAINED_TIME_UNCERTAINTY_ENABLED",
&mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED, NULL, 'n'},
{"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD",
&mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, NULL, 'f'},
{"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET",
&mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'},
{"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED",
&mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'},
{"PROXY_APP_PACKAGE_NAME", &mGps_conf.PROXY_APP_PACKAGE_NAME, NULL, 's' },
{"CP_MTLR_ES", &mGps_conf.CP_MTLR_ES, NULL, 'n' },
{"GNSS_DEPLOYMENT", &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'},
{"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED",
&mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'},
{"NI_SUPL_DENY_ON_NFW_LOCKED", &mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED, NULL, 'n'},
{"ENABLE_NMEA_PRINT", &mGps_conf.ENABLE_NMEA_PRINT, NULL, 'n'}
};
const loc_param_s_type ContextBase::mSap_conf_table[] =
@@ -122,8 +136,6 @@ void ContextBase::readConfig()
mGps_conf.LPP_PROFILE = 0;
/*By default no positioning protocol is selected on A-GLONASS system*/
mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
/*XTRA version check is disabled by default*/
mGps_conf.XTRA_VERSION_CHECK=0;
/*Use emergency PDN by default*/
mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1;
/* By default no LPPe CP technology is enabled*/
@@ -166,15 +178,37 @@ void ContextBase::readConfig()
/* default configuration value of constrained time uncertainty mode:
feature disabled, time uncertainty threshold defined by modem,
and unlimited power budget */
#ifdef FEATURE_AUTOMOTIVE
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 1;
#else
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0;
#endif
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0;
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0;
/* default configuration value of position assisted clock estimator mode */
mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0;
/* default configuration QTI GNSS H/W */
mGps_conf.GNSS_DEPLOYMENT = 0;
mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0;
/* default configuration for NI_SUPL_DENY_ON_NFW_LOCKED */
mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED = 1;
/* By default NMEA Printing is disabled */
mGps_conf.ENABLE_NMEA_PRINT = 0;
UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table);
UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table);
if (strncmp(mGps_conf.NMEA_REPORT_RATE, "1HZ", sizeof(mGps_conf.NMEA_REPORT_RATE)) == 0) {
/* NMEA reporting is configured at 1Hz*/
sNmeaReportRate = GNSS_NMEA_REPORT_RATE_1HZ;
} else {
sNmeaReportRate = GNSS_NMEA_REPORT_RATE_NHZ;
}
LOC_LOGI("%s] GNSS Deployment: %s", __FUNCTION__,
((mGps_conf.GNSS_DEPLOYMENT == 1) ? "SS5" :
((mGps_conf.GNSS_DEPLOYMENT == 2) ? "QFUSION" : "QGNSS")));
switch (getTargetGnssType(loc_get_target())) {
case GNSS_GSS:
case GNSS_AUTO:
@@ -231,19 +265,24 @@ LBSProxyBase* ContextBase::getLBSProxy(const char* libName)
LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
{
LocApiBase* locApi = NULL;
const char* libname = LOC_APIV2_0_LIB_NAME;
// Check the target
if (TARGET_NO_GNSS != loc_get_target()){
if (NULL == (locApi = mLBSProxy->getLocApi(exMask, this))) {
void *handle = NULL;
//try to see if LocApiV02 is present
if ((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) {
LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__);
if (IS_SS5_HW_ENABLED == mGps_conf.GNSS_DEPLOYMENT) {
libname = SLL_LOC_API_LIB_NAME;
}
if ((handle = dlopen(libname, RTLD_NOW)) != NULL) {
LOC_LOGD("%s:%d]: %s is present", __func__, __LINE__, libname);
getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi");
if (getter != NULL) {
LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__,
__LINE__);
LOC_LOGD("%s:%d]: getter is not NULL of %s", __func__,
__LINE__, libname);
locApi = (*getter)(exMask, this);
}
}
@@ -294,6 +333,32 @@ void ContextBase::setEngineCapabilities(uint64_t supportedMsgMask,
(void *)featureList, sizeof(ContextBase::sFeaturesSupported));
}
/* */
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION)) {
static uint8_t isSapModeKnown = 0;
if (!isSapModeKnown) {
/* Check if SAP is PREMIUM_ENV_AIDING in izat.conf */
char conf_feature_sap[LOC_MAX_PARAM_STRING];
loc_param_s_type izat_conf_feature_table[] =
{
{ "SAP", &conf_feature_sap, &isSapModeKnown, 's' }
};
UTIL_READ_CONF(LOC_PATH_IZAT_CONF, izat_conf_feature_table);
/* Disable this feature if SAP is not PREMIUM_ENV_AIDING in izat.conf */
if (strcmp(conf_feature_sap, "PREMIUM_ENV_AIDING") != 0) {
uint8_t arrayIndex = LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION >> 3;
uint8_t bitPos = LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION & 7;
if (arrayIndex < MAX_FEATURE_LENGTH) {
/* To disable the feature we need to reset the bit on the "bitPos"
position, so shift a "1" to the left by "bitPos" */
ContextBase::sFeaturesSupported[arrayIndex] &= ~(1 << bitPos);
}
}
}
}
ContextBase::sIsEngineCapabilitiesKnown = true;
}
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-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
@@ -49,12 +49,12 @@ typedef struct loc_gps_cfg_s
uint32_t SUPL_ES;
uint32_t CAPABILITIES;
uint32_t LPP_PROFILE;
uint32_t XTRA_VERSION_CHECK;
char XTRA_SERVER_1[LOC_MAX_PARAM_STRING];
char XTRA_SERVER_2[LOC_MAX_PARAM_STRING];
char XTRA_SERVER_3[LOC_MAX_PARAM_STRING];
uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
uint32_t NMEA_PROVIDER;
char NMEA_REPORT_RATE[LOC_MAX_PARAM_NAME];
GnssConfigGpsLock GPS_LOCK;
uint32_t A_GLONASS_POS_PROTOCOL_SELECT;
uint32_t AGPS_CERT_WRITABLE_MASK;
@@ -73,15 +73,19 @@ typedef struct loc_gps_cfg_s
uint32_t POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED;
char PROXY_APP_PACKAGE_NAME[LOC_MAX_PARAM_STRING];
uint32_t CP_MTLR_ES;
uint32_t GNSS_DEPLOYMENT;
uint32_t CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED;
uint32_t NI_SUPL_DENY_ON_NFW_LOCKED;
uint32_t ENABLE_NMEA_PRINT;
} loc_gps_cfg_s_type;
/* NOTE: the implementaiton of the parser casts number
/* NOTE: the implementation of the parser casts number
fields to 32 bit. To ensure all 'n' fields working,
they must all be 32 bit fields. */
/* Meanwhile, *_valid fields are 8 bit fields, and 'f'
fields are double. Rigid as they are, it is the
the status quo, until the parsing mechanism is
change, that is. */
changed, that is. */
typedef struct
{
uint8_t GYRO_BIAS_RANDOM_WALK_VALID;
@@ -153,6 +157,7 @@ public:
static uint64_t sSupportedMsgMask;
static uint8_t sFeaturesSupported[MAX_FEATURE_LENGTH];
static bool sGnssMeasurementSupported;
static GnssNMEARptRate sNmeaReportRate;
void readConfig();
static uint32_t getCarrierCapabilities();

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 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
@@ -101,14 +101,21 @@ public:
(void) additionalSystemInfo;
return false;
}
inline virtual bool configLeverArm(const LeverArmConfigInfo& configInfo) {
(void) configInfo;
return false;
}
inline virtual bool configDeadReckoningEngineParams(
const DeadReckoningEngineConfig& dreConfig) {
(void) dreConfig;
return false;
}
};
typedef std::function<void(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask,
bool fromEngineHub)>
GnssAdapterReportPositionEventCb;
typedef std::function<void(int count, EngineLocationInfo* locationArr)>
GnssAdapterReportEnginePositionsEventCb;
typedef std::function<void(const GnssSvNotification& svNotify,
bool fromEngineHub)>
@@ -117,13 +124,18 @@ typedef std::function<void(const GnssSvNotification& svNotify,
typedef std::function<void(const GnssAidingDataSvMask& svDataMask)>
GnssAdapterReqAidingDataCb;
typedef std::function<void(bool nHzNeeded, bool nHzMeasNeeded)>
GnssAdapterUpdateNHzRequirementCb;
// potential parameters: message queue: MsgTask * msgTask;
// callback function to report back dr and ppe position and sv report
typedef EngineHubProxyBase* (getEngHubProxyFn)(const MsgTask * msgTask,
IOsObserver* osObserver,
GnssAdapterReportPositionEventCb positionEventCb,
GnssAdapterReportSvEventCb svEventCb,
GnssAdapterReqAidingDataCb reqAidingDataCb);
typedef EngineHubProxyBase* (getEngHubProxyFn)(
const MsgTask * msgTask,
IOsObserver* osObserver,
GnssAdapterReportEnginePositionsEventCb positionEventCb,
GnssAdapterReportSvEventCb svEventCb,
GnssAdapterReqAidingDataCb reqAidingDataCb,
GnssAdapterUpdateNHzRequirementCb updateNHzRequirementCb);
} // namespace loc_core

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-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
@@ -43,13 +43,20 @@ namespace loc_core {
// the right locApi should get created.
LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
ContextBase* context, bool isMaster,
LocAdapterProxyBase *adapterProxyBase) :
LocAdapterProxyBase *adapterProxyBase,
bool waitForDoneInit) :
mIsMaster(isMaster), mEvtMask(mask), mContext(context),
mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase),
mMsgTask(context->getMsgTask()),
mIsEngineCapabilitiesKnown(ContextBase::sIsEngineCapabilitiesKnown)
{
mLocApi->addAdapter(this);
LOC_LOGd("waitForDoneInit: %d", waitForDoneInit);
if (!waitForDoneInit) {
mLocApi->addAdapter(this);
mAdapterAdded = true;
} else {
mAdapterAdded = false;
}
}
uint32_t LocAdapterBase::mSessionIdCounter(1);
@@ -81,7 +88,6 @@ void LocAdapterBase::
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
bool /*fromEngineHub*/,
GnssDataNotification* pDataNotify,
int msInWeek)
{
@@ -179,6 +185,10 @@ DEFAULT_IMPL()
void LocAdapterBase::reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& /*config*/)
DEFAULT_IMPL()
void LocAdapterBase::reportGnssConfigEvent(uint32_t, /* session id*/
const GnssConfig& /*gnssConfig*/)
DEFAULT_IMPL()
bool LocAdapterBase::
requestOdcpiEvent(OdcpiRequestInfo& /*request*/)
DEFAULT_IMPL(false)
@@ -303,6 +313,15 @@ LocAdapterBase::getCapabilities()
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_LOCATION_PRIVACY)) {
mask |= LOCATION_CAPABILITIES_PRIVACY_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION)) {
mask |= LOCATION_CAPABILITIES_MEASUREMENTS_CORRECTION_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_ROBUST_LOCATION)) {
mask |= LOCATION_CAPABILITIES_CONFORMITY_INDEX_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_EDGNSS)) {
mask |= LOCATION_CAPABILITIES_EDGNSS_BIT;
}
} else {
LOC_LOGE("%s]: attempt to get capabilities before they are known.", __func__);
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-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
@@ -70,9 +70,11 @@ protected:
LocApiBase* mLocApi;
LocAdapterProxyBase* mLocAdapterProxyBase;
const MsgTask* mMsgTask;
bool mAdapterAdded;
inline LocAdapterBase(const MsgTask* msgTask) :
mIsMaster(false), mEvtMask(0), mContext(NULL), mLocApi(NULL),
mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
mLocAdapterProxyBase(NULL), mMsgTask(msgTask), mAdapterAdded(false) {}
/* ==== CLIENT ========================================================================= */
typedef std::map<LocationAPI*, LocationCallbacks> ClientDataMap;
@@ -89,9 +91,27 @@ protected:
public:
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
// When waitForDoneInit is not specified or specified as false,
// handleEngineUpEvent may be called on the child adapter object from
// a different thread before the constructor of the child
// object finishes.
//
// If the handleEngineUpEvent relies on member variables of the constructor
// of the child adapter to be initialized first, we need to specify the
// waitForDoneInit to *TRUE* to delay handleEngineUpEvent to get called
// until when the child adapter finishes its initialization and notify
// LocAdapterBase via doneInit method.
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
ContextBase* context, bool isMaster = false,
LocAdapterProxyBase *adapterProxyBase = NULL);
LocAdapterProxyBase *adapterProxyBase = NULL,
bool waitForDoneInit = false);
inline void doneInit() {
if (!mAdapterAdded) {
mLocApi->addAdapter(this);
mAdapterAdded = true;
}
}
inline LOC_API_ADAPTER_EVENT_MASK_T
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
@@ -151,9 +171,13 @@ public:
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
bool fromEngineHub = false,
GnssDataNotification* pDataNotify = nullptr,
int msInWeek = -1);
virtual void reportEnginePositionsEvent(unsigned int count,
EngineLocationInfo* locationArr) {
(void)count;
(void)locationArr;
}
virtual void reportSvEvent(const GnssSvNotification& svNotify,
bool fromEngineHub=false);
virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek);
@@ -182,6 +206,7 @@ public:
GpsLocationExtended &location_extended, LocPosTechMask tech_mask);
virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
virtual void reportGnssConfigEvent(uint32_t sessionId, const GnssConfig& gnssConfig);
virtual bool requestOdcpiEvent(OdcpiRequestInfo& request);
virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
virtual bool reportDeleteAidingDataEvent(GnssAidingData &aidingData);

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-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
@@ -330,7 +330,7 @@ void LocApiBase::reportPosition(UlpLocation& location,
"timestamp: %" PRId64 "\n"
"Session status: %d\n Technology mask: %u\n "
"SV used in fix (gps/glo/bds/gal/qzss) : \
(0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 ")",
(0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 ")",
location.gpsLocation.flags, location.position_source,
location.gpsLocation.latitude, location.gpsLocation.longitude,
location.gpsLocation.altitude, location.gpsLocation.speed,
@@ -340,12 +340,12 @@ void LocApiBase::reportPosition(UlpLocation& location,
locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask);
locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.navic_sv_used_ids_mask);
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportPositionEvent(location, locationExtended,
status, loc_technology_mask,
false,
pDataNotify, msInWeek)
);
}
@@ -407,28 +407,27 @@ void LocApiBase::reportSv(GnssSvNotification& svNotify)
// print the SV info before delivering
LOC_LOGV("num sv: %u\n"
" sv: constellation svid cN0"
" sv: constellation svid cN0 basebandCN0"
" elevation azimuth flags",
svNotify.count);
for (size_t i = 0; i < svNotify.count && i < LOC_GNSS_MAX_SVS; i++) {
for (size_t i = 0; i < svNotify.count && i < GNSS_SV_MAX; i++) {
if (svNotify.gnssSvs[i].type >
sizeof(constellationString) / sizeof(constellationString[0]) - 1) {
svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
}
// Display what we report to clients
uint16_t displaySvId = GNSS_SV_TYPE_QZSS == svNotify.gnssSvs[i].type ?
svNotify.gnssSvs[i].svId + QZSS_SV_PRN_MIN - 1 :
svNotify.gnssSvs[i].svId;
LOC_LOGV(" %03zu: %*s %02d %f %f %f %f 0x%02X",
LOC_LOGV(" %03zu: %*s %02d %f %f %f %f %f 0x%02X 0x%2X",
i,
13,
constellationString[svNotify.gnssSvs[i].type],
displaySvId,
svNotify.gnssSvs[i].svId,
svNotify.gnssSvs[i].cN0Dbhz,
svNotify.gnssSvs[i].basebandCarrierToNoiseDbHz,
svNotify.gnssSvs[i].elevation,
svNotify.gnssSvs[i].azimuth,
svNotify.gnssSvs[i].carrierFrequencyHz,
svNotify.gnssSvs[i].gnssSvOptionsMask);
svNotify.gnssSvs[i].gnssSvOptionsMask,
svNotify.gnssSvs[i].gnssSignalTypeMask);
}
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
@@ -542,9 +541,10 @@ void LocApiBase::reportGnssSvIdConfig(const GnssSvIdConfig& config)
{
// Print the config
LOC_LOGv("gloBlacklistSvMask: %" PRIu64 ", bdsBlacklistSvMask: %" PRIu64 ",\n"
"qzssBlacklistSvMask: %" PRIu64 ", galBlacklistSvMask: %" PRIu64,
"qzssBlacklistSvMask: %" PRIu64 ", galBlacklistSvMask: %" PRIu64 ",\n"
"navicBlacklistSvMask: %" PRIu64,
config.gloBlacklistSvMask, config.bdsBlacklistSvMask,
config.qzssBlacklistSvMask, config.galBlacklistSvMask);
config.qzssBlacklistSvMask, config.galBlacklistSvMask, config.navicBlacklistSvMask);
// Loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvIdConfigEvent(config));
@@ -594,6 +594,11 @@ void LocApiBase::handleBatchStatusEvent(BatchingStatus batchStatus)
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportBatchStatusChangeEvent(batchStatus));
}
void LocApiBase::reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig)
{
// loop through adapters, and deliver to the first handling adapter.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssConfigEvent(sessionId, gnssConfig));
}
enum loc_api_adapter_err LocApiBase::
open(LOC_API_ADAPTER_EVENT_MASK_T /*mask*/)
@@ -614,7 +619,8 @@ void LocApiBase::
DEFAULT_IMPL()
void LocApiBase::
injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/,
bool /*onDemandCpi*/)
DEFAULT_IMPL()
void LocApiBase::
@@ -664,7 +670,7 @@ enum loc_api_adapter_err LocApiBase::
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setLPPConfigSync(GnssConfigLppProfile /*profile*/)
setLPPConfigSync(GnssConfigLppProfileMask /*profileMask*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
@@ -709,9 +715,6 @@ DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
GnssConfigSuplVersion LocApiBase::convertSuplVersion(const uint32_t /*suplVersion*/)
DEFAULT_IMPL(GNSS_CONFIG_SUPL_VERSION_1_0_0)
GnssConfigLppProfile LocApiBase::convertLppProfile(const uint32_t /*lppProfile*/)
DEFAULT_IMPL(GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE)
GnssConfigLppeControlPlaneMask LocApiBase::convertLppeCp(const uint32_t /*lppeControlPlaneMask*/)
DEFAULT_IMPL(0)
@@ -722,6 +725,10 @@ LocationError LocApiBase::setEmergencyExtensionWindowSync(
const uint32_t /*emergencyExtensionSeconds*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::setMeasurementCorrections(
const GnssMeasurementCorrections /*gnssMeasurementCorrections*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
getWwanZppFix()
DEFAULT_IMPL()
@@ -751,30 +758,34 @@ DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::setBlacklistSvSync(const GnssSvIdConfig& /*config*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::setBlacklistSv(const GnssSvIdConfig& /*config*/)
void LocApiBase::setBlacklistSv(const GnssSvIdConfig& /*config*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::getBlacklistSv()
DEFAULT_IMPL()
void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/)
void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::getConstellationControl()
DEFAULT_IMPL()
void LocApiBase::resetConstellationControl()
void LocApiBase::resetConstellationControl(LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::
void LocApiBase::
setConstrainedTuncMode(bool /*enabled*/,
float /*tuncConstraint*/,
uint32_t /*energyBudget*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
uint32_t /*energyBudget*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::
setPositionAssistedClockEstimatorMode(bool /*enabled*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
setPositionAssistedClockEstimatorMode(bool /*enabled*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::getGnssEnergyConsumed()
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
@@ -874,5 +885,42 @@ DEFAULT_IMPL()
void LocApiBase::addToCallQueue(LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::updateSystemPowerState(PowerStateType /*powerState*/)
DEFAULT_IMPL()
void LocApiBase::
configRobustLocation(bool /*enabled*/,
bool /*enableForE911*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
getRobustLocationConfig(uint32_t sessionId, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
configMinGpsWeek(uint16_t minGpsWeek,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
getMinGpsWeek(uint32_t sessionId, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::
setParameterSync(const GnssConfig& gnssConfig)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
getParameter(uint32_t sessionId, GnssConfigFlagsMask flags, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
configConstellationMultiBand(const GnssSvTypeConfig& secondaryBandConfig,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
getConstellationMultiBandConfig(uint32_t sessionId, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
} // namespace loc_core

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2016-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
@@ -59,13 +59,6 @@ int decodeAddress(char *addr_string, int string_size,
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
enum xtra_version_check {
DISABLED,
AUTO,
XTRA2,
XTRA3
};
class LocAdapterBase;
struct LocSsrMsg;
struct LocOpenMsg;
@@ -97,6 +90,8 @@ public:
inline LocApiProxyBase() {}
inline virtual ~LocApiProxyBase() {}
inline virtual void* getSibling2() { return NULL; }
inline virtual double getGloRfLoss(uint32_t left,
uint32_t center, uint32_t right, uint8_t gloFrequency) { return 0.0; }
};
class LocApiBase {
@@ -196,6 +191,7 @@ public:
void reportKlobucharIonoModel(GnssKlobucharIonoModel& ionoModel);
void reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo);
void sendNfwNotification(GnssNfwNotification& notification);
void reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig);
void geofenceBreach(size_t count, uint32_t* hwIds, Location& location,
GeofenceBreachType breachType, uint64_t timestamp);
@@ -214,7 +210,8 @@ public:
virtual void startFix(const LocPosMode& fixCriteria, LocApiResponse* adapterResponse);
virtual void stopFix(LocApiResponse* adapterResponse);
virtual void deleteAidingData(const GnssAidingData& data, LocApiResponse* adapterResponse);
virtual void injectPosition(double latitude, double longitude, float accuracy);
virtual void injectPosition(double latitude, double longitude, float accuracy,
bool onDemandCpi);
virtual void injectPosition(const GnssLocationInfoNotification &locationInfo,
bool onDemandCpi=false);
virtual void injectPosition(const Location& location, bool onDemandCpi);
@@ -228,7 +225,7 @@ public:
virtual void informNiResponse(GnssNiResponse userResponse, const void* passThroughData);
virtual LocationError setSUPLVersionSync(GnssConfigSuplVersion version);
virtual enum loc_api_adapter_err setNMEATypesSync(uint32_t typesMask);
virtual LocationError setLPPConfigSync(GnssConfigLppProfile profile);
virtual LocationError setLPPConfigSync(GnssConfigLppProfileMask profileMask);
virtual enum loc_api_adapter_err setSensorPropertiesSync(
bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,
@@ -244,10 +241,11 @@ public:
virtual LocationError setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask lppeCP);
virtual LocationError setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask lppeUP);
virtual GnssConfigSuplVersion convertSuplVersion(const uint32_t suplVersion);
virtual GnssConfigLppProfile convertLppProfile(const uint32_t lppProfile);
virtual GnssConfigLppeControlPlaneMask convertLppeCp(const uint32_t lppeControlPlaneMask);
virtual GnssConfigLppeUserPlaneMask convertLppeUp(const uint32_t lppeUserPlaneMask);
virtual LocationError setEmergencyExtensionWindowSync(const uint32_t emergencyExtensionSeconds);
virtual LocationError setMeasurementCorrections(
const GnssMeasurementCorrections gnssMeasurementCorrections);
virtual void getWwanZppFix();
virtual void getBestAvailableZppFix();
@@ -258,14 +256,20 @@ public:
virtual LocationError setXtraVersionCheckSync(uint32_t check);
/* Requests for SV/Constellation Control */
virtual LocationError setBlacklistSvSync(const GnssSvIdConfig& config);
virtual void setBlacklistSv(const GnssSvIdConfig& config);
virtual void setBlacklistSv(const GnssSvIdConfig& config,
LocApiResponse *adapterResponse=nullptr);
virtual void getBlacklistSv();
virtual void setConstellationControl(const GnssSvTypeConfig& config);
virtual void setConstellationControl(const GnssSvTypeConfig& config,
LocApiResponse *adapterResponse=nullptr);
virtual void getConstellationControl();
virtual void resetConstellationControl();
virtual LocationError setConstrainedTuncMode(bool enabled, float tuncConstraint,
uint32_t energyBudget);
virtual LocationError setPositionAssistedClockEstimatorMode(bool enabled);
virtual void resetConstellationControl(LocApiResponse *adapterResponse=nullptr);
virtual void setConstrainedTuncMode(bool enabled,
float tuncConstraint,
uint32_t energyBudget,
LocApiResponse* adapterResponse=nullptr);
virtual void setPositionAssistedClockEstimatorMode(bool enabled,
LocApiResponse* adapterResponse=nullptr);
virtual LocationError getGnssEnergyConsumed();
virtual void addGeofence(uint32_t clientId, const GeofenceOption& options,
@@ -312,6 +316,23 @@ public:
void updateEvtMask();
void updateNmeaMask(uint32_t mask);
virtual void updateSystemPowerState(PowerStateType systemPowerState);
virtual void configRobustLocation(bool enable, bool enableForE911,
LocApiResponse* adapterResponse=nullptr);
virtual void getRobustLocationConfig(uint32_t sessionId, LocApiResponse* adapterResponse);
virtual void configMinGpsWeek(uint16_t minGpsWeek,
LocApiResponse* adapterResponse=nullptr);
virtual void getMinGpsWeek(uint32_t sessionId, LocApiResponse* adapterResponse);
virtual LocationError setParameterSync(const GnssConfig & gnssConfig);
virtual void getParameter(uint32_t sessionId, GnssConfigFlagsMask flags,
LocApiResponse* adapterResponse=nullptr);
virtual void configConstellationMultiBand(const GnssSvTypeConfig& secondaryBandConfig,
LocApiResponse* adapterResponse=nullptr);
virtual void getConstellationMultiBandConfig(uint32_t sessionId,
LocApiResponse* adapterResponse=nullptr);
};
typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask,

View File

@@ -40,6 +40,10 @@ libloc_core_la_c_sources = \
SystemStatusOsObserver.cpp \
SystemStatus.cpp
if USE_EXTERNAL_AP
AM_CFLAGS += -DFEATURE_EXTERNAL_AP
endif
library_includedir = $(pkgincludedir)
library_include_HEADERS = $(libloc_core_la_h_sources)
@@ -56,6 +60,10 @@ libloc_core_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0
libloc_core_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
if USE_FEATURE_AUTOMOTIVE
AM_CFLAGS += -DFEATURE_AUTOMOTIVE
endif
libloc_core_la_LIBADD = -ldl $(GPSUTILS_LIBS)
#Create and Install libraries

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017, 2019, The Linux Foundation. All rights reserved.
/* 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
@@ -158,6 +158,7 @@ private:
eAgcGlo = 20,
eAgcBds = 21,
eAgcGal = 22,
eMax0 = eAgcGal,
eLeapSeconds = 23,
eLeapSecUnc = 24,
eGloBpAmpI = 25,
@@ -166,7 +167,6 @@ private:
eBdsBpAmpQ = 28,
eGalBpAmpI = 29,
eGalBpAmpQ = 30,
eMax0 = eGalBpAmpQ,
eTimeUncNs = 31,
eMax
};
@@ -660,6 +660,7 @@ private:
{
eTalker = 0,
eUtcTime = 1,
eMin = 2 + SV_ALL_NUM_MIN*3,
eMax = 2 + SV_ALL_NUM*3
};
SystemStatusPQWP7 mP7;
@@ -668,11 +669,18 @@ public:
SystemStatusPQWP7parser(const char *str_in, uint32_t len_in)
: SystemStatusNmeaBase(str_in, len_in)
{
if (mField.size() < eMax) {
uint32_t svLimit = SV_ALL_NUM;
if (mField.size() < eMin) {
LOC_LOGE("PQWP7parser - invalid size=%zu", mField.size());
return;
}
for (uint32_t i=0; i<SV_ALL_NUM; i++) {
if (mField.size() < eMax) {
// Try reducing limit, accounting for possibly missing NAVIC support
svLimit = SV_ALL_NUM_MIN;
}
memset(mP7.mNav, 0, sizeof(mP7.mNav));
for (uint32_t i=0; i<svLimit; i++) {
mP7.mNav[i].mType = GnssEphemerisType(atoi(mField[i*3+2].c_str()));
mP7.mNav[i].mSource = GnssEphemerisSource(atoi(mField[i*3+3].c_str()));
mP7.mNav[i].mAgeSec = atoi(mField[i*3+4].c_str());
@@ -1338,6 +1346,9 @@ SystemStatus::SystemStatus(const MsgTask* msgTask) :
template <typename TYPE_REPORT, typename TYPE_ITEM>
bool SystemStatus::setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s)
{
if (s.ignore()) {
return false;
}
if (!report.empty() && report.back().equals(static_cast<TYPE_ITEM&>(s.collate(report.back())))) {
// there is no change - just update reported timestamp
report.back().mUtcReported = s.mUtcReported;

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -59,7 +59,8 @@
#define BDS_NUM (37)
#define GAL_NUM (36)
#define NAVIC_NUM (14)
#define SV_ALL_NUM (GPS_NUM+GLO_NUM+QZSS_NUM+BDS_NUM+GAL_NUM+NAVIC_NUM) //=148
#define SV_ALL_NUM_MIN (GPS_NUM + GLO_NUM + QZSS_NUM + BDS_NUM + GAL_NUM) //=134
#define SV_ALL_NUM (SV_ALL_NUM_MIN + NAVIC_NUM) //=148
namespace loc_core
{
@@ -86,6 +87,7 @@ public:
return *this;
}
virtual void dump(void) {};
inline virtual bool ignore() { return false; };
};
class SystemStatusLocation : public SystemStatusItemBase
@@ -102,7 +104,7 @@ public:
mLocation(location),
mLocationEx(locationEx) {}
bool equals(const SystemStatusLocation& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWM1;
@@ -132,7 +134,7 @@ public:
mTimeUncNs(0ULL) {}
inline SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusTimeAndClock& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusXoState : public SystemStatusItemBase
@@ -143,7 +145,7 @@ public:
mXoState(0) {}
inline SystemStatusXoState(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusXoState& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusRfAndParams : public SystemStatusItemBase
@@ -190,7 +192,7 @@ public:
mGalBpAmpQ(0) {}
inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusRfAndParams& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusErrRecovery : public SystemStatusItemBase
@@ -201,7 +203,8 @@ public:
mRecErrorRecovery(0) {};
inline SystemStatusErrRecovery(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusErrRecovery& peer);
void dump(void);
inline bool ignore() override { return 0 == mRecErrorRecovery; };
void dump(void) override;
};
class SystemStatusPQWP1;
@@ -225,7 +228,7 @@ public:
mEpiSrc(0) {}
inline SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea);
bool equals(const SystemStatusInjectedPosition& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWP2;
@@ -247,7 +250,7 @@ public:
mBestAltUnc(0) {}
inline SystemStatusBestPosition(const SystemStatusPQWP2& nmea);
bool equals(const SystemStatusBestPosition& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWP3;
@@ -283,7 +286,7 @@ public:
mNavicXtraValid(0) {}
inline SystemStatusXtra(const SystemStatusPQWP3& nmea);
bool equals(const SystemStatusXtra& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWP4;
@@ -303,7 +306,7 @@ public:
mQzssEpheValid(0) {}
inline SystemStatusEphemeris(const SystemStatusPQWP4& nmea);
bool equals(const SystemStatusEphemeris& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWP5;
@@ -349,7 +352,7 @@ public:
mNavicBadMask(0) {}
inline SystemStatusSvHealth(const SystemStatusPQWP5& nmea);
bool equals(const SystemStatusSvHealth& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWP6;
@@ -361,7 +364,7 @@ public:
mFixInfoMask(0) {}
inline SystemStatusPdr(const SystemStatusPQWP6& nmea);
bool equals(const SystemStatusPdr& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWP7;
@@ -385,7 +388,7 @@ public:
}
inline SystemStatusNavData(const SystemStatusPQWP7& nmea);
bool equals(const SystemStatusNavData& peer);
void dump(void);
void dump(void) override;
};
class SystemStatusPQWS1;
@@ -399,7 +402,7 @@ public:
mHepeLimit(0) {}
inline SystemStatusPositionFailure(const SystemStatusPQWS1& nmea);
bool equals(const SystemStatusPositionFailure& peer);
void dump(void);
void dump(void) override;
};
/******************************************************************************
@@ -548,6 +551,9 @@ public:
typeCount--;
}
}
if (MAX_NETWORK_HANDLES == lastValidIndex) {
--lastValidIndex;
}
if (MAX_NETWORK_HANDLES != deletedIndex) {
LOC_LOGD("deletedIndex:%u, lastValidIndex:%u, typeCount:%u",
@@ -758,7 +764,7 @@ public:
inline bool equals(const SystemStatusTac& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
inline void dump(void) override {
LOC_LOGD("Tac: value=%s", mValue.c_str());
}
};
@@ -774,7 +780,7 @@ public:
inline bool equals(const SystemStatusMccMnc& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
inline void dump(void) override {
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
}
};

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-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
@@ -38,7 +38,7 @@ namespace loc_core
{
template <typename CINT, typename COUT>
COUT SystemStatusOsObserver::containerTransfer(CINT& inContainer) {
COUT outContainer(0);
COUT outContainer = {};
for (auto item : inContainer) {
outContainer.insert(outContainer.begin(), item);
}
@@ -67,6 +67,7 @@ void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscript
inline SetSubsObj(ObserverContext& context, IDataItemSubscription* subscriptionObj) :
mContext(context), mSubsObj(subscriptionObj) {}
void proc() const {
LOC_LOGi("SetSubsObj::enter");
mContext.mSubscriptionObj = mSubsObj;
if (!mContext.mSSObserver->mDataItemToClients.empty()) {
@@ -76,6 +77,7 @@ void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscript
mContext.mSubscriptionObj->subscribe(dis, mContext.mSSObserver);
mContext.mSubscriptionObj->requestData(dis, mContext.mSSObserver);
}
LOC_LOGi("SetSubsObj::exit");
}
};
@@ -101,7 +103,7 @@ void SystemStatusOsObserver::subscribe(const list<DataItemId>& l, IDataItemObser
mToRequestData(requestData) {}
void proc() const {
unordered_set<DataItemId> dataItemsToSubscribe(0);
unordered_set<DataItemId> dataItemsToSubscribe = {};
mParent->mDataItemToClients.add(mDataItemSet, {mClient}, &dataItemsToSubscribe);
mParent->mClientToDataItems.add(mClient, mDataItemSet);
@@ -147,8 +149,8 @@ void SystemStatusOsObserver::updateSubscription(
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
void proc() const {
unordered_set<DataItemId> dataItemsToSubscribe(0);
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
unordered_set<DataItemId> dataItemsToSubscribe = {};
unordered_set<DataItemId> dataItemsToUnsubscribe = {};
unordered_set<IDataItemObserver*> clients({mClient});
// below removes clients from all entries keyed with the return of the
// mClientToDataItems.update() call. If leaving an empty set of clients as the
@@ -219,11 +221,11 @@ void SystemStatusOsObserver::unsubscribe(
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
void proc() const {
unordered_set<DataItemId> dataItemsUnusedByClient(0);
unordered_set<IDataItemObserver*> clientToRemove(0);
unordered_set<DataItemId> dataItemsUnusedByClient = {};
unordered_set<IDataItemObserver*> clientToRemove = {};
unordered_set<DataItemId> dataItemsToUnsubscribe = {};
mParent->mClientToDataItems.trimOrRemove({mClient}, mDataItemSet, &clientToRemove,
&dataItemsUnusedByClient);
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
mParent->mDataItemToClients.trimOrRemove(dataItemsUnusedByClient, {mClient},
&dataItemsToUnsubscribe, nullptr);
@@ -259,6 +261,7 @@ void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
void proc() const {
unordered_set<DataItemId> diByClient = mParent->mClientToDataItems.getValSet(mClient);
if (!diByClient.empty()) {
unordered_set<DataItemId> dataItemsToUnsubscribe;
mParent->mClientToDataItems.remove(mClient);
@@ -308,7 +311,7 @@ void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
void proc() const {
// Update Cache with received data items and prepare
// list of data items to be sent.
unordered_set<DataItemId> dataItemIdsToBeSent(0);
unordered_set<DataItemId> dataItemIdsToBeSent = {};
for (auto item : mDiVec) {
if (mParent->updateCache(item)) {
dataItemIdsToBeSent.insert(item->getId());
@@ -316,7 +319,7 @@ void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
}
// Send data item to all subscribed clients
unordered_set<IDataItemObserver*> clientSet(0);
unordered_set<IDataItemObserver*> clientSet = {};
for (auto each : dataItemIdsToBeSent) {
auto clients = mParent->mDataItemToClients.getValSetPtr(each);
if (nullptr != clients) {
@@ -347,11 +350,6 @@ void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
vector<IDataItemCore*> dataItemVec(dlist.size());
for (auto each : dlist) {
IF_LOC_LOGD {
string dv;
each->stringify(dv);
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
}
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
if (nullptr == di) {
@@ -364,6 +362,11 @@ void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
// add this dataitem if updated from last one
dataItemVec.push_back(di);
IF_LOC_LOGD {
string dv;
di->stringify(dv);
LOC_LOGd("notify: DataItem In Value:%s", dv.c_str());
}
}
if (!dataItemVec.empty()) {
@@ -448,60 +451,74 @@ void SystemStatusOsObserver::turnOff(DataItemId dit)
}
}
#ifdef USE_QCMAP
bool SystemStatusOsObserver::connectBackhaul()
#ifdef USE_GLIB
bool SystemStatusOsObserver::connectBackhaul(const string& clientName)
{
bool result = false;
if (mContext.mFrameworkActionReqObj != NULL) {
struct HandleConnectBackhaul : public LocMsg {
HandleConnectBackhaul(IFrameworkActionReq* fwkActReq) :
mFwkActionReqObj(fwkActReq) {}
HandleConnectBackhaul(IFrameworkActionReq* fwkActReq, const string& clientName) :
mClientName(clientName), mFwkActionReqObj(fwkActReq) {}
virtual ~HandleConnectBackhaul() {}
void proc() const {
LOC_LOGD("HandleConnectBackhaul");
mFwkActionReqObj->connectBackhaul();
LOC_LOGi("HandleConnectBackhaul::enter");
mFwkActionReqObj->connectBackhaul(mClientName);
LOC_LOGi("HandleConnectBackhaul::exit");
}
IFrameworkActionReq* mFwkActionReqObj;
string mClientName;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleConnectBackhaul(mContext.mFrameworkActionReqObj));
new (nothrow) HandleConnectBackhaul(mContext.mFrameworkActionReqObj, clientName));
result = true;
}
else {
++mBackHaulConnectReqCount;
LOC_LOGE("Framework action request object is NULL.Caching connect request: %d",
mBackHaulConnectReqCount);
LOC_LOGe("Framework action request object is NULL.Caching connect request: %s",
clientName.c_str());
ClientBackhaulReqCache::const_iterator iter = mBackHaulConnReqCache.find(clientName);
if (iter == mBackHaulConnReqCache.end()) {
// not found in set. first time receiving from request from client
LOC_LOGe("Adding client to BackHaulConnReqCache list");
mBackHaulConnReqCache.insert(clientName);
}
result = false;
}
return result;
}
bool SystemStatusOsObserver::disconnectBackhaul()
bool SystemStatusOsObserver::disconnectBackhaul(const string& clientName)
{
bool result = false;
if (mContext.mFrameworkActionReqObj != NULL) {
struct HandleDisconnectBackhaul : public LocMsg {
HandleDisconnectBackhaul(IFrameworkActionReq* fwkActReq) :
mFwkActionReqObj(fwkActReq) {}
HandleDisconnectBackhaul(IFrameworkActionReq* fwkActReq, const string& clientName) :
mClientName(clientName), mFwkActionReqObj(fwkActReq) {}
virtual ~HandleDisconnectBackhaul() {}
void proc() const {
LOC_LOGD("HandleDisconnectBackhaul");
mFwkActionReqObj->disconnectBackhaul();
LOC_LOGi("HandleDisconnectBackhaul::enter");
mFwkActionReqObj->disconnectBackhaul(mClientName);
LOC_LOGi("HandleDisconnectBackhaul::exit");
}
IFrameworkActionReq* mFwkActionReqObj;
string mClientName;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleDisconnectBackhaul(mContext.mFrameworkActionReqObj));
new (nothrow) HandleDisconnectBackhaul(mContext.mFrameworkActionReqObj,
clientName));
}
else {
if (mBackHaulConnectReqCount > 0) {
--mBackHaulConnectReqCount;
LOC_LOGe("Framework action request object is NULL.Caching disconnect request: %s",
clientName.c_str());
// Check if client has requested for backhaul connection.
ClientBackhaulReqCache::const_iterator iter = mBackHaulConnReqCache.find(clientName);
if (iter != mBackHaulConnReqCache.end()) {
// client found, remove from set.
LOC_LOGd("Removing client from BackHaulConnReqCache list");
mBackHaulConnReqCache.erase(iter);
}
LOC_LOGE("Framework action request object is NULL.Caching disconnect request: %d",
mBackHaulConnectReqCount);
result = false;
}
return result;
@@ -518,7 +535,7 @@ void SystemStatusOsObserver::sendCachedDataItems(
} else {
string clientName;
to->getName(clientName);
list<IDataItemCore*> dataItems(0);
list<IDataItemCore*> dataItems = {};
for (auto each : s) {
auto citer = mDataItemCache.find(each);

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-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
@@ -60,6 +60,10 @@ typedef LocUnorderedSetMap<IDataItemObserver*, DataItemId> ClientToDataItems;
typedef LocUnorderedSetMap<DataItemId, IDataItemObserver*> DataItemToClients;
typedef unordered_map<DataItemId, IDataItemCore*> DataItemIdToCore;
typedef unordered_map<DataItemId, int> DataItemIdToInt;
#ifdef USE_GLIB
// Cache details of backhaul client requests
typedef unordered_set<string> ClientBackhaulReqCache;
#endif
struct ObserverContext {
IDataItemSubscription* mSubscriptionObj;
@@ -83,12 +87,7 @@ public:
inline SystemStatusOsObserver(SystemStatus* systemstatus, const MsgTask* msgTask) :
mSystemStatus(systemstatus), mContext(msgTask, this),
mAddress("SystemStatusOsObserver"),
mClientToDataItems(MAX_DATA_ITEM_ID), mDataItemToClients(MAX_DATA_ITEM_ID)
#ifdef USE_QCMAP
, mBackHaulConnectReqCount(0)
#endif
{
}
mClientToDataItems(MAX_DATA_ITEM_ID), mDataItemToClients(MAX_DATA_ITEM_ID) {}
// dtor
~SystemStatusOsObserver();
@@ -106,10 +105,16 @@ public:
// To set the framework action request object
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
#ifdef USE_QCMAP
if (mBackHaulConnectReqCount > 0) {
connectBackhaul();
mBackHaulConnectReqCount = 0;
#ifdef USE_GLIB
uint32_t numBackHaulClients = mBackHaulConnReqCache.size();
if (numBackHaulClients > 0) {
// For each client, invoke connectbackhaul.
for (auto clientName : mBackHaulConnReqCache) {
LOC_LOGd("Invoke connectBackhaul for client: %s", clientName.c_str());
connectBackhaul(clientName);
}
// Clear the set
mBackHaulConnReqCache.clear();
}
#endif
}
@@ -134,9 +139,9 @@ public:
// IFrameworkActionReq Overrides
virtual void turnOn(DataItemId dit, int timeOut = 0) override;
virtual void turnOff(DataItemId dit) override;
#ifdef USE_QCMAP
virtual bool connectBackhaul() override;
virtual bool disconnectBackhaul();
#ifdef USE_GLIB
virtual bool connectBackhaul(const string& clientName) override;
virtual bool disconnectBackhaul(const string& clientName) override;
#endif
private:
@@ -151,9 +156,9 @@ private:
// Cache the subscribe and requestData till subscription obj is obtained
void cacheObserverRequest(ObserverReqCache& reqCache,
const list<DataItemId>& l, IDataItemObserver* client);
#ifdef USE_QCMAP
#ifdef USE_GLIB
// Cache the framework action request for connect/disconnect
int mBackHaulConnectReqCount;
ClientBackhaulReqCache mBackHaulConnReqCache;
#endif
void subscribe(const list<DataItemId>& l, IDataItemObserver* client, bool toRequestData);

View File

@@ -7,7 +7,7 @@ AC_PREREQ(2.61)
# Initialize the gps loc-hal package version 1.0.0
AC_INIT([loc-core],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
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
@@ -74,6 +74,31 @@ fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_ARG_WITH([auto_feature],
AC_HELP_STRING([--with-auto_feature=@<:@dir@:>@],
[Using Automotive feature]),
[],
with_auto_feature=no)
if test "x$with_auto_feature" != "xno"; then
CPPFLAGS="${CPPFLAGS} -DFEATURE_AUTOMOTIVE"
fi
AM_CONDITIONAL(USE_FEATURE_AUTOMOTIVE, test "x${with_auto_feature}" = "xyes")
# External AP
AC_ARG_WITH([external_ap],
AC_HELP_STRING([--with-external_ap=@<:@dir@:>@],
[Using External Application Processor]),
[],
with_external_ap=no)
if test "x$with_external_ap" != "xno"; then
CPPFLAGS="${CPPFLAGS} -DFEATURE_EXTERNAL_AP"
fi
AM_CONDITIONAL(USE_EXTERNAL_AP, test "x${with_external_ap}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
loc-core.pc \

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* 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
@@ -34,6 +34,7 @@
#include <DataItemsFactoryProxy.h>
#include <loc_pla.h>
#include <log_util.h>
#include "loc_misc_utils.h"
namespace loc_core
{
@@ -48,40 +49,21 @@ IDataItemCore* DataItemsFactoryProxy::createNewDataItem(DataItemId id)
mydi = (*getConcreteDIFunc)(id);
}
else {
// first call to this function, symbol not yet loaded
if (NULL == dataItemLibHandle) {
LOC_LOGD("Loaded library %s",DATA_ITEMS_LIB_NAME);
dataItemLibHandle = dlopen(DATA_ITEMS_LIB_NAME, RTLD_NOW);
if (NULL == dataItemLibHandle) {
// dlopen failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGE("%s:%d]: failed to load library %s; error=%s",
__func__, __LINE__, DATA_ITEMS_LIB_NAME, err);
}
}
getConcreteDIFunc = (get_concrete_data_item_fn * )
dlGetSymFromLib(dataItemLibHandle, DATA_ITEMS_LIB_NAME, DATA_ITEMS_GET_CONCRETE_DI);
// load sym - if dlopen handle is obtained and symbol is not yet obtained
if (NULL != dataItemLibHandle) {
getConcreteDIFunc = (get_concrete_data_item_fn * )
dlsym(dataItemLibHandle, DATA_ITEMS_GET_CONCRETE_DI);
if (NULL != getConcreteDIFunc) {
LOC_LOGD("Loaded function %s : %p",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
mydi = (*getConcreteDIFunc)(id);
}
else {
// dlysm failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGE("%s:%d]: failed to find symbol %s; error=%s",
__func__, __LINE__, DATA_ITEMS_GET_CONCRETE_DI, err);
if (NULL != getConcreteDIFunc) {
LOC_LOGd("Loaded function %s : %p", DATA_ITEMS_GET_CONCRETE_DI, getConcreteDIFunc);
mydi = (*getConcreteDIFunc)(id);
}
else {
// dlysm failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGe("failed to find symbol %s; error=%s", DATA_ITEMS_GET_CONCRETE_DI, err);
}
}
return mydi;

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2015, 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
@@ -53,7 +53,7 @@ void LocPosMode::logv() const
}
/* GPS status names */
static const loc_name_val_s_type gps_status_name[] =
DECLARE_TBL(gps_status_name) =
{
NAME_VAL( LOC_GPS_STATUS_NONE ),
NAME_VAL( LOC_GPS_STATUS_SESSION_BEGIN ),
@@ -61,18 +61,16 @@ static const loc_name_val_s_type gps_status_name[] =
NAME_VAL( LOC_GPS_STATUS_ENGINE_ON ),
NAME_VAL( LOC_GPS_STATUS_ENGINE_OFF ),
};
static const int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);
/* Find Android GPS status name */
const char* loc_get_gps_status_name(LocGpsStatusValue gps_status)
{
return loc_get_name_from_val(gps_status_name, gps_status_num,
(long) gps_status);
return loc_get_name_from_val(gps_status_name_tbl, (int64_t) gps_status);
}
static const loc_name_val_s_type loc_eng_position_modes[] =
DECLARE_TBL(loc_eng_position_modes) =
{
NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
NAME_VAL( LOC_POSITION_MODE_MS_BASED ),
@@ -83,25 +81,23 @@ static const loc_name_val_s_type loc_eng_position_modes[] =
NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),
NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )
};
static const int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
const char* loc_get_position_mode_name(LocGpsPositionMode mode)
{
return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
return loc_get_name_from_val(loc_eng_position_modes_tbl, (int64_t) mode);
}
static const loc_name_val_s_type loc_eng_position_recurrences[] =
DECLARE_TBL(loc_eng_position_recurrences) =
{
NAME_VAL( LOC_GPS_POSITION_RECURRENCE_PERIODIC ),
NAME_VAL( LOC_GPS_POSITION_RECURRENCE_SINGLE )
};
static const int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur)
{
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
return loc_get_name_from_val(loc_eng_position_recurrences_tbl, (int64_t) recur);
}
const char* loc_get_aiding_data_mask_names(LocGpsAidingData /*data*/)
@@ -110,7 +106,7 @@ const char* loc_get_aiding_data_mask_names(LocGpsAidingData /*data*/)
}
static const loc_name_val_s_type loc_eng_agps_types[] =
DECLARE_TBL(loc_eng_agps_types) =
{
NAME_VAL( LOC_AGPS_TYPE_INVALID ),
NAME_VAL( LOC_AGPS_TYPE_ANY ),
@@ -118,44 +114,41 @@ static const loc_name_val_s_type loc_eng_agps_types[] =
NAME_VAL( LOC_AGPS_TYPE_C2K ),
NAME_VAL( LOC_AGPS_TYPE_WWAN_ANY )
};
static const int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_type_name(LocAGpsType type)
{
return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
return loc_get_name_from_val(loc_eng_agps_types_tbl, (int64_t) type);
}
static const loc_name_val_s_type loc_eng_ni_types[] =
DECLARE_TBL(loc_eng_ni_types) =
{
NAME_VAL( LOC_GPS_NI_TYPE_VOICE ),
NAME_VAL( LOC_GPS_NI_TYPE_UMTS_SUPL ),
NAME_VAL( LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE ),
NAME_VAL( LOC_GPS_NI_TYPE_EMERGENCY_SUPL )
};
static const int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_type_name(LocGpsNiType type)
{
return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
return loc_get_name_from_val(loc_eng_ni_types_tbl, (int64_t) type);
}
static const loc_name_val_s_type loc_eng_ni_responses[] =
DECLARE_TBL(loc_eng_ni_responses) =
{
NAME_VAL( LOC_GPS_NI_RESPONSE_ACCEPT ),
NAME_VAL( LOC_GPS_NI_RESPONSE_DENY ),
NAME_VAL( LOC_GPS_NI_RESPONSE_DENY )
};
static const int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_response_name(LocGpsUserResponseType response)
{
return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
return loc_get_name_from_val(loc_eng_ni_responses_tbl, (int64_t) response);
}
static const loc_name_val_s_type loc_eng_ni_encodings[] =
DECLARE_TBL(loc_eng_ni_encodings) =
{
NAME_VAL( LOC_GPS_ENC_NONE ),
NAME_VAL( LOC_GPS_ENC_SUPL_GSM_DEFAULT ),
@@ -163,55 +156,51 @@ static const loc_name_val_s_type loc_eng_ni_encodings[] =
NAME_VAL( LOC_GPS_ENC_SUPL_UCS2 ),
NAME_VAL( LOC_GPS_ENC_UNKNOWN )
};
static const int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_encoding_name(LocGpsNiEncodingType encoding)
{
return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
return loc_get_name_from_val(loc_eng_ni_encodings_tbl, (int64_t) encoding);
}
static const loc_name_val_s_type loc_eng_agps_bears[] =
DECLARE_TBL(loc_eng_agps_bears) =
{
NAME_VAL( AGPS_APN_BEARER_INVALID ),
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
NAME_VAL( AGPS_APN_BEARER_IPV6 ),
NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
};
static const int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_bear_name(AGpsBearerType bearer)
{
return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);
return loc_get_name_from_val(loc_eng_agps_bears_tbl, (int64_t) bearer);
}
static const loc_name_val_s_type loc_eng_server_types[] =
DECLARE_TBL(loc_eng_server_types) =
{
NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),
NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),
NAME_VAL( LOC_AGPS_MPC_SERVER ),
NAME_VAL( LOC_AGPS_SUPL_SERVER )
};
static const int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);
const char* loc_get_server_type_name(LocServerType type)
{
return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);
return loc_get_name_from_val(loc_eng_server_types_tbl, (int64_t) type);
}
static const loc_name_val_s_type loc_eng_position_sess_status_types[] =
DECLARE_TBL(loc_eng_position_sess_status_types) =
{
NAME_VAL( LOC_SESS_SUCCESS ),
NAME_VAL( LOC_SESS_INTERMEDIATE ),
NAME_VAL( LOC_SESS_FAILURE )
};
static const int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);
const char* loc_get_position_sess_status_name(enum loc_sess_status status)
{
return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);
return loc_get_name_from_val(loc_eng_position_sess_status_types_tbl, (int64_t) status);
}
static const loc_name_val_s_type loc_eng_agps_status_names[] =
DECLARE_TBL(loc_eng_agps_status_names) =
{
NAME_VAL( LOC_GPS_REQUEST_AGPS_DATA_CONN ),
NAME_VAL( LOC_GPS_RELEASE_AGPS_DATA_CONN ),
@@ -219,9 +208,8 @@ static const loc_name_val_s_type loc_eng_agps_status_names[] =
NAME_VAL( LOC_GPS_AGPS_DATA_CONN_DONE ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONN_FAILED )
};
static const int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_status_name(LocAGpsStatusValue status)
{
return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
return loc_get_name_from_val(loc_eng_agps_status_names_tbl, (int64_t) status);
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
/* 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
@@ -30,8 +30,11 @@
#ifndef __IFRAMEWORKACTIONREQ_H__
#define __IFRAMEWORKACTIONREQ_H__
#include <string>
#include <DataItemId.h>
using namespace std;
namespace loc_core
{
@@ -70,14 +73,14 @@ public:
*/
virtual void turnOff (DataItemId dit) = 0;
#ifdef USE_QCMAP
#ifdef USE_GLIB
/**
* @brief Setup WWAN backhaul
* @details Setup WWAN backhaul
*
* @param None
*/
virtual bool connectBackhaul() = 0;
virtual bool connectBackhaul(const string& clientName) = 0;
/**
* @brief Disconnects the WWANbackhaul
@@ -85,7 +88,7 @@ public:
*
* @param None
*/
virtual bool disconnectBackhaul() = 0;
virtual bool disconnectBackhaul(const string& clientName) = 0;
#endif
/**

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* 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
@@ -91,8 +91,8 @@ public:
inline virtual void turnOn (DataItemId /*dit*/, int /*timeOut*/){}
inline virtual void turnOff (DataItemId /*dit*/) {}
#ifdef USE_GLIB
inline virtual bool connectBackhaul() { return false; }
inline virtual bool disconnectBackhaul() { return false; }
inline virtual bool connectBackhaul(const string& clientName) { return false; }
inline virtual bool disconnectBackhaul(const string& clientName) { return false; }
#endif
/**

27
gps/etc/Android.bp Normal file
View File

@@ -0,0 +1,27 @@
prebuilt_etc {
name: "gnss@2.0-base.policy",
vendor: true,
sub_dir: "seccomp_policy",
src: "seccomp_policy/gnss@2.0-base.policy",
}
prebuilt_etc {
name: "gnss@2.0-xtra-daemon.policy",
vendor: true,
sub_dir: "seccomp_policy",
src: "seccomp_policy/gnss@2.0-xtra-daemon.policy",
}
prebuilt_etc {
name: "gnss@2.0-xtwifi-client.policy",
vendor: true,
sub_dir: "seccomp_policy",
src: "seccomp_policy/gnss@2.0-xtwifi-client.policy",
}
prebuilt_etc {
name: "gnss@2.0-xtwifi-inet-agent.policy",
vendor: true,
sub_dir: "seccomp_policy",
src: "seccomp_policy/gnss@2.0-xtwifi-inet-agent.policy",
}

View File

@@ -0,0 +1,95 @@
#*******************************************************************************
# 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.
#
#******************************************************************************
clone: 1
close: 1
connect: 1
execve: 1
exit_group: 1
exit: 1
faccessat: 1
fcntl: 1
fstat: 1
fstatfs: 1
futex: 1
getpid: 1
getuid: 1
getgid: 1
getegid: 1
getgroups: 1
geteuid: 1
umask: 1
getrandom: 1
mmap: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
mprotect: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE
mremap: 1
munmap: 1
newfstatat: 1
openat: 1
#prctl: arg0 == PR_SET_VMA || arg0 == PR_SET_NO_NEW_PRIVS || arg0 == PR_GET_DUMPABLE || arg0 == PR_SET_SECCOMP || arg0 == 0x37 /* PR_??? */
prctl: 1
pread64: 1
read: 1
pwrite64: 1
write: 1
writev: 1
readlinkat: 1
restart_syscall: 1
rt_sigaction: 1
rt_sigprocmask: 1
rt_sigreturn: 1
sched_getscheduler: 1
set_tid_address: 1
sigaltstack: 1
unlinkat: 1
lseek: 1
##ioctl: arg1 == _IOC(_IOC_NONE || arg1 == _IOC(_IOC_READ || arg1 == VSOC_MAYBE_SEND_INTERRUPT_TO_HOST
ioctl: 1
clock_gettime: 1
socket: arg0 == AF_INET6 || arg0 == AF_UNIX || arg0 == AF_QIPCRTR
connect: 1
setsockopt: 1
getsockname: 1
socketpair: 1
ppoll: 1
pselect6: 1
accept4: 1
listen: 1
bind: 1
pipe2: 1
recvmsg: 1
sendmsg: 1
sendto: 1
recvfrom: 1

View File

@@ -0,0 +1,48 @@
#*******************************************************************************
# 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.
#
#******************************************************************************
bind: 1
getrlimit: 1
pipe2: 1
sched_getaffinity: 1
timerfd_create: 1
unlinkat: 1
setpriority: 1
epoll_create1: 1
epoll_ctl: 1
epoll_pwait: 1
timerfd_settime: 1
fdatasync: 1
madvise: 1
ftruncate: 1

View File

@@ -0,0 +1,45 @@
#*******************************************************************************
# 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.
#
#******************************************************************************
fdatasync: 1
getdents64: 1
gettimeofday: 1
#ioctl: arg1 == _IOC(_IOC_NONE || arg1 == _IOC(_IOC_READ || arg1 == VSOC_MAYBE_SEND_INTERRUPT_TO_HOST
lseek: 1
madvise: 1
mkdirat: 1
pwrite64: 1
timerfd_create: 1
timerfd_settime: 1
epoll_create1: 1
epoll_pwait: 1
epoll_ctl: 1

View File

@@ -0,0 +1,33 @@
#*******************************************************************************
# 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.
#
#******************************************************************************
unlinkat: 1
sched_getaffinity: 1

31
gps/geofence/Android.bp Normal file
View File

@@ -0,0 +1,31 @@
cc_library_shared {
name: "libgeofencing",
vendor: true,
sanitize: GNSS_SANITIZE,
srcs: [
"GeofenceAdapter.cpp",
"location_geofence.cpp",
],
shared_libs: [
"libutils",
"libcutils",
"libgps.utils",
"liblog",
"libloc_core",
],
header_libs: [
"libgps.utils_headers",
"libloc_core_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
cflags: GNSS_CFLAGS,
}

View File

@@ -1,35 +0,0 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libgeofencing
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
GeofenceAdapter.cpp \
location_geofence.cpp
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libgps.utils \
liblog \
libloc_core
LOCAL_HEADER_LIBRARIES := \
libgps.utils_headers \
libloc_core_headers \
libloc_pla_headers \
liblocation_api_headers
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS += $(GNSS_CFLAGS)
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

View File

@@ -242,30 +242,33 @@ GeofenceAdapter::addGeofencesCommand(LocationAPI* client, size_t count, Geofence
if (NULL == mIds || NULL == mOptions || NULL == mInfos) {
errs[i] = LOCATION_ERROR_INVALID_PARAMETER;
} else {
mApi.addGeofence(mIds[i],
mOptions[i],
mInfos[i],
new LocApiResponseData<LocApiGeofenceData>(*mAdapter.getContext(),
[&mAdapter = mAdapter, mOptions = mOptions, mClient = mClient,
mCount = mCount, mIds = mIds, mInfos = mInfos, errs, i]
(LocationError err, LocApiGeofenceData data) {
if (LOCATION_ERROR_SUCCESS == err) {
mAdapter.saveGeofenceItem(mClient,
mIds[i],
data.hwId,
mOptions[i],
mInfos[i]);
}
errs[i] = err;
mApi.addToCallQueue(new LocApiResponse(*mAdapter.getContext(),
[&mAdapter = mAdapter, mCount = mCount, mClient = mClient,
mOptions = mOptions, mInfos = mInfos, mIds = mIds, &mApi = mApi,
errs, i] (LocationError err ) {
mApi.addGeofence(mIds[i], mOptions[i], mInfos[i],
new LocApiResponseData<LocApiGeofenceData>(*mAdapter.getContext(),
[&mAdapter = mAdapter, mOptions = mOptions, mClient = mClient,
mCount = mCount, mIds = mIds, mInfos = mInfos, errs, i]
(LocationError err, LocApiGeofenceData data) {
if (LOCATION_ERROR_SUCCESS == err) {
mAdapter.saveGeofenceItem(mClient,
mIds[i],
data.hwId,
mOptions[i],
mInfos[i]);
}
errs[i] = err;
// Send aggregated response on last item and cleanup
if (i == mCount-1) {
mAdapter.reportResponse(mClient, mCount, errs, mIds);
delete[] errs;
delete[] mIds;
delete[] mOptions;
delete[] mInfos;
}
// Send aggregated response on last item and cleanup
if (i == mCount-1) {
mAdapter.reportResponse(mClient, mCount, errs, mIds);
delete[] errs;
delete[] mIds;
delete[] mOptions;
delete[] mInfos;
}
}));
}));
}
}

View File

@@ -1,6 +1,6 @@
AC_PREREQ(2.61)
AC_INIT([location-geofence], 1.0.0)
AM_INIT_AUTOMAKE([foreign])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

View File

@@ -304,7 +304,7 @@ void AgpsStateMachine::requestOrReleaseDataConn(bool request){
nifRequest.status = LOC_GPS_RELEASE_AGPS_DATA_CONN;
}
mAgpsManager->mFrameworkStatusV4Cb(nifRequest);
mFrameworkStatusV4Cb(nifRequest);
}
void AgpsStateMachine::notifyAllSubscribers(
@@ -511,7 +511,7 @@ void AgpsStateMachine::dropAllSubscribers(){
/* CREATE AGPS STATE MACHINES
* Must be invoked in Msg Handler context */
void AgpsManager::createAgpsStateMachines() {
void AgpsManager::createAgpsStateMachines(const AgpsCbInfo& cbInfo) {
LOC_LOGD("AgpsManager::createAgpsStateMachines");
@@ -519,13 +519,16 @@ void AgpsManager::createAgpsStateMachines() {
((loc_core::ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA) ||
(loc_core::ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB));
if (NULL == mInternetNif) {
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) {
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);
}
}
@@ -544,6 +547,11 @@ AgpsStateMachine* AgpsManager::getAgpsStateMachine(AGpsExtType agpsType) {
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;
}

View File

@@ -137,6 +137,7 @@ protected:
/* Current state for this state machine */
AgpsState mState;
AgnssStatusIpV4Cb mFrameworkStatusV4Cb;
private:
/* AGPS Type for this state machine
LOC_AGPS_TYPE_ANY 0
@@ -154,6 +155,7 @@ private:
public:
/* CONSTRUCTOR */
AgpsStateMachine(AgpsManager* agpsManager, AGpsExtType agpsType):
mFrameworkStatusV4Cb(NULL),
mAgpsManager(agpsManager), mSubscriberList(),
mCurrentSubscriber(NULL), mState(AGPS_STATE_RELEASED),
mAgpsType(agpsType), mAPN(NULL), mAPNLen(0),
@@ -175,6 +177,10 @@ public:
inline void setCurrentSubscriber(AgpsSubscriber* subscriber)
{ mCurrentSubscriber = subscriber; }
inline void registerFrameworkStatusCallback(AgnssStatusIpV4Cb frameworkStatusV4Cb) {
mFrameworkStatusV4Cb = frameworkStatusV4Cb;
}
/* Fetch subscriber with specified handle */
AgpsSubscriber* getSubscriber(int connHandle);
@@ -234,7 +240,6 @@ class AgpsManager {
public:
/* CONSTRUCTOR */
AgpsManager():
mFrameworkStatusV4Cb(NULL),
mAtlOpenStatusCb(), mAtlCloseStatusCb(),
mAgnssNif(NULL), mInternetNif(NULL)/*, mDsNif(NULL)*/ {}
@@ -246,12 +251,11 @@ public:
mAtlCloseStatusCb = atlCloseStatusCb;
}
inline void registerFrameworkStatusCallback(AgnssStatusIpV4Cb frameworkStatusV4Cb) {
mFrameworkStatusV4Cb = frameworkStatusV4Cb;
}
/* Check if AGPS client is registered */
inline bool isRegistered() { return nullptr != mAgnssNif || nullptr != mInternetNif; }
/* Create all AGPS state machines */
void createAgpsStateMachines();
void createAgpsStateMachines(const AgpsCbInfo& cbInfo);
/* Process incoming ATL requests */
void requestATL(int connHandle, AGpsExtType agpsType, LocApnTypeMask apnTypeMask);
@@ -266,7 +270,6 @@ public:
void handleModemSSR();
protected:
AgnssStatusIpV4Cb mFrameworkStatusV4Cb;
AgpsAtlOpenStatusCb mAtlOpenStatusCb;
AgpsAtlCloseStatusCb mAtlCloseStatusCb;

34
gps/gnss/Android.bp Normal file
View File

@@ -0,0 +1,34 @@
cc_library_shared {
name: "libgnss",
vendor: true,
sanitize: GNSS_SANITIZE,
shared_libs: [
"libutils",
"libcutils",
"libdl",
"liblog",
"libloc_core",
"libgps.utils",
],
srcs: [
"location_gnss.cpp",
"GnssAdapter.cpp",
"Agps.cpp",
"XtraSystemStatusObserver.cpp",
],
cflags: ["-fno-short-enums"] + GNSS_CFLAGS,
header_libs: [
"libgps.utils_headers",
"libloc_core_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
}

View File

@@ -1,46 +0,0 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libgnss
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libdl \
liblog \
libloc_core \
libgps.utils
LOCAL_SRC_FILES += \
location_gnss.cpp \
GnssAdapter.cpp \
Agps.cpp \
XtraSystemStatusObserver.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
ifeq ($(TARGET_BUILD_VARIANT),user)
LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
endif
LOCAL_HEADER_LIBRARIES := \
libgps.utils_headers \
libloc_core_headers \
libloc_pla_headers \
liblocation_api_headers
LOCAL_CFLAGS += $(GNSS_CFLAGS)
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -38,6 +38,7 @@
#include <SystemStatus.h>
#include <XtraSystemStatusObserver.h>
#include <map>
#include <functional>
#define MAX_URL_LEN 256
#define NMEA_SENTENCE_MAX_LENGTH 200
@@ -46,6 +47,7 @@
#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;
@@ -122,6 +124,30 @@ typedef struct {
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;
} LocIntegrationConfigInfo;
using namespace loc_core;
namespace loc_core {
@@ -132,12 +158,33 @@ typedef std::function<void(
uint64_t gnssEnergyConsumedFromFirstBoot
)> GnssEnergyConsumedCallback;
typedef void (*powerStateCallback)(bool on);
typedef void* QDgnssListenerHDL;
typedef std::function<void(
bool sessionActive
)> QDgnssSessionActiveCb;
struct CdfwInterface {
void (*startDgnssApiService)();
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 GnssAdapter : public LocAdapterBase {
/* ==== Engine Hub ===================================================================== */
EngineHubProxyBase* mEngHubProxy;
bool mNHzNeeded;
bool mSPEAlreadyRunningAtHighestInterval;
/* ==== TRACKING ======================================================================= */
TrackingOptionsMap mTimeBasedTrackingSessions;
@@ -152,10 +199,13 @@ class GnssAdapter : public LocAdapterBase {
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;
@@ -163,7 +213,6 @@ class GnssAdapter : public LocAdapterBase {
/* ==== AGPS =========================================================================== */
// This must be initialized via initAgps()
AgpsManager mAgpsManager;
AgpsCbInfo mAgpsCbInfo;
void initAgps(const AgpsCbInfo& cbInfo);
/* ==== NFW =========================================================================== */
@@ -174,13 +223,30 @@ class GnssAdapter : public LocAdapterBase {
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;
@@ -188,6 +254,7 @@ class GnssAdapter : public LocAdapterBase {
XtraSystemStatusObserver mXtraObserver;
LocationSystemInfo mLocSystemInfo;
std::vector<GnssSvIdSource> mBlacklistedSvIds;
PowerStateType mSystemPowerState;
/* === Misc ===================================================================== */
BlockCPIInfo mBlockCPIInfo;
@@ -196,7 +263,7 @@ class GnssAdapter : public LocAdapterBase {
/* === Misc callback from QMI LOC API ============================================== */
GnssEnergyConsumedCallback mGnssEnergyConsumedCb;
powerStateCallback mPowerStateCb;
std::function<void(bool)> mPowerStateCb;
/*==== CONVERSION ===================================================================*/
static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions);
@@ -209,10 +276,18 @@ class GnssAdapter : public LocAdapterBase {
int totalSvCntInThisConstellation);
/* ======== UTILITIES ================================================================== */
inline void initOdcpi(const OdcpiRequestCallback& callback);
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 ========================================================================= */
@@ -228,7 +303,10 @@ public:
/* ======== EVENTS ====(Called from QMI Thread)========================================= */
virtual void handleEngineUpEvent();
/* ======== UTILITIES ================================================================== */
void restartSessions();
void restartSessions(bool modemSSR = false);
void checkAndRestartTimeBasedSession();
void checkAndRestartSPESession();
void suspendSessions();
/* ==== CLIENT ========================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
@@ -244,10 +322,9 @@ public:
/* ======== RESPONSES ================================================================== */
void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId);
/* ======== UTILITIES ================================================================== */
bool hasTrackingCallback(LocationAPI* client);
bool isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId);
bool isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessionId);
bool hasMeasurementsCallback(LocationAPI* client);
bool hasCallbacksToStartTracking(LocationAPI* client);
bool isTrackingSession(LocationAPI* client, uint32_t sessionId);
void saveTrackingSession(LocationAPI* client, uint32_t sessionId,
const TrackingOptions& trackingOptions);
@@ -266,6 +343,22 @@ public:
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)==================================== */
@@ -284,14 +377,14 @@ public:
void readConfigCommand();
void requestUlpCommand();
void initEngHubProxyCommand();
uint32_t* gnssUpdateConfigCommand(GnssConfig config);
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 GnssConfig& gnssConfigRequested,
const GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0);
GnssConfig& gnssConfigRequested,
GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0);
/* ==== GNSS SV TYPE CONFIG ============================================================ */
/* ==== COMMANDS ====(Called from Client Thread)======================================== */
@@ -314,6 +407,7 @@ public:
inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback()
{ return mGnssSvTypeConfigCb; }
void setConfig();
void gnssSecondaryBandConfigUpdate(LocApiResponse* locApiResponse= nullptr);
/* ========= AGPS ====================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
@@ -326,10 +420,27 @@ public:
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);
/* ========= ODCPI ===================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void initOdcpiCommand(const OdcpiRequestCallback& callback);
void initOdcpiCommand(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
void injectOdcpiCommand(const Location& location);
/* ======== RESPONSES ================================================================== */
void reportResponse(LocationError err, uint32_t sessionId);
@@ -343,6 +454,7 @@ public:
virtual bool isInSession() { return !mTimeBasedTrackingSessions.empty(); }
void initDefaultAgps();
bool initEngHubProxy();
void initCDFWService();
void odcpiTimerExpireEvent();
/* ==== REPORTS ======================================================================== */
@@ -351,9 +463,11 @@ public:
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask,
bool fromEngineHub = false,
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);
@@ -366,6 +480,7 @@ public:
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);
@@ -382,10 +497,14 @@ public:
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);
@@ -394,6 +513,7 @@ public:
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);
@@ -410,6 +530,13 @@ public:
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 */
@@ -424,7 +551,6 @@ public:
/*==== CONVERSION ===================================================================*/
static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion);
static uint32_t convertLppProfile(const GnssConfigLppProfile lppProfile);
static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl);
static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices);
static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask);
@@ -437,7 +563,7 @@ public:
static bool convertToGnssSvIdConfig(
const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config);
static void convertFromGnssSvIdConfig(
const GnssSvIdConfig& svConfig, GnssConfig& config);
const GnssSvIdConfig& svConfig, std::vector<GnssSvIdSource>& blacklistedSvIds);
static void convertGnssSvIdMaskToList(
uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds,
GnssSvId initialSvId, GnssSvType svType);
@@ -451,16 +577,36 @@ public:
/* ==== MISCELLANEOUS ================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void getPowerStateChangesCommand(void* powerStateCb);
void getPowerStateChangesCommand(std::function<void(bool)> powerStateCb);
/* ======== UTILITIES ================================================================== */
void reportPowerStateIfChanged();
void savePowerStateCallback(powerStateCallback powerStateCb){ mPowerStateCb = powerStateCb; }
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);
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

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017, 2019, The Linux Foundation. All rights reserved.
/* 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
@@ -65,15 +65,20 @@ 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) override {
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")) {
mSystemStatusObsrvr->connectBackhaul();
char clientName[30] = {0};
sscanf(data, "%*s %29s", clientName);
mSystemStatusObsrvr->connectBackhaul(string(clientName));
} else if (!STRNCMP(data, "disconnectBackhaul")) {
mSystemStatusObsrvr->disconnectBackhaul();
char clientName[30] = {0};
sscanf(data, "%*s %29s", clientName);
mSystemStatusObsrvr->disconnectBackhaul(string(clientName));
#endif
} else if (!STRNCMP(data, "requestStatus")) {
int32_t xtraStatusUpdated = 0;
@@ -87,6 +92,8 @@ public:
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));
@@ -230,6 +237,55 @@ inline bool XtraSystemStatusObserver::onStatusRequested(int32_t xtraStatusUpdate
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

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -33,6 +33,7 @@
#include <MsgTask.h>
#include <LocIpc.h>
#include <LocTimer.h>
#include <stdlib.h>
using namespace std;
using namespace loc_util;
@@ -40,6 +41,22 @@ 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
@@ -62,6 +79,10 @@ public :
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;
@@ -76,6 +97,7 @@ private:
bool mReqStatusReceived;
bool mIsConnectivityStatusKnown;
shared_ptr<LocIpcSender> mSender;
string mNtripParamsString;
class DelayLocTimer : public LocTimer {
LocIpcSender& mSender;

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* 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
@@ -50,7 +50,7 @@ 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(GnssConfig config);
static uint32_t* gnssUpdateConfig(const GnssConfig& config);
static uint32_t* gnssGetConfig(GnssConfigFlagsMask mask);
static void gnssUpdateSvTypeConfig(GnssSvTypeConfig& config);
@@ -71,14 +71,37 @@ static void updateConnectionStatus(bool connected, int8_t type, bool roaming = f
static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb);
static void enableNfwLocationAccess(bool enable);
static void nfwInit(const NfwCbInfo& cbInfo);
static void getPowerStateChanges(void* powerStateCb);
static void getPowerStateChanges(std::function<void(bool)> powerStateCb);
static void odcpiInit(const OdcpiRequestCallback& callback);
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 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 const GnssInterface gGnssInterface = {
sizeof(GnssInterface),
@@ -117,7 +140,25 @@ static const GnssInterface gGnssInterface = {
nfwInit,
getPowerStateChanges,
injectLocationExt,
updateBatteryStatus
updateBatteryStatus,
updateSystemPowerState,
setConstrainedTunc,
setPositionAssistedClockEstimator,
gnssUpdateSvConfig,
configLeverArm,
measCorrInit,
measCorrSetCorrections,
measCorrClose,
antennaInfoInit,
antennaInfoClose,
configRobustLocation,
configMinGpsWeek,
configDeadReckoningEngineParams,
updateNTRIPGGAConsent,
enablePPENtripStream,
disablePPENtripStream,
gnssUpdateSecondaryBandConfig,
gnssGetSecondaryBandConfig,
};
#ifndef DEBUG_X86
@@ -126,6 +167,7 @@ extern "C" const GnssInterface* getGnssInterface()
const GnssInterface* getGnssInterface()
#endif // DEBUG_X86
{
gGnssInterface.initialize();
return &gGnssInterface;
}
@@ -221,7 +263,7 @@ static void disable(uint32_t id)
}
}
static uint32_t* gnssUpdateConfig(GnssConfig config)
static uint32_t* gnssUpdateConfig(const GnssConfig& config)
{
if (NULL != gGnssAdapter) {
return gGnssAdapter->gnssUpdateConfigCommand(config);
@@ -332,10 +374,10 @@ static void updateConnectionStatus(bool connected, int8_t type,
}
}
static void odcpiInit(const OdcpiRequestCallback& callback)
static void odcpiInit(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->initOdcpiCommand(callback);
gGnssAdapter->initOdcpiCommand(callback, priority);
}
}
@@ -371,7 +413,8 @@ static void nfwInit(const NfwCbInfo& cbInfo) {
gGnssAdapter->initNfwCommand(cbInfo);
}
}
static void getPowerStateChanges(void* powerStateCb)
static void getPowerStateChanges(std::function<void(bool)> powerStateCb)
{
if (NULL != gGnssAdapter) {
gGnssAdapter->getPowerStateChangesCommand(powerStateCb);
@@ -390,3 +433,142 @@ static void updateBatteryStatus(bool charging) {
gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging);
}
}
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();
}
}

36
gps/location/Android.bp Normal file
View File

@@ -0,0 +1,36 @@
cc_library_shared {
name: "liblocation_api",
vendor: true,
sanitize: GNSS_SANITIZE,
shared_libs: [
"libutils",
"libcutils",
"libgps.utils",
"libdl",
"liblog",
],
srcs: [
"LocationAPI.cpp",
"LocationAPIClientBase.cpp",
],
cflags: ["-fno-short-enums"] + GNSS_CFLAGS,
header_libs: [
"libloc_pla_headers",
"libgps.utils_headers",
],
}
cc_library_headers {
name: "liblocation_api_headers",
export_include_dirs: ["."],
vendor: true,
}

View File

@@ -1,41 +0,0 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := liblocation_api
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libgps.utils \
libdl \
liblog
LOCAL_SRC_FILES += \
LocationAPI.cpp \
LocationAPIClientBase.cpp
LOCAL_CFLAGS += \
-fno-short-enums
LOCAL_HEADER_LIBRARIES := \
libloc_pla_headers \
libgps.utils_headers
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS += $(GNSS_CFLAGS)
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblocation_api_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_HEADER_LIBRARY)
endif # not BUILD_TINY_ANDROID
endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 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
@@ -179,7 +179,7 @@ public:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
virtual uint32_t* gnssUpdateConfig(GnssConfig config) = 0;
virtual uint32_t* gnssUpdateConfig(const GnssConfig& config) = 0;
/** @brief Delete specific gnss aiding data for testing, which returns a session id
that will be returned in responseCallback to match command with response.
@@ -189,6 +189,180 @@ public:
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */
virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) = 0;
/** @brief
Configure the constellation and SVs to be used by the GNSS engine on
modem.
@param
constellationEnablementConfig: configuration to enable/disable SV
constellation to be used by SPE engine. When size in
constellationEnablementConfig is set to 0, this indicates to reset SV
constellation configuration to modem NV default.
blacklistSvConfig: configuration to blacklist or unblacklist SVs
used by SPE engine
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configConstellations(
const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig) = 0;
/** @brief
Configure the secondary band of constellations to be used by
the GNSS engine on modem.
@param
secondaryBandConfig: configuration the secondary band usage
for SPE engine
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configConstellationSecondaryBand(
const GnssSvTypeConfig& secondaryBandConfig) = 0;
/** @brief
Enable or disable the constrained time uncertainty feature.
@param
enable: true to enable the constrained time uncertainty
feature and false to disable the constrainted time
uncertainty feature.
@param
tuncThreshold: this specifies the time uncertainty threshold
that gps engine need to maintain, in units of milli-seconds.
Default is 0.0 meaning that modem default value of time
uncertainty threshold will be used. This parameter is
ignored when requesting to disable this feature.
@param
energyBudget: this specifies the power budget that gps
engine is allowed to spend to maintain the time uncertainty.
Default is 0 meaning that GPS engine is not constained by
power budget and can spend as much power as needed. The
parameter need to be specified in units of 0.1 milli watt
second. This parameter is ignored requesting to disable this
feature.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters
are invalid
*/
virtual uint32_t configConstrainedTimeUncertainty(
bool enable, float tuncThreshold = 0.0,
uint32_t energyBudget = 0) = 0;
/** @brief
Enable or disable position assisted clock estimator feature.
@param
enable: true to enable position assisted clock estimator and
false to disable the position assisted clock estimator
feature.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configPositionAssistedClockEstimator(bool enable) = 0;
/** @brief
Sets the lever arm parameters for the vehicle.
@param
configInfo: lever arm configuration info regarding below two
types of lever arm info:
a: GNSS Antenna w.r.t the origin at the IMU e.g.: inertial
measurement unit.
b: lever arm parameters regarding the OPF (output frame)
w.r.t the origin (at the GPS Antenna). Vehicle manufacturers
prefer the position output to be tied to a specific point in
the vehicle rather than where the antenna is placed
(midpoint of the rear axle is typical).
Caller can choose types of lever arm info to configure via the
leverMarkTypeMask.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) = 0;
/** @brief
Configure the robust location setting.
@param
enable: true to enable robust location and false to disable
robust location.
@param
enableForE911: true to enable robust location when device is on
E911 session and false to disable on E911 session.
This parameter is only valid if robust location is enabled.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configRobustLocation(bool enable, bool enableForE911) = 0;
/** @brief
Config the minimum GPS week used by modem GNSS engine.
@param
minGpsWeek: minimum GPS week to be used by modem GNSS engine.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configMinGpsWeek(uint16_t minGpsWeek) = 0;
/** @brief
Configure the vehicle body-to-Sensor mount parameters and
other parameters for dead reckoning position engine.
@param
dreConfig: vehicle body-to-Sensor mount angles and other
parameters.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configDeadReckoningEngineParams(const DeadReckoningEngineConfig& dreConfig)=0;
};
#endif /* ILOCATIONAPI_H */

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
/* 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
@@ -80,12 +80,27 @@ static const T1* loadLocationInterface(const char* library, const char* name) {
}
}
static bool needsGnssTrackingInfo(LocationCallbacks& locationCallbacks)
{
return (locationCallbacks.gnssLocationInfoCb != nullptr ||
locationCallbacks.engineLocationsInfoCb != nullptr ||
locationCallbacks.gnssSvCb != nullptr ||
locationCallbacks.gnssNmeaCb != nullptr ||
locationCallbacks.gnssDataCb != nullptr ||
locationCallbacks.gnssMeasurementsCb != nullptr);
}
static bool isGnssClient(LocationCallbacks& locationCallbacks)
{
return (locationCallbacks.gnssNiCb != nullptr ||
locationCallbacks.trackingCb != nullptr ||
locationCallbacks.gnssLocationInfoCb != nullptr ||
locationCallbacks.gnssMeasurementsCb != nullptr);
locationCallbacks.engineLocationsInfoCb != nullptr ||
locationCallbacks.gnssSvCb != nullptr ||
locationCallbacks.gnssNmeaCb != nullptr ||
locationCallbacks.gnssDataCb != nullptr ||
locationCallbacks.gnssMeasurementsCb != nullptr ||
locationCallbacks.locationSystemInfoCb != nullptr);
}
static bool isBatchingClient(LocationCallbacks& locationCallbacks)
@@ -120,7 +135,6 @@ void LocationAPI::onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType)
if ((true == invokeCallback) && (nullptr != destroyCompleteCb)) {
LOC_LOGd("invoke client destroy cb");
(destroyCompleteCb) ();
LOC_LOGd("finish invoke client destroy cb");
delete this;
}
@@ -142,7 +156,7 @@ void onGeofenceRemoveClientCompleteCb (LocationAPI* client)
}
LocationAPI*
LocationAPI::createInstance(LocationCallbacks& locationCallbacks)
LocationAPI::createInstance (LocationCallbacks& locationCallbacks)
{
if (nullptr == locationCallbacks.capabilitiesCb ||
nullptr == locationCallbacks.responseCb ||
@@ -233,15 +247,12 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb)
pthread_mutex_lock(&gDataMutex);
auto it = gData.clientData.find(this);
if (it != gData.clientData.end()) {
bool removeFromGnssInf =
(isGnssClient(it->second) && NULL != gData.gnssInterface);
bool removeFromBatchingInf =
(isBatchingClient(it->second) && NULL != gData.batchingInterface);
bool removeFromGeofenceInf =
(isGeofenceClient(it->second) && NULL != gData.geofenceInterface);
bool removeFromGnssInf = (NULL != gData.gnssInterface);
bool removeFromBatchingInf = (NULL != gData.batchingInterface);
bool removeFromGeofenceInf = (NULL != gData.geofenceInterface);
bool needToWait = (removeFromGnssInf || removeFromBatchingInf || removeFromGeofenceInf);
LOC_LOGe("removeFromGnssInf: %d, removeFromBatchingInf: %d, removeFromGeofenceInf: %d,"
"need %d", removeFromGnssInf, removeFromBatchingInf, removeFromGeofenceInf,
"needToWait: %d", removeFromGnssInf, removeFromBatchingInf, removeFromGeofenceInf,
needToWait);
if ((NULL != destroyCompleteCb) && (true == needToWait)) {
@@ -257,7 +268,7 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb)
destroyCbData.waitAdapterMask |=
(removeFromGeofenceInf ? LOCATION_ADAPTER_GEOFENCE_TYPE_BIT : 0);
gData.destroyClientData[this] = destroyCbData;
LOC_LOGe("destroy data stored in the map: 0x%x", destroyCbData.waitAdapterMask);
LOC_LOGi("destroy data stored in the map: 0x%x", destroyCbData.waitAdapterMask);
}
if (removeFromGnssInf) {
@@ -675,7 +686,7 @@ LocationControlAPI::disable(uint32_t id)
}
uint32_t*
LocationControlAPI::gnssUpdateConfig(GnssConfig config)
LocationControlAPI::gnssUpdateConfig(const GnssConfig& config)
{
uint32_t* ids = NULL;
pthread_mutex_lock(&gDataMutex);
@@ -722,3 +733,123 @@ LocationControlAPI::gnssDeleteAidingData(GnssAidingData& data)
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configConstellations(
const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->gnssUpdateSvConfig(
constellationEnablementConfig, blacklistSvConfig);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configConstellationSecondaryBand(
const GnssSvTypeConfig& secondaryBandConfig) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->gnssUpdateSecondaryBandConfig(secondaryBandConfig);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configConstrainedTimeUncertainty(
bool enable, float tuncThreshold, uint32_t energyBudget) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->setConstrainedTunc(enable,
tuncThreshold,
energyBudget);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configPositionAssistedClockEstimator(bool enable) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->setPositionAssistedClockEstimator(enable);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configLeverArm(const LeverArmConfigInfo& configInfo) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->configLeverArm(configInfo);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configRobustLocation(bool enable, bool enableForE911) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->configRobustLocation(enable, enableForE911);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configMinGpsWeek(uint16_t minGpsWeek) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->configMinGpsWeek(minGpsWeek);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}
uint32_t LocationControlAPI::configDeadReckoningEngineParams(
const DeadReckoningEngineConfig& dreConfig) {
uint32_t id = 0;
pthread_mutex_lock(&gDataMutex);
if (gData.gnssInterface != NULL) {
id = gData.gnssInterface->configDeadReckoningEngineParams(dreConfig);
} else {
LOC_LOGe("No gnss interface available for Location Control API");
}
pthread_mutex_unlock(&gDataMutex);
return id;
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
/* 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
@@ -236,7 +236,7 @@ public:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
virtual uint32_t* gnssUpdateConfig(GnssConfig config) override;
virtual uint32_t* gnssUpdateConfig(const GnssConfig& config) override;
/* gnssGetConfig fetches the current constellation and SV configuration
on the GNSS engine.
@@ -261,6 +261,181 @@ public:
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */
virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) override;
/** @brief
Configure the constellation and SVs to be used by the GNSS engine on
modem.
@param
constellationEnablementConfig: configuration to enable/disable SV
constellation to be used by SPE engine. When size in
constellationEnablementConfig is set to 0, this indicates to reset SV
constellation configuration to modem NV default.
blacklistSvConfig: configuration to blacklist or unblacklist SVs
used by SPE engine
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configConstellations(
const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig) override;
/** @brief
Configure the secondary band of constellations to be used by
the GNSS engine on modem.
@param
secondaryBandConfig: configuration the secondary band usage
for SPE engine
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configConstellationSecondaryBand(
const GnssSvTypeConfig& secondaryBandConfig) override;
/** @brief
Enable or disable the constrained time uncertainty feature.
@param
enable: true to enable the constrained time uncertainty
feature and false to disable the constrainted time
uncertainty feature.
@param
tuncThreshold: this specifies the time uncertainty threshold
that gps engine need to maintain, in units of milli-seconds.
Default is 0.0 meaning that modem default value of time
uncertainty threshold will be used. This parameter is
ignored when requesting to disable this feature.
@param
energyBudget: this specifies the power budget that gps
engine is allowed to spend to maintain the time uncertainty.
Default is 0 meaning that GPS engine is not constained by
power budget and can spend as much power as needed. The
parameter need to be specified in units of 0.1 milli watt
second. This parameter is ignored requesting to disable this
feature.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters
are invalid
*/
virtual uint32_t configConstrainedTimeUncertainty(
bool enable, float tuncThreshold = 0.0,
uint32_t energyBudget = 0) override;
/** @brief
Enable or disable position assisted clock estimator feature.
@param
enable: true to enable position assisted clock estimator and
false to disable the position assisted clock estimator
feature.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configPositionAssistedClockEstimator(bool enable) override;
/** @brief
Sets the lever arm parameters for the vehicle.
@param
configInfo: lever arm configuration info regarding below two
types of lever arm info:
a: GNSS Antenna w.r.t the origin at the IMU e.g.: inertial
measurement unit.
b: lever arm parameters regarding the OPF (output frame)
w.r.t the origin (at the GPS Antenna). Vehicle manufacturers
prefer the position output to be tied to a specific point in
the vehicle rather than where the antenna is placed
(midpoint of the rear axle is typical).
Caller can choose types of lever arm info to configure via the
leverMarkTypeMask.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) override;
/** @brief
Configure the robust location setting.
@param
enable: true to enable robust location and false to disable
robust location.
@param
enableForE911: true to enable robust location when device is
on E911 session and false to disable on E911 session.
This parameter is only valid if robust location is enabled.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configRobustLocation(bool enable, bool enableForE911) override;
/** @brief
Config the minimal GPS week used by modem GNSS engine.
@param
minGpsWeek: minimal GPS week to be used by modem GNSS engine.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configMinGpsWeek(uint16_t minGpsWeek) override;
/** @brief
Configure the vehicle body-to-Sensor mount parameters and
other parameters for dead reckoning position engine.
@param
dreConfig: vehicle body-to-Sensor mount angles and other
parameters.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configDeadReckoningEngineParams(
const DeadReckoningEngineConfig& dreConfig) override;
};
#endif /* LOCATIONAPI_H */

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
/* 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
@@ -310,14 +310,16 @@ void LocationAPIClientBase::locAPISetCallbacks(LocationCallbacks& locationCallba
pthread_mutex_unlock(&mMutex);
}
LocationAPIClientBase::~LocationAPIClientBase()
void LocationAPIClientBase::destroy()
{
LOC_LOGD("LocationAPIClientBase::destroy()");
pthread_mutex_lock(&mMutex);
mGeofenceBreachCallback = nullptr;
if (mLocationAPI) {
mLocationAPI->destroy();
mLocationAPI->destroy([this]() {onLocationApiDestroyCompleteCb();});
mLocationAPI = nullptr;
}
@@ -326,10 +328,19 @@ LocationAPIClientBase::~LocationAPIClientBase()
}
pthread_mutex_unlock(&mMutex);
}
LocationAPIClientBase::~LocationAPIClientBase()
{
pthread_mutex_destroy(&mMutex);
}
void LocationAPIClientBase::onLocationApiDestroyCompleteCb()
{
LOC_LOGD("LocationAPIClientBase::onLocationApiDestroyCompleteCb()");
delete this;
}
uint32_t LocationAPIClientBase::locAPIStartTracking(TrackingOptions& options)
{
uint32_t retVal = LOCATION_ERROR_GENERAL_FAILURE;
@@ -799,7 +810,9 @@ void LocationAPIClientBase::locAPIResumeGeofences(
void LocationAPIClientBase::locAPIRemoveAllGeofences()
{
std::vector<uint32_t> sessionsVec = mGeofenceBiDict.getAllSessions();
locAPIRemoveGeofences(sessionsVec.size(), &sessionsVec[0]);
if (sessionsVec.size() > 0) {
locAPIRemoveGeofences(sessionsVec.size(), &sessionsVec[0]);
}
}
void LocationAPIClientBase::locAPIGnssNiResponse(uint32_t id, GnssNiResponse response)

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
/* 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
@@ -200,10 +200,12 @@ private:
class LocationAPIClientBase {
public:
LocationAPIClientBase();
virtual ~LocationAPIClientBase();
LocationAPIClientBase(const LocationAPIClientBase&) = delete;
LocationAPIClientBase& operator=(const LocationAPIClientBase&) = delete;
void destroy();
void onLocationApiDestroyCompleteCb();
void locAPISetCallbacks(LocationCallbacks& locationCallbacks);
void removeSession(uint32_t session);
LocationAPIRequest* getRequestBySession(uint32_t session);
@@ -283,6 +285,9 @@ public:
inline virtual void onLocationSystemInfoCb(LocationSystemInfo /*locationSystemInfo*/) {}
protected:
virtual ~LocationAPIClientBase();
private:
// private inner classes
typedef struct {
@@ -488,6 +493,7 @@ private:
for (size_t i = 0; i < count; i++) {
ids[i] = mAPI.mGeofenceBiDict.getId(sessions[i]);
}
LOC_LOGD("%s:]Returned geofence-id: %d in add geofence", __FUNCTION__, *ids);
mAPI.onAddGeofencesCb(count, errors, ids);
free(ids);
}
@@ -505,6 +511,7 @@ private:
for (size_t i = 0; i < count; i++) {
ids[i] = mRemovedGeofenceBiDict->getId(sessions[i]);
}
LOC_LOGD("%s:]Returned geofence-id: %d in remove geofence", __FUNCTION__, *ids);
mAPI.onRemoveGeofencesCb(count, errors, ids);
free(ids);
delete(mRemovedGeofenceBiDict);

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,10 @@ liblocation_api_la_SOURCES = \
LocationAPI.cpp \
LocationAPIClientBase.cpp
if USE_EXTERNAL_AP
AM_CFLAGS += -DFEATURE_EXTERNAL_AP
endif
if USE_GLIB
liblocation_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
liblocation_api_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0

View File

@@ -7,7 +7,7 @@ AC_PREREQ(2.61)
# Initialize the gps location-api-iface package version 1.0.0
AC_INIT([location-api-iface],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
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
@@ -74,6 +74,19 @@ fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
# External AP
AC_ARG_WITH([external_ap],
AC_HELP_STRING([--with-external_ap=@<:@dir@:>@],
[Using External Application Processor]),
[],
with_external_ap=no)
if test "x$with_external_ap" != "xno"; then
CPPFLAGS="${CPPFLAGS} -DFEATURE_EXTERNAL_AP"
fi
AM_CONDITIONAL(USE_EXTERNAL_AP, test "x${with_external_ap}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
location-api.pc \

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
/* 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
@@ -31,6 +31,7 @@
#include <LocationAPI.h>
#include <gps_extended_c.h>
#include <functional>
/* Used for callback to deliver GNSS energy consumed */
/** @fn
@@ -62,7 +63,7 @@ struct GnssInterface {
void (*setControlCallbacks)(LocationControlCallbacks& controlCallbacks);
uint32_t (*enable)(LocationTechnologyType techType);
void (*disable)(uint32_t id);
uint32_t* (*gnssUpdateConfig)(GnssConfig config);
uint32_t* (*gnssUpdateConfig)(const GnssConfig& config);
uint32_t* (*gnssGetConfig)(GnssConfigFlagsMask config);
void (*gnssUpdateSvTypeConfig)(GnssSvTypeConfig& config);
void (*gnssGetSvTypeConfig)(GnssSvTypeConfigCallback& callback);
@@ -78,16 +79,35 @@ struct GnssInterface {
void (*getDebugReport)(GnssDebugReport& report);
void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming,
NetworkHandle networkHandle);
void (*odcpiInit)(const OdcpiRequestCallback& callback);
void (*odcpiInit)(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
void (*odcpiInject)(const Location& location);
void (*blockCPI)(double latitude, double longitude, float accuracy,
int blockDurationMsec, double latLonDiffThreshold);
void (*getGnssEnergyConsumed)(GnssEnergyConsumedCallback energyConsumedCb);
void (*enableNfwLocationAccess)(bool enable);
void (*nfwInit)(const NfwCbInfo& cbInfo);
void (*getPowerStateChanges)(void* powerStateCb);
void (*getPowerStateChanges)(std::function<void(bool)> powerStateCb);
void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo);
void (*updateBatteryStatus)(bool charging);
void (*updateSystemPowerState)(PowerStateType systemPowerState);
uint32_t (*setConstrainedTunc) (bool enable, float tuncConstraint, uint32_t energyBudget);
uint32_t (*setPositionAssistedClockEstimator) (bool enable);
uint32_t (*gnssUpdateSvConfig)(const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig);
uint32_t (*configLeverArm)(const LeverArmConfigInfo& configInfo);
bool (*measCorrInit)(const measCorrSetCapabilitiesCb setCapabilitiesCb);
bool (*measCorrSetCorrections)(const GnssMeasurementCorrections gnssMeasCorr);
void (*measCorrClose)();
uint32_t (*antennaInfoInit)(const antennaInfoCb antennaInfoCallback);
void (*antennaInfoClose) ();
uint32_t (*configRobustLocation)(bool enable, bool enableForE911);
uint32_t (*configMinGpsWeek)(uint16_t minGpsWeek);
uint32_t (*configDeadReckoningEngineParams)(const DeadReckoningEngineConfig& dreConfig);
void (*updateNTRIPGGAConsent)(bool consentAccepted);
void (*enablePPENtripStream)(const GnssNtripConnectionParams& params, bool enableRTKEngine);
void (*disablePPENtripStream)();
uint32_t (*gnssUpdateSecondaryBandConfig)(const GnssSvTypeConfig& secondaryBandConfig);
uint32_t (*gnssGetSecondaryBandConfig)();
};
struct BatchingInterface {

Some files were not shown because too many files have changed in this diff Show More