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

@@ -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

@@ -1,71 +0,0 @@
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_TAG "LocSvc_MeasurementCorrectionsInterface"
#include <log_util.h>
#include "MeasurementCorrections.h"
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
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;
MeasurementCorrections::MeasurementCorrections() {
}
MeasurementCorrections::~MeasurementCorrections() {
}
Return<bool> MeasurementCorrections::setCorrections(const ::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections& /*corrections*/) {
return true;
}
Return<bool> MeasurementCorrections::setCallback(
const sp<V1_0::IMeasurementCorrectionsCallback>& /*callback*/) {
return true;
}
} // namespace implementation
} // namespace V1_0
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware
} // namespace android

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();
}