From f2fb47a4a0bc1205abb6216c1a17411d8c243ae4 Mon Sep 17 00:00:00 2001 From: Arian Date: Fri, 23 Oct 2020 19:22:47 +0200 Subject: [PATCH] davinci: gps: Update to LA.UM.9.1.r1-06700-SMxxx0.0 Change-Id: I7441cf1b3d067969dad0ad3d57c27bb87a276189 --- BoardConfig.mk | 2 +- device.mk | 4 +- gps/Android.bp | 45 + gps/Android.mk | 42 +- .../android.hardware.gnss@2.0-service-qti.rc | 4 - gps/android/2.0/location_api/LocationUtil.cpp | 278 --- gps/android/{2.0 => 2.1}/AGnss.cpp | 8 +- gps/android/{2.0 => 2.1}/AGnss.h | 9 +- gps/android/{2.0 => 2.1}/AGnssRil.cpp | 6 +- gps/android/{2.0 => 2.1}/AGnssRil.h | 6 +- gps/android/{2.0 => 2.1}/Android.mk | 28 +- gps/android/{2.0 => 2.1}/Gnss.cpp | 238 +- gps/android/{2.0 => 2.1}/Gnss.h | 54 +- gps/android/2.1/GnssAntennaInfo.cpp | 202 ++ .../GnssAntennaInfo.h} | 66 +- gps/android/{2.0 => 2.1}/GnssBatching.cpp | 12 +- gps/android/{2.0 => 2.1}/GnssBatching.h | 6 +- .../{2.0 => 2.1}/GnssConfiguration.cpp | 147 +- gps/android/{2.0 => 2.1}/GnssConfiguration.h | 32 +- gps/android/{2.0 => 2.1}/GnssDebug.cpp | 6 +- gps/android/{2.0 => 2.1}/GnssDebug.h | 6 +- gps/android/{2.0 => 2.1}/GnssGeofencing.cpp | 8 +- gps/android/{2.0 => 2.1}/GnssGeofencing.h | 6 +- gps/android/{2.0 => 2.1}/GnssMeasurement.cpp | 70 +- gps/android/{2.0 => 2.1}/GnssMeasurement.h | 33 +- gps/android/{2.0 => 2.1}/GnssNi.cpp | 6 +- gps/android/{2.0 => 2.1}/GnssNi.h | 6 +- .../1.0 => 2.1}/GnssVisibilityControl.cpp | 0 .../1.0 => 2.1}/GnssVisibilityControl.h | 2 +- gps/android/2.1/MeasurementCorrections.cpp | 199 ++ gps/android/2.1/MeasurementCorrections.h | 106 + .../android.hardware.gnss@2.1-service-qti.rc | 4 + ...android.hardware.gnss@2.1-service-qti.xml} | 4 +- .../location_api/BatchingAPIClient.cpp | 8 +- .../location_api/BatchingAPIClient.h | 9 +- .../location_api/GeofenceAPIClient.cpp | 6 +- .../location_api/GeofenceAPIClient.h | 9 +- .../location_api/GnssAPIClient.cpp | 205 +- .../{2.0 => 2.1}/location_api/GnssAPIClient.h | 16 +- gps/android/2.1/location_api/LocationUtil.cpp | 492 ++++ .../{2.0 => 2.1}/location_api/LocationUtil.h | 17 +- .../location_api/MeasurementAPIClient.cpp | 376 ++- .../location_api/MeasurementAPIClient.h | 19 +- gps/android/{2.0 => 2.1}/service.cpp | 36 +- gps/android/Android.mk | 7 +- gps/android/utils/Android.bp | 37 + gps/android/utils/Android.mk | 33 - gps/android/utils/battery_listener.cpp | 102 +- gps/batching/Android.bp | 31 + gps/batching/Android.mk | 36 - gps/batching/Makefile.am | 3 +- gps/batching/configure.ac | 6 +- gps/core/Android.bp | 56 + gps/core/Android.mk | 59 - gps/core/ContextBase.cpp | 95 +- gps/core/ContextBase.h | 13 +- gps/core/EngineHubProxyBase.h | 36 +- gps/core/LocAdapterBase.cpp | 27 +- gps/core/LocAdapterBase.h | 33 +- gps/core/LocApiBase.cpp | 104 +- gps/core/LocApiBase.h | 55 +- gps/core/Makefile.am | 8 + gps/core/SystemStatus.cpp | 19 +- gps/core/SystemStatus.h | 40 +- gps/core/SystemStatusOsObserver.cpp | 89 +- gps/core/SystemStatusOsObserver.h | 37 +- gps/core/configure.ac | 27 +- gps/core/data-items/DataItemsFactoryProxy.cpp | 48 +- gps/core/loc_core_log.cpp | 58 +- gps/core/observer/IFrameworkActionReq.h | 11 +- gps/core/observer/IOsObserver.h | 6 +- gps/etc/Android.bp | 27 + gps/etc/seccomp_policy/gnss@2.0-base.policy | 95 + .../gnss@2.0-xtra-daemon.policy | 48 + .../gnss@2.0-xtwifi-client.policy | 45 + .../gnss@2.0-xtwifi-inet-agent.policy | 33 + gps/geofence/Android.bp | 31 + gps/geofence/Android.mk | 35 - gps/geofence/GeofenceAdapter.cpp | 49 +- gps/geofence/configure.ac | 2 +- gps/gnss/Agps.cpp | 16 +- gps/gnss/Agps.h | 15 +- gps/gnss/Android.bp | 34 + gps/gnss/Android.mk | 46 - gps/gnss/GnssAdapter.cpp | 2103 +++++++++++++++-- gps/gnss/GnssAdapter.h | 180 +- gps/gnss/XtraSystemStatusObserver.cpp | 64 +- gps/gnss/XtraSystemStatusObserver.h | 24 +- gps/gnss/location_gnss.cpp | 200 +- gps/location/Android.bp | 36 + gps/location/Android.mk | 41 - gps/location/ILocationAPI.h | 178 +- gps/location/LocationAPI.cpp | 157 +- gps/location/LocationAPI.h | 179 +- gps/location/LocationAPIClientBase.cpp | 21 +- gps/location/LocationAPIClientBase.h | 11 +- gps/location/LocationDataTypes.h | 732 +++++- gps/location/Makefile.am | 4 + gps/location/configure.ac | 15 +- gps/location/location_interface.h | 28 +- gps/pla/Android.bp | 7 + gps/pla/Android.mk | 29 - gps/pla/android/loc_pla.h | 35 +- gps/pla/oe/loc_pla.h | 81 +- gps/utils/Android.bp | 54 + gps/utils/Android.mk | 65 - gps/utils/LocIpc.cpp | 107 +- gps/utils/LocIpc.h | 80 +- .../LocLoggerBase.h} | 54 +- gps/utils/LocTimer.cpp | 2 +- gps/utils/LocUnorderedSetMap.h | 29 +- gps/utils/LogBuffer.cpp | 189 ++ gps/utils/LogBuffer.h | 95 + gps/utils/Makefile.am | 5 +- gps/utils/MsgTask.cpp | 4 +- gps/utils/SkipList.h | 158 ++ gps/utils/configure.ac | 2 +- gps/utils/gps_extended_c.h | 429 ++-- gps/utils/loc_cfg.cpp | 149 +- gps/utils/loc_cfg.h | 9 +- gps/utils/loc_gps.h | 8 +- gps/utils/loc_log.cpp | 137 +- gps/utils/loc_log.h | 97 +- gps/utils/loc_misc_utils.cpp | 95 +- gps/utils/loc_misc_utils.h | 159 +- gps/utils/loc_nmea.cpp | 490 ++-- gps/utils/loc_nmea.h | 6 +- gps/utils/loc_target.cpp | 53 +- gps/utils/loc_target.h | 4 + gps/utils/log_util.h | 86 +- gps/utils/msg_q.c | 2 + 131 files changed, 8722 insertions(+), 2361 deletions(-) create mode 100644 gps/Android.bp delete mode 100644 gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc delete mode 100644 gps/android/2.0/location_api/LocationUtil.cpp rename gps/android/{2.0 => 2.1}/AGnss.cpp (97%) rename gps/android/{2.0 => 2.1}/AGnss.h (91%) rename gps/android/{2.0 => 2.1}/AGnssRil.cpp (97%) rename gps/android/{2.0 => 2.1}/AGnssRil.h (96%) rename gps/android/{2.0 => 2.1}/Android.mk (72%) rename gps/android/{2.0 => 2.1}/Gnss.cpp (75%) rename gps/android/{2.0 => 2.1}/Gnss.h (78%) create mode 100644 gps/android/2.1/GnssAntennaInfo.cpp rename gps/android/{measurement_corrections/1.0/MeasurementCorrections.h => 2.1/GnssAntennaInfo.h} (53%) rename gps/android/{2.0 => 2.1}/GnssBatching.cpp (96%) rename gps/android/{2.0 => 2.1}/GnssBatching.h (96%) rename gps/android/{2.0 => 2.1}/GnssConfiguration.cpp (67%) rename gps/android/{2.0 => 2.1}/GnssConfiguration.h (65%) rename gps/android/{2.0 => 2.1}/GnssDebug.cpp (99%) rename gps/android/{2.0 => 2.1}/GnssDebug.h (94%) rename gps/android/{2.0 => 2.1}/GnssGeofencing.cpp (96%) rename gps/android/{2.0 => 2.1}/GnssGeofencing.h (96%) rename gps/android/{2.0 => 2.1}/GnssMeasurement.cpp (75%) rename gps/android/{2.0 => 2.1}/GnssMeasurement.h (68%) rename gps/android/{2.0 => 2.1}/GnssNi.cpp (95%) rename gps/android/{2.0 => 2.1}/GnssNi.h (95%) rename gps/android/{visibility_control/1.0 => 2.1}/GnssVisibilityControl.cpp (100%) rename gps/android/{visibility_control/1.0 => 2.1}/GnssVisibilityControl.h (98%) create mode 100644 gps/android/2.1/MeasurementCorrections.cpp create mode 100644 gps/android/2.1/MeasurementCorrections.h create mode 100644 gps/android/2.1/android.hardware.gnss@2.1-service-qti.rc rename gps/android/{2.0/android.hardware.gnss@2.0-service-qti.xml => 2.1/android.hardware.gnss@2.1-service-qti.xml} (93%) mode change 100644 => 100755 rename gps/android/{2.0 => 2.1}/location_api/BatchingAPIClient.cpp (98%) mode change 100644 => 100755 rename gps/android/{2.0 => 2.1}/location_api/BatchingAPIClient.h (96%) mode change 100644 => 100755 rename gps/android/{2.0 => 2.1}/location_api/GeofenceAPIClient.cpp (99%) mode change 100644 => 100755 rename gps/android/{2.0 => 2.1}/location_api/GeofenceAPIClient.h (96%) mode change 100644 => 100755 rename gps/android/{2.0 => 2.1}/location_api/GnssAPIClient.cpp (77%) rename gps/android/{2.0 => 2.1}/location_api/GnssAPIClient.h (91%) mode change 100644 => 100755 create mode 100644 gps/android/2.1/location_api/LocationUtil.cpp rename gps/android/{2.0 => 2.1}/location_api/LocationUtil.h (76%) rename gps/android/{2.0 => 2.1}/location_api/MeasurementAPIClient.cpp (52%) rename gps/android/{2.0 => 2.1}/location_api/MeasurementAPIClient.h (85%) rename gps/android/{2.0 => 2.1}/service.cpp (64%) mode change 100644 => 100755 create mode 100644 gps/android/utils/Android.bp delete mode 100644 gps/android/utils/Android.mk create mode 100644 gps/batching/Android.bp delete mode 100644 gps/batching/Android.mk create mode 100644 gps/core/Android.bp delete mode 100644 gps/core/Android.mk create mode 100644 gps/etc/Android.bp create mode 100644 gps/etc/seccomp_policy/gnss@2.0-base.policy create mode 100644 gps/etc/seccomp_policy/gnss@2.0-xtra-daemon.policy create mode 100644 gps/etc/seccomp_policy/gnss@2.0-xtwifi-client.policy create mode 100644 gps/etc/seccomp_policy/gnss@2.0-xtwifi-inet-agent.policy create mode 100644 gps/geofence/Android.bp delete mode 100644 gps/geofence/Android.mk create mode 100644 gps/gnss/Android.bp delete mode 100644 gps/gnss/Android.mk create mode 100644 gps/location/Android.bp delete mode 100644 gps/location/Android.mk create mode 100644 gps/pla/Android.bp delete mode 100644 gps/pla/Android.mk create mode 100644 gps/utils/Android.bp delete mode 100644 gps/utils/Android.mk rename gps/{android/measurement_corrections/1.0/MeasurementCorrections.cpp => utils/LocLoggerBase.h} (53%) create mode 100644 gps/utils/LogBuffer.cpp create mode 100644 gps/utils/LogBuffer.h create mode 100644 gps/utils/SkipList.h diff --git a/BoardConfig.mk b/BoardConfig.mk index 65d979d..ecc6466 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -91,7 +91,7 @@ TARGET_USES_FOD_ZPOS := true # GPS BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default -LOC_HIDL_VERSION := 3.0 +LOC_HIDL_VERSION := 4.0 # HIDL DEVICE_MANIFEST_FILE := $(DEVICE_PATH)/configs/hidl/manifest.xml diff --git a/device.mk b/device.mk index 57d2c34..3935302 100644 --- a/device.mk +++ b/device.mk @@ -169,8 +169,8 @@ PRODUCT_COPY_FILES += \ # GPS PRODUCT_PACKAGES += \ - android.hardware.gnss@2.0-impl-qti \ - android.hardware.gnss@2.0-service-qti + android.hardware.gnss@2.1-impl-qti \ + android.hardware.gnss@2.1-service-qti PRODUCT_PACKAGES += \ libbatching \ diff --git a/gps/Android.bp b/gps/Android.bp new file mode 100644 index 0000000..ea0d991 --- /dev/null +++ b/gps/Android.bp @@ -0,0 +1,45 @@ +GNSS_CFLAGS = [ + "-Werror", + "-Wno-error=unused-parameter", + "-Wno-error=macro-redefined", + "-Wno-error=reorder", + "-Wno-error=missing-braces", + "-Wno-error=self-assign", + "-Wno-error=enum-conversion", + "-Wno-error=logical-op-parentheses", + "-Wno-error=null-arithmetic", + "-Wno-error=null-conversion", + "-Wno-error=parentheses-equality", + "-Wno-error=undefined-bool-conversion", + "-Wno-error=tautological-compare", + "-Wno-error=switch", + "-Wno-error=date-time", +] + +/* Activate the following for regression testing */ +GNSS_SANITIZE = { +/* address: true,*/ + cfi: true, + misc_undefined: [ + "bounds", + "null", + "unreachable", + "integer", + ], +} + +/* Activate the following for debug purposes only, + comment out for production */ +GNSS_SANITIZE_DIAG = { +/* + diag: { + cfi: true, + misc_undefined: [ + "bounds", + "null", + "unreachable", + "integer", + ], + }, +*/ +} diff --git a/gps/Android.mk b/gps/Android.mk index 0f8c039..83e2dcd 100644 --- a/gps/Android.mk +++ b/gps/Android.mk @@ -1,22 +1,26 @@ -# -# Copyright (C) 2020 The LineageOS Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) -LOCAL_PATH := $(call my-dir) -include $(call first-makefiles-under,$(LOCAL_PATH)) +# Set required flags +GNSS_CFLAGS := \ + -Werror \ + -Wno-error=unused-parameter \ + -Wno-error=macro-redefined \ + -Wno-error=reorder \ + -Wno-error=missing-braces \ + -Wno-error=self-assign \ + -Wno-error=enum-conversion \ + -Wno-error=logical-op-parentheses \ + -Wno-error=null-arithmetic \ + -Wno-error=null-conversion \ + -Wno-error=parentheses-equality \ + -Wno-error=undefined-bool-conversion \ + -Wno-error=tautological-compare \ + -Wno-error=switch \ + -Wno-error=date-time -endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE +LOCAL_PATH := $(call my-dir) +include $(call all-makefiles-under,$(LOCAL_PATH)) + +GNSS_SANITIZE := cfi bounds null unreachable integer + +endif # ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) diff --git a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc b/gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc deleted file mode 100644 index 36ee47c..0000000 --- a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc +++ /dev/null @@ -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 diff --git a/gps/android/2.0/location_api/LocationUtil.cpp b/gps/android/2.0/location_api/LocationUtil.cpp deleted file mode 100644 index 38a083a..0000000 --- a/gps/android/2.0/location_api/LocationUtil.cpp +++ /dev/null @@ -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 -#include -#include - -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(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,¤tTime)) { - - 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(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 diff --git a/gps/android/2.0/AGnss.cpp b/gps/android/2.1/AGnss.cpp similarity index 97% rename from gps/android/2.0/AGnss.cpp rename to gps/android/2.1/AGnss.cpp index 7bd015e..c759492 100644 --- a/gps/android/2.0/AGnss.cpp +++ b/gps/android/2.1/AGnss.cpp @@ -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 AGnss::setCallback(const sp& 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 AGnss::setServer(V2_0::IAGnssCallback::AGnssType type, } } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/AGnss.h b/gps/android/2.1/AGnss.h similarity index 91% rename from gps/android/2.0/AGnss.h rename to gps/android/2.1/AGnss.h index c442327..f6ea997 100644 --- a/gps/android/2.0/AGnss.h +++ b/gps/android/2.1/AGnss.h @@ -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 mAGnssCbIface = nullptr; + sp mAGnssCbIface = nullptr; }; } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/AGnssRil.cpp b/gps/android/2.1/AGnssRil.cpp similarity index 97% rename from gps/android/2.0/AGnssRil.cpp rename to gps/android/2.1/AGnssRil.cpp index a477fc2..65fb300 100644 --- a/gps/android/2.0/AGnssRil.cpp +++ b/gps/android/2.1/AGnssRil.cpp @@ -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 AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttr } } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/AGnssRil.h b/gps/android/2.1/AGnssRil.h similarity index 96% rename from gps/android/2.0/AGnssRil.h rename to gps/android/2.1/AGnssRil.h index a04d8aa..2bf6156 100644 --- a/gps/android/2.0/AGnssRil.h +++ b/gps/android/2.1/AGnssRil.h @@ -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 diff --git a/gps/android/2.0/Android.mk b/gps/android/2.1/Android.mk similarity index 72% rename from gps/android/2.0/Android.mk rename to gps/android/2.1/Android.mk index 0cb0ddd..a947e41 100644 --- a/gps/android/2.0/Android.mk +++ b/gps/android/2.1/Android.mk @@ -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) diff --git a/gps/android/2.0/Gnss.cpp b/gps/android/2.1/Gnss.cpp similarity index 75% rename from gps/android/2.0/Gnss.cpp rename to gps/android/2.1/Gnss.cpp index af76b72..a83271e 100644 --- a/gps/android/2.0/Gnss.cpp +++ b/gps/android/2.1/Gnss.cpp @@ -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 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 Gnss::setCallback(const sp& 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 Gnss::setCallback(const sp& 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 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 Gnss::injectLocation(double latitudeDegrees, Return 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 Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) { @@ -376,38 +369,49 @@ Return> Gnss::getExtensionGnssNi() { Return> Gnss::getExtensionGnssMeasurement() { ENTRY_LOG_CALLFLOW(); - if (mGnssMeasurement == nullptr) + if (mGnssMeasurement == nullptr) { mGnssMeasurement = new GnssMeasurement(); + } return mGnssMeasurement; } Return> Gnss::getExtensionGnssConfiguration() { ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } return mGnssConfig; } Return> Gnss::getExtensionGnssGeofencing() { ENTRY_LOG_CALLFLOW(); - mGnssGeofencingIface = new GnssGeofencing(); + if (mGnssGeofencingIface == nullptr) { + mGnssGeofencingIface = new GnssGeofencing(); + } return mGnssGeofencingIface; } Return> Gnss::getExtensionGnssBatching() { ENTRY_LOG_CALLFLOW(); - mGnssBatching = new GnssBatching(); + if (mGnssBatching == nullptr) { + mGnssBatching = new GnssBatching(); + } return mGnssBatching; } Return> Gnss::getExtensionGnssDebug() { ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); + if (mGnssDebug == nullptr) { + mGnssDebug = new GnssDebug(this); + } return mGnssDebug; } Return> Gnss::getExtensionAGnssRil() { ENTRY_LOG_CALLFLOW(); - mGnssRil = new AGnssRil(this); + if (mGnssRil == nullptr) { + mGnssRil = new AGnssRil(this); + } return mGnssRil; } @@ -420,11 +424,12 @@ Return Gnss::setCallback_1_1(const sp& 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 Gnss::setCallback_1_1(const sp& 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 Gnss::setCallback_1_1(const sp& 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 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 Gnss::setCallback_2_0(const sp& 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 Gnss::setCallback_2_0(const sp& 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 Gnss::setCallback_2_0(const sp& 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 Gnss::setCallback_2_0(const sp& callback) { Return> 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> Gnss::getExtensionAGnssRil_2_0() { - mGnssRil = new AGnssRil(this); + + if (mGnssRil == nullptr) { + mGnssRil = new AGnssRil(this); + } return mGnssRil; } Return> Gnss::getExtensionGnssConfiguration_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } return mGnssConfig; } Return> Gnss::getExtensionGnssMeasurement_2_0() { @@ -617,11 +654,25 @@ Return> Gnss::getExtensionGnssMeasurement_2_0() { return mGnssMeasurement; #endif } -Return> + +Return> 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> + Gnss::getExtensionMeasurementCorrections_1_1() { + ENTRY_LOG_CALLFLOW(); + if (mGnssMeasCorr == nullptr) { + mGnssMeasCorr = new MeasurementCorrections(this); + } + return mGnssMeasCorr; +} + Return> Gnss::getExtensionVisibilityControl() { ENTRY_LOG_CALLFLOW(); @@ -644,14 +695,91 @@ Return Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation Return> Gnss::getExtensionGnssDebug_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); + if (mGnssDebug == nullptr) { + mGnssDebug = new GnssDebug(this); + } return mGnssDebug; } Return> Gnss::getExtensionGnssBatching_2_0() { + return nullptr; +} + +// Methods from ::android::hardware::gnss::V2_1::IGnss follow. +Return Gnss::setCallback_2_1(const sp& 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> Gnss::getExtensionGnssMeasurement_2_1() { + ENTRY_LOG_CALLFLOW(); + if (mGnssMeasurement == nullptr) { + mGnssMeasurement = new GnssMeasurement(); + } + return mGnssMeasurement; +} +Return> Gnss::getExtensionGnssConfiguration_2_1() { + ENTRY_LOG_CALLFLOW(); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } + return mGnssConfig; +} + +Return> 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 diff --git a/gps/android/2.0/Gnss.h b/gps/android/2.1/Gnss.h similarity index 78% rename from gps/android/2.0/Gnss.h rename to gps/android/2.1/Gnss.h index a403d61..c383882 100644 --- a/gps/android/2.0/Gnss.h +++ b/gps/android/2.1/Gnss.h @@ -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 #include @@ -29,8 +29,10 @@ #include #include #include +#include -#include +#include +#include #include #include #include @@ -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> getExtensionAGnssRil_2_0() override; Return> getExtensionGnssConfiguration_2_0() override; - Return> - getExtensionMeasurementCorrections() override; + Return> getExtensionMeasurementCorrections() override; + Return> getExtensionMeasurementCorrections_1_1() override; Return> getExtensionGnssMeasurement_2_0() override; - Return injectBestLocation_2_0(const ::android::hardware::gnss::V2_0::GnssLocation& location) override; + Return injectBestLocation_2_0( + const ::android::hardware::gnss::V2_0::GnssLocation& location) override; Return> getExtensionGnssBatching_2_0() override; Return> getExtensionGnssDebug_2_0() override; - - - /** - * This method returns the IGnssVisibilityControl interface. - * - * @return visibilityControlIface Handle to the IGnssVisibilityControl interface. - */ Return> getExtensionVisibilityControl() override; + // Methods from ::android::hardware::gnss::V2_1::IGnss follow. + Return setCallback_2_1(const sp& callback) override; + Return> getExtensionGnssMeasurement_2_1() override; + Return> getExtensionGnssConfiguration_2_1() override; + Return> getExtensionGnssAntennaInfo() override; // These methods are not part of the IGnss base class. GnssAPIClient* getApi(); @@ -163,12 +167,14 @@ struct Gnss : public IGnss { sp mGnssCbIface_1_1 = nullptr; sp mAGnssIface_2_0 = nullptr; sp mGnssRil = nullptr; - sp mGnssMeasurement = nullptr; - sp mGnssConfig = nullptr; sp mGnssBatching = nullptr; sp mGnssDebug = nullptr; sp mGnssCbIface_2_0 = nullptr; - sp mGnssMeasCorr = nullptr; + sp mGnssCbIface_2_1 = nullptr; + sp mGnssMeasurement = nullptr; + sp mGnssConfig = nullptr; + sp mGnssAntennaInfo = nullptr; + sp mGnssMeasCorr = nullptr; sp 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 diff --git a/gps/android/2.1/GnssAntennaInfo.cpp b/gps/android/2.1/GnssAntennaInfo.cpp new file mode 100644 index 0000000..62c4cc7 --- /dev/null +++ b/gps/android/2.1/GnssAntennaInfo.cpp @@ -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 +#include "Gnss.h" +#include "GnssAntennaInfo.h" +#include + +namespace android { +namespace hardware { +namespace gnss { +namespace V2_1 { +namespace implementation { + +static GnssAntennaInfo* spGnssAntennaInfo = nullptr; + +static void convertGnssAntennaInfo(std::vector& in, + hidl_vec& antennaInfos); + +void GnssAntennaInfo::GnssAntennaInfoDeathRecipient::serviceDied(uint64_t cookie, + const wp& who) { + LOC_LOGE("%s] service died. cookie: %llu, who: %p", + __FUNCTION__, static_cast(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& in, + hidl_vec& 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::setCallback(const sp& 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 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 gnssAntennaInformations) { + if (nullptr != spGnssAntennaInfo) { + spGnssAntennaInfo->gnssAntennaInfoCb(gnssAntennaInformations); + } +} + +void GnssAntennaInfo::gnssAntennaInfoCb + (std::vector gnssAntennaInformations) { + + if (mGnssAntennaInfoCbIface != nullptr) { + hidl_vec 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 diff --git a/gps/android/measurement_corrections/1.0/MeasurementCorrections.h b/gps/android/2.1/GnssAntennaInfo.h similarity index 53% rename from gps/android/measurement_corrections/1.0/MeasurementCorrections.h rename to gps/android/2.1/GnssAntennaInfo.h index ad534dc..02ddd28 100644 --- a/gps/android/measurement_corrections/1.0/MeasurementCorrections.h +++ b/gps/android/2.1/GnssAntennaInfo.h @@ -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 -#include -#include +#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H +#define ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H + +#include #include -#include - 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 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 + setCallback(const sp& callback) override; + Return close(void) override; -Return setCallback(const sp& callback) override; + void gnssAntennaInfoCb(std::vector gnssAntennaInformations); + static void aiGnssAntennaInfoCb(std::vector gnssAntennaInformations); + + private: + struct GnssAntennaInfoDeathRecipient : hidl_death_recipient { + GnssAntennaInfoDeathRecipient(sp gnssAntennaInfo) : + mGnssAntennaInfo(gnssAntennaInfo) { + } + ~GnssAntennaInfoDeathRecipient() = default; + virtual void serviceDied(uint64_t cookie, const wp& who) override; + sp mGnssAntennaInfo; + }; + + private: + sp mGnssAntennaInfoDeathRecipient = nullptr; + sp 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 diff --git a/gps/android/2.0/GnssBatching.cpp b/gps/android/2.1/GnssBatching.cpp similarity index 96% rename from gps/android/2.0/GnssBatching.cpp rename to gps/android/2.1/GnssBatching.cpp index 7a937fc..73e3532 100644 --- a/gps/android/2.0/GnssBatching.cpp +++ b/gps/android/2.1/GnssBatching.cpp @@ -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 GnssBatching::init(const sp& 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 GnssBatching::cleanup() { Return GnssBatching::init_2_0(const sp& 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 GnssBatching::init_2_0(const sp& callb } } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/GnssBatching.h b/gps/android/2.1/GnssBatching.h similarity index 96% rename from gps/android/2.0/GnssBatching.h rename to gps/android/2.1/GnssBatching.h index 4c8d1db..908748f 100644 --- a/gps/android/2.0/GnssBatching.h +++ b/gps/android/2.1/GnssBatching.h @@ -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 diff --git a/gps/android/2.0/GnssConfiguration.cpp b/gps/android/2.1/GnssConfiguration.cpp similarity index 67% rename from gps/android/2.0/GnssConfiguration.cpp rename to gps/android/2.1/GnssConfiguration.cpp index 363d2b1..b6077ae 100644 --- a/gps/android/2.0/GnssConfiguration.cpp +++ b/gps/android/2.1/GnssConfiguration.cpp @@ -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 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 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 GnssConfiguration::setSuplMode(uint8_t mode) { default: LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode); return false; - break; } return mGnss->updateConfiguration(config); } -Return GnssConfiguration::setLppProfile(uint8_t lppProfile) { +Return GnssConfiguration::setLppProfile(uint8_t lppProfileMask) { if (mGnss == nullptr) { LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); return false; @@ -114,23 +115,19 @@ Return 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 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 GnssConfiguration::setEmergencySuplPdn(bool enabled) { // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow. Return GnssConfiguration::setBlacklist( - const hidl_vec& blacklist) { + const hidl_vec& blacklist) { ENTRY_LOG_CALLFLOW(); if (nullptr == mGnss) { @@ -238,7 +234,8 @@ Return 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 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 GnssConfiguration::setEsExtensionSec(uint32_t emergencyExtensionSec return mGnss->updateConfiguration(config); } +// Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow. +Return GnssConfiguration::setBlacklist_2_1( + const hidl_vec& 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 diff --git a/gps/android/2.0/GnssConfiguration.h b/gps/android/2.1/GnssConfiguration.h similarity index 65% rename from gps/android/2.0/GnssConfiguration.h rename to gps/android/2.1/GnssConfiguration.h index 202a9fd..f000dbd 100644 --- a/gps/android/2.0/GnssConfiguration.h +++ b/gps/android/2.1/GnssConfiguration.h @@ -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 +#include #include 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 setSuplVersion(uint32_t version) override; Return setSuplMode(uint8_t mode) override; Return setSuplEs(bool enabled) override; - Return setLppProfile(uint8_t lppProfile) override; + Return setLppProfile(uint8_t lppProfileMask) override; Return setGlonassPositioningProtocol(uint8_t protocol) override; Return setEmergencySuplPdn(bool enable) override; Return setGpsLock(uint8_t lock) override; // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow. Return setBlacklist( - const hidl_vec& blacklist) override; + const hidl_vec& blacklist) override; // Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow. Return setEsExtensionSec(uint32_t emergencyExtensionSeconds) override; + // Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow. + Return setBlacklist_2_1( + const hidl_vec& 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 diff --git a/gps/android/2.0/GnssDebug.cpp b/gps/android/2.1/GnssDebug.cpp similarity index 99% rename from gps/android/2.0/GnssDebug.cpp rename to gps/android/2.1/GnssDebug.cpp index dc0d9f4..27ff964 100644 --- a/gps/android/2.0/GnssDebug.cpp +++ b/gps/android/2.1/GnssDebug.cpp @@ -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 GnssDebug::getDebugData_2_0(getDebugData_2_0_cb _hidl_cb) } } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/GnssDebug.h b/gps/android/2.1/GnssDebug.h similarity index 94% rename from gps/android/2.0/GnssDebug.h rename to gps/android/2.1/GnssDebug.h index 8d75bea..4eaf34a 100644 --- a/gps/android/2.0/GnssDebug.h +++ b/gps/android/2.1/GnssDebug.h @@ -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 diff --git a/gps/android/2.0/GnssGeofencing.cpp b/gps/android/2.1/GnssGeofencing.cpp similarity index 96% rename from gps/android/2.0/GnssGeofencing.cpp rename to gps/android/2.1/GnssGeofencing.cpp index b72d835..0ca3e6d 100644 --- a/gps/android/2.0/GnssGeofencing.cpp +++ b/gps/android/2.1/GnssGeofencing.cpp @@ -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 GnssGeofencing::removeAllGeofences() { } } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/GnssGeofencing.h b/gps/android/2.1/GnssGeofencing.h similarity index 96% rename from gps/android/2.0/GnssGeofencing.h rename to gps/android/2.1/GnssGeofencing.h index caa56d0..1cdca12 100644 --- a/gps/android/2.0/GnssGeofencing.h +++ b/gps/android/2.1/GnssGeofencing.h @@ -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 diff --git a/gps/android/2.0/GnssMeasurement.cpp b/gps/android/2.1/GnssMeasurement.cpp similarity index 75% rename from gps/android/2.0/GnssMeasurement.cpp rename to gps/android/2.1/GnssMeasurement.cpp index 721a48c..af75802 100644 --- a/gps/android/2.0/GnssMeasurement.cpp +++ b/gps/android/2.1/GnssMeasurement.cpp @@ -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::setCallback( return ret; } + clearInterfaces(); + mGnssMeasurementCbIface = callback; mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0); return mApi->measurementSetCallback(callback); } -Return 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 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 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::setCallback_1_1( return ret; } + clearInterfaces(); + mGnssMeasurementCbIface_1_1 = callback; mGnssMeasurementCbIface_1_1->linkToDeath(mGnssMeasurementDeathRecipient, 0); @@ -149,6 +161,8 @@ Return GnssMeasurement::setCallba return ret; } + clearInterfaces(); + mGnssMeasurementCbIface_2_0 = callback; mGnssMeasurementCbIface_2_0->linkToDeath(mGnssMeasurementDeathRecipient, 0); @@ -158,8 +172,40 @@ Return GnssMeasurement::setCallba return mApi->measurementSetCallback_2_0(callback, powerMode); } +// Methods from ::android::hardware::gnss::V2_1::IGnssMeasurement follow. +Return GnssMeasurement::setCallback_2_1( + const sp<::android::hardware::gnss::V2_1::IGnssMeasurementCallback>& callback, + bool enableFullTracking) { + Return 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 diff --git a/gps/android/2.0/GnssMeasurement.h b/gps/android/2.1/GnssMeasurement.h similarity index 68% rename from gps/android/2.0/GnssMeasurement.h rename to gps/android/2.1/GnssMeasurement.h index 000b00f..2ac45c6 100644 --- a/gps/android/2.0/GnssMeasurement.h +++ b/gps/android/2.1/GnssMeasurement.h @@ -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 +#include #include #include 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 setCallback( + Return setCallback( const sp& callback) override; Return close() override; // Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow. - Return setCallback_1_1( + Return setCallback_1_1( const sp& callback, bool enableFullTracking) override; // Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow. - Return setCallback_2_0( + Return setCallback_2_0( const sp& callback, bool enableFullTracking) override; + // Methods from ::android::hardware::gnss::V2_1::IGnssMeasurement follow. + Return setCallback_2_1( + const sp<::android::hardware::gnss::V2_1::IGnssMeasurementCallback>& callback, + bool enableFullTracking) override; + private: struct GnssMeasurementDeathRecipient : hidl_death_recipient { GnssMeasurementDeathRecipient(sp gnssMeasurement) : @@ -74,13 +79,15 @@ struct GnssMeasurement : public V2_0::IGnssMeasurement { sp mGnssMeasurementCbIface = nullptr; sp mGnssMeasurementCbIface_1_1 = nullptr; sp mGnssMeasurementCbIface_2_0 = nullptr; + sp 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 diff --git a/gps/android/2.0/GnssNi.cpp b/gps/android/2.1/GnssNi.cpp similarity index 95% rename from gps/android/2.0/GnssNi.cpp rename to gps/android/2.1/GnssNi.cpp index d65a488..ba5e8d9 100644 --- a/gps/android/2.0/GnssNi.cpp +++ b/gps/android/2.1/GnssNi.cpp @@ -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& who) { @@ -79,7 +79,7 @@ Return GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseT } } // namespace implementation -} // namespace V2_0 +} // namespace V2_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/gps/android/2.0/GnssNi.h b/gps/android/2.1/GnssNi.h similarity index 95% rename from gps/android/2.0/GnssNi.h rename to gps/android/2.1/GnssNi.h index 26e281f..9a8fb69 100644 --- a/gps/android/2.0/GnssNi.h +++ b/gps/android/2.1/GnssNi.h @@ -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 diff --git a/gps/android/visibility_control/1.0/GnssVisibilityControl.cpp b/gps/android/2.1/GnssVisibilityControl.cpp similarity index 100% rename from gps/android/visibility_control/1.0/GnssVisibilityControl.cpp rename to gps/android/2.1/GnssVisibilityControl.cpp diff --git a/gps/android/visibility_control/1.0/GnssVisibilityControl.h b/gps/android/2.1/GnssVisibilityControl.h similarity index 98% rename from gps/android/visibility_control/1.0/GnssVisibilityControl.h rename to gps/android/2.1/GnssVisibilityControl.h index 9c26e38..6794a64 100644 --- a/gps/android/visibility_control/1.0/GnssVisibilityControl.h +++ b/gps/android/2.1/GnssVisibilityControl.h @@ -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); diff --git a/gps/android/2.1/MeasurementCorrections.cpp b/gps/android/2.1/MeasurementCorrections.cpp new file mode 100644 index 0000000..f8f0803 --- /dev/null +++ b/gps/android/2.1/MeasurementCorrections.cpp @@ -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 +#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& who) { + LOC_LOGe("service died. cookie: %llu, who: %p", static_cast(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 MeasurementCorrections::setCorrections( + const MeasurementCorrectionsV1_0& corrections) { + + GnssMeasurementCorrections gnssMeasurementCorrections = {}; + + V2_1::implementation::convertMeasurementCorrections(corrections, gnssMeasurementCorrections); + + return mGnss->getGnssInterface()->measCorrSetCorrections(gnssMeasurementCorrections); +} + +Return 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 MeasurementCorrections::setCallback( + const sp& 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 diff --git a/gps/android/2.1/MeasurementCorrections.h b/gps/android/2.1/MeasurementCorrections.h new file mode 100644 index 0000000..92fcc6a --- /dev/null +++ b/gps/android/2.1/MeasurementCorrections.h @@ -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 +#include +#include +#include + +#include +#include +#include "Gnss.h" +#include + +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 setCorrections(const MeasurementCorrectionsV1_0& corrections) override; + + // Methods from + // ::android::hardware::gnss::measurement_corrections::V1_1::IMeasurementCorrections follow. + Return setCorrections_1_1(const MeasurementCorrectionsV1_1& corrections); + + Return setCallback(const sp& 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 gnssMeasurementCorrections) : + mGnssMeasurementCorrections(gnssMeasurementCorrections) { + } + ~GnssMeasurementCorrectionsDeathRecipient() = default; + virtual void serviceDied(uint64_t cookie, const wp& who) override; + sp mGnssMeasurementCorrections; + }; + Gnss* mGnss = nullptr; + sp mGnssMeasurementCorrectionsDeathRecipient = + nullptr; + sp mMeasurementCorrectionsCbIface = nullptr; +}; + + +} // namespace implementation +} // namespace V1_1 +} // namespace measurement_corrections +} // namespace gnss +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_GNSS_V1_1_MeasurementCorrections_H diff --git a/gps/android/2.1/android.hardware.gnss@2.1-service-qti.rc b/gps/android/2.1/android.hardware.gnss@2.1-service-qti.rc new file mode 100644 index 0000000..19e32c4 --- /dev/null +++ b/gps/android/2.1/android.hardware.gnss@2.1-service-qti.rc @@ -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 diff --git a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml b/gps/android/2.1/android.hardware.gnss@2.1-service-qti.xml old mode 100644 new mode 100755 similarity index 93% rename from gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml rename to gps/android/2.1/android.hardware.gnss@2.1-service-qti.xml index ff9fb2c..842fb6e --- a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml +++ b/gps/android/2.1/android.hardware.gnss@2.1-service-qti.xml @@ -1,4 +1,4 @@ -