Merge "Add GnssMeasurement AIDL HAL"

This commit is contained in:
TreeHugger Robot 2020-12-09 04:29:25 +00:00 committed by Android (Google) Code Review
commit 418390cf14
53 changed files with 1897 additions and 201 deletions

View file

@ -18,6 +18,7 @@ cc_binary {
"android.hardware.gnss@2.0",
"android.hardware.gnss@1.1",
"android.hardware.gnss@1.0",
"android.hardware.gnss-ndk_platform",
],
static_libs: [
"android.hardware.gnss@common-default-lib",

View file

@ -29,7 +29,7 @@ cc_binary {
"GnssMeasurement.cpp",
"GnssMeasurementCorrections.cpp",
"GnssVisibilityControl.cpp",
"service.cpp"
"service.cpp",
],
shared_libs: [
"libhidlbase",
@ -39,8 +39,9 @@ cc_binary {
"android.hardware.gnss.visibility_control@1.0",
"android.hardware.gnss@2.1",
"android.hardware.gnss@2.0",
"android.hardware.gnss@1.0",
"android.hardware.gnss@1.1",
"android.hardware.gnss@1.0",
"android.hardware.gnss-ndk_platform",
],
static_libs: [
"android.hardware.gnss@common-default-lib",

View file

@ -34,6 +34,7 @@ cc_binary {
"android.hardware.gnss@1.0",
"android.hardware.gnss@1.1",
"android.hardware.gnss@2.0",
"android.hardware.gnss-ndk_platform",
],
static_libs: [
"android.hardware.gnss@common-default-lib",

View file

@ -19,10 +19,9 @@
#include <android/hardware/gnss/2.1/IGnss.h>
#include "v2_1/gnss_hal_test_template.h"
using android::hardware::gnss::V2_1::IGnss;
// The main test class for GNSS HAL.
class GnssHalTest : public GnssHalTestTemplate<IGnss> {
class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<
android::hardware::gnss::V2_1::IGnss> {
public:
/**
* IsGnssHalVersion_2_1:

View file

@ -27,6 +27,9 @@ using android::hardware::hidl_vec;
using android::hardware::gnss::common::Utils;
using android::hardware::gnss::V2_1::IGnssAntennaInfo;
using android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
using IGnssMeasurement_2_1 = android::hardware::gnss::V2_1::IGnssMeasurement;
using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement;
using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement;

View file

@ -36,6 +36,7 @@ cc_binary {
"android.hardware.gnss@3.0",
"android.hardware.gnss.measurement_corrections@1.1",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss-ndk_platform",
],
static_libs: [
"android.hardware.gnss@common-default-lib",

View file

@ -19,7 +19,6 @@
#include <android/hardware/gnss/3.0/IGnss.h>
#include "v2_1/gnss_hal_test_template.h"
using android::hardware::gnss::V3_0::IGnss;
// The main test class for GNSS HAL.
class GnssHalTest : public GnssHalTestTemplate<IGnss> {};
class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<
android::hardware::gnss::V3_0::IGnss> {};

View file

@ -21,4 +21,6 @@ parcelable ElapsedRealtime {
int flags;
long timestampNs;
double timeUncertaintyNs;
const int HAS_TIMESTAMP_NS = 1;
const int HAS_TIME_UNCERTAINTY_NS = 2;
}

View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@VintfStability
parcelable GnssClock {
int gnssClockFlags;
int leapSecond;
long timeNs;
double timeUncertaintyNs;
long fullBiasNs;
double biasNs;
double biasUncertaintyNs;
double driftNsps;
double driftUncertaintyNsps;
int hwClockDiscontinuityCount;
android.hardware.gnss.GnssSignalType referenceSignalTypeForIsb;
const int HAS_LEAP_SECOND = 1;
const int HAS_TIME_UNCERTAINTY = 2;
const int HAS_FULL_BIAS = 4;
const int HAS_BIAS = 8;
const int HAS_BIAS_UNCERTAINTY = 16;
const int HAS_DRIFT = 32;
const int HAS_DRIFT_UNCERTAINTY = 64;
}

View file

@ -0,0 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@VintfStability
parcelable GnssData {
android.hardware.gnss.GnssMeasurement[] measurements;
android.hardware.gnss.GnssClock clock;
android.hardware.gnss.ElapsedRealtime elapsedRealtime;
}

View file

@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@VintfStability
parcelable GnssMeasurement {
int flags;
int svid;
android.hardware.gnss.GnssSignalType signalType;
double timeOffsetNs;
int state;
long receivedSvTimeInNs;
long receivedSvTimeUncertaintyInNs;
double antennaCN0DbHz;
double basebandCN0DbHz;
double pseudorangeRateMps;
double pseudorangeRateUncertaintyMps;
int accumulatedDeltaRangeState;
double accumulatedDeltaRangeM;
double accumulatedDeltaRangeUncertaintyM;
float carrierFrequencyHz;
long carrierCycles;
double carrierPhase;
double carrierPhaseUncertainty;
android.hardware.gnss.GnssMultipathIndicator multipathIndicator;
double snrDb;
double agcLevelDb;
double fullInterSignalBiasNs;
double fullInterSignalBiasUncertaintyNs;
double satelliteInterSignalBiasNs;
double satelliteInterSignalBiasUncertaintyNs;
const int HAS_SNR = 1;
const int HAS_CARRIER_FREQUENCY = 512;
const int HAS_CARRIER_CYCLES = 1024;
const int HAS_CARRIER_PHASE = 2048;
const int HAS_CARRIER_PHASE_UNCERTAINTY = 4096;
const int HAS_AUTOMATIC_GAIN_CONTROL = 8192;
const int HAS_FULL_ISB = 65536;
const int HAS_FULL_ISB_UNCERTAINTY = 131072;
const int HAS_SATELLITE_ISB = 262144;
const int HAS_SATELLITE_ISB_UNCERTAINTY = 524288;
const int STATE_UNKNOWN = 0;
const int STATE_CODE_LOCK = 1;
const int STATE_BIT_SYNC = 2;
const int STATE_SUBFRAME_SYNC = 4;
const int STATE_TOW_DECODED = 8;
const int STATE_MSEC_AMBIGUOUS = 16;
const int STATE_SYMBOL_SYNC = 32;
const int STATE_GLO_STRING_SYNC = 64;
const int STATE_GLO_TOD_DECODED = 128;
const int STATE_BDS_D2_BIT_SYNC = 256;
const int STATE_BDS_D2_SUBFRAME_SYNC = 512;
const int STATE_GAL_E1BC_CODE_LOCK = 1024;
const int STATE_GAL_E1C_2ND_CODE_LOCK = 2048;
const int STATE_GAL_E1B_PAGE_SYNC = 4096;
const int STATE_SBAS_SYNC = 8192;
const int STATE_TOW_KNOWN = 16384;
const int STATE_GLO_TOD_KNOWN = 32768;
const int STATE_2ND_CODE_LOCK = 65536;
const int ADR_STATE_UNKNOWN = 0;
const int ADR_STATE_VALID = 1;
const int ADR_STATE_RESET = 2;
const int ADR_STATE_CYCLE_SLIP = 4;
const int ADR_STATE_HALF_CYCLE_RESOLVED = 8;
}

View file

@ -0,0 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@Backing(type="int") @VintfStability
enum GnssMultipathIndicator {
UNKNOWN = 0,
PRESENT = 1,
NOT_PRESENT = 2,
}

View file

@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@VintfStability
parcelable GnssSignalType {
android.hardware.gnss.GnssConstellationType constellation;
double carrierFrequencyHz;
String codeType;
const String CODE_TYPE_A = "A";
const String CODE_TYPE_B = "B";
const String CODE_TYPE_C = "C";
const String CODE_TYPE_D = "D";
const String CODE_TYPE_I = "I";
const String CODE_TYPE_L = "L";
const String CODE_TYPE_M = "M";
const String CODE_TYPE_N = "N";
const String CODE_TYPE_P = "P";
const String CODE_TYPE_Q = "Q";
const String CODE_TYPE_S = "S";
const String CODE_TYPE_W = "W";
const String CODE_TYPE_X = "X";
const String CODE_TYPE_Y = "Y";
const String CODE_TYPE_Z = "Z";
const String CODE_TYPE_UNKNOWN = "UNKNOWN";
}

View file

@ -22,8 +22,7 @@ interface IGnss {
void close();
android.hardware.gnss.IGnssPsds getExtensionPsds();
android.hardware.gnss.IGnssConfiguration getExtensionGnssConfiguration();
android.hardware.gnss.IGnssMeasurementInterface getExtensionGnssMeasurement();
android.hardware.gnss.IGnssPowerIndication getExtensionGnssPowerIndication();
const int ERROR_INVALID_ARGUMENT = 1;
const int ELAPSED_REALTIME_HAS_TIMESTAMP_NS = 1;
const int ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS = 2;
}

View file

@ -0,0 +1,22 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@VintfStability
interface IGnssMeasurementCallback {
void gnssMeasurementCb(in android.hardware.gnss.GnssData data);
}

View file

@ -0,0 +1,23 @@
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
//
// You must not make a backward incompatible changes to the AIDL files built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.gnss;
@VintfStability
interface IGnssMeasurementInterface {
void setCallback(in android.hardware.gnss.IGnssMeasurementCallback callback, in boolean enableFullTracking);
void close();
}

View file

@ -22,10 +22,18 @@ package android.hardware.gnss;
@VintfStability
parcelable ElapsedRealtime {
/** Bit mask indicating a valid timestampNs is stored in the ElapsedRealtime parcelable. */
const int HAS_TIMESTAMP_NS = 1 << 0;
/**
* Bit mask indicating a valid timeUncertaintyNs is stored in the ElapsedRealtime parcelable.
*/
const int HAS_TIME_UNCERTAINTY_NS = 1 << 1;
/**
* A bit field of flags indicating the validity of each field in this data structure.
*
* The bit masks are defined in IGnss interface and prefixed with ELAPSED_REALTIME_HAS_.
* The bit masks are the constants with prefix HAS_.
*
* Fields may have invalid information in them, if not marked as valid by the corresponding bit
* in flags.

View file

@ -0,0 +1,203 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
import android.hardware.gnss.GnssSignalType;
/**
* Represents an estimate of the GNSS clock time.
*/
@VintfStability
parcelable GnssClock {
/** Bit mask indicating a valid 'leap second' is stored in the GnssClock. */
const int HAS_LEAP_SECOND = 1 << 0;
/** Bit mask indicating a valid 'time uncertainty' is stored in the GnssClock. */
const int HAS_TIME_UNCERTAINTY = 1 << 1;
/** Bit mask indicating a valid 'full bias' is stored in the GnssClock. */
const int HAS_FULL_BIAS = 1 << 2;
/** Bit mask indicating a valid 'bias' is stored in the GnssClock. */
const int HAS_BIAS = 1 << 3;
/** Bit mask indicating a valid 'bias uncertainty' is stored in the GnssClock. */
const int HAS_BIAS_UNCERTAINTY = 1 << 4;
/** Bit mask indicating a valid 'drift' is stored in the GnssClock. */
const int HAS_DRIFT = 1 << 5;
/** Bit mask indicating a valid 'drift uncertainty' is stored in the GnssClock. */
const int HAS_DRIFT_UNCERTAINTY = 1 << 6;
/**
* A bitfield of flags indicating the validity of the fields in this data
* structure.
*
* The bit masks are the constants with perfix HAS_.
*
* Fields for which there is no corresponding flag must be filled in
* with a valid value. For convenience, these are marked as mandatory.
*
* Others fields may have invalid information in them, if not marked as
* valid by the corresponding bit in gnssClockFlags.
*/
int gnssClockFlags;
/**
* Leap second data.
* The sign of the value is defined by the following equation:
* utcTimeNs = timeNs - (fullBiasNs + biasNs) - leapSecond *
* 1,000,000,000
*
* If this data is available, gnssClockFlags must contain
* HAS_LEAP_SECOND.
*/
int leapSecond;
/**
* The GNSS receiver internal clock value. This is the local hardware clock
* value.
*
* For local hardware clock, this value is expected to be monotonically
* increasing while the hardware clock remains powered on. (For the case of a
* HW clock that is not continuously on, see the
* hwClockDiscontinuityCount field). The receiver's estimate of GNSS time
* can be derived by subtracting the sum of fullBiasNs and biasNs (when
* available) from this value.
*
* This GNSS time must be the best estimate of current GNSS time
* that GNSS receiver can achieve.
*
* Sub-nanosecond accuracy can be provided by means of the 'biasNs' field.
* The value contains the timeUncertaintyNs in it.
*
* This value is mandatory.
*/
long timeNs;
/**
* 1-Sigma uncertainty associated with the clock's time in nanoseconds.
* The uncertainty is represented as an absolute (single sided) value.
*
* If the data is available, gnssClockFlags must contain
* HAS_TIME_UNCERTAINTY. Ths value is ideally zero, as the time
* 'latched' by timeNs is defined as the reference clock vs. which all
* other times (and corresponding uncertainties) are measured.
*/
double timeUncertaintyNs;
/**
* The difference between hardware clock ('time' field) inside GNSS receiver
* and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
*
* The sign of the value is defined by the following equation:
* local estimate of GPS time = timeNs - (fullBiasNs + biasNs)
*
* If receiver has computed time for a non-GPS constellation, the time offset of
* that constellation versus GPS time must be applied to fill this value.
*
* The error estimate for the sum of this and the biasNs is the biasUncertaintyNs.
*
* If the data is available gnssClockFlags must contain HAS_FULL_BIAS.
*
* This value is mandatory if the receiver has estimated GPS time.
*/
long fullBiasNs;
/**
* Sub-nanosecond bias - used with fullBiasNS, see fullBiasNs for details.
*
* The error estimate for the sum of this and the fullBiasNs is the
* biasUncertaintyNs.
*
* If the data is available gnssClockFlags must contain HAS_BIAS.
*
* This value is mandatory if the receiver has estimated GPS time.
*/
double biasNs;
/**
* 1-Sigma uncertainty associated with the local estimate of GNSS time (clock
* bias) in nanoseconds. The uncertainty is represented as an absolute
* (single sided) value.
*
* The caller is responsible for using this uncertainty (it can be very
* large before the GPS time has been fully resolved.)
*
* If the data is available gnssClockFlags must contain HAS_BIAS_UNCERTAINTY.
*
* This value is mandatory if the receiver has estimated GPS time.
*/
double biasUncertaintyNs;
/**
* The clock's drift in nanoseconds (per second).
*
* A positive value means that the frequency is higher than the nominal
* frequency, and that the (fullBiasNs + biasNs) is growing more positive
* over time.
*
* If the data is available gnssClockFlags must contain HAS_DRIFT.
*
* This value is mandatory if the receiver has estimated GPS time.
*/
double driftNsps;
/**
* 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per
* second).
* The uncertainty is represented as an absolute (single sided) value.
*
* If the data is available gnssClockFlags must contain HAS_DRIFT_UNCERTAINTY.
*
* This value is mandatory if the receiver has estimated GPS time.
*/
double driftUncertaintyNsps;
/**
* This field must be incremented, when there are discontinuities in the
* hardware clock.
*
* A "discontinuity" is meant to cover the case of a switch from one source
* of clock to another. A single free-running crystal oscillator (XO)
* will generally not have any discontinuities, and this can be set and
* left at 0.
*
* If, however, the timeNs value (HW clock) is derived from a composite of
* sources, that is not as smooth as a typical XO, or is otherwise stopped &
* restarted, then this value shall be incremented each time a discontinuity
* occurs. (E.g. this value can start at zero at device boot-up and
* increment each time there is a change in clock continuity. In the
* unlikely event that this value reaches full scale, rollover (not
* clamping) is required, such that this value continues to change, during
* subsequent discontinuity events.)
*
* While this number stays the same, between GnssClock reports, it can be
* safely assumed that the timeNs value has been running continuously, e.g.
* derived from a single, high quality clock (XO like, or better, that is
* typically used during continuous GNSS signal sampling.)
*
* It is expected, esp. during periods where there are few GNSS signals
* available, that the HW clock be discontinuity-free as long as possible,
* as this avoids the need to use (waste) a GNSS measurement to fully
* re-solve for the GNSS clock bias and drift, when using the accompanying
* measurements, from consecutive GnssData reports.
*
* This value is mandatory.
*/
int hwClockDiscontinuityCount;
/**
* Reference GNSS signal type for inter-signal bias.
*/
GnssSignalType referenceSignalTypeForIsb;
}

View file

@ -0,0 +1,44 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
import android.hardware.gnss.ElapsedRealtime;
import android.hardware.gnss.GnssClock;
import android.hardware.gnss.GnssMeasurement;
/**
* Represents a reading of GNSS measurements. For devices launched in Android Q or newer, it is
* mandatory that these be provided, on request, when the GNSS receiver is searching/tracking
* signals.
*
* - Reporting of GNSS constellation measurements is mandatory.
* - Reporting of all tracked constellations are encouraged.
*/
@VintfStability
parcelable GnssData {
/** The array of measurements. */
GnssMeasurement[] measurements;
/** The GNSS clock time reading. */
GnssClock clock;
/**
* Timing information of the GNSS data synchronized with SystemClock.elapsedRealtimeNanos()
* clock.
*/
ElapsedRealtime elapsedRealtime;
}

View file

@ -0,0 +1,634 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
import android.hardware.gnss.GnssConstellationType;
import android.hardware.gnss.GnssSignalType;
import android.hardware.gnss.GnssMultipathIndicator;
/**
* Represents a GNSS Measurement, it contains raw and computed information.
*
* All signal measurement information (e.g. svTime, pseudorangeRate, multipathIndicator) reported in
* this struct must be based on GNSS signal measurements only. You must not synthesize measurements
* by calculating or reporting expected measurements based on known or estimated position, velocity,
* or time.
*/
@VintfStability
parcelable GnssMeasurement {
/** Bit mask indicating a valid 'snr' is stored in the GnssMeasurement. */
const int HAS_SNR = 1 << 0;
/** Bit mask indicating a valid 'carrier frequency' is stored in the GnssMeasurement. */
const int HAS_CARRIER_FREQUENCY = 1 << 9;
/** Bit mask indicating a valid 'carrier cycles' is stored in the GnssMeasurement. */
const int HAS_CARRIER_CYCLES = 1 << 10;
/** Bit mask indicating a valid 'carrier phase' is stored in the GnssMeasurement. */
const int HAS_CARRIER_PHASE = 1 << 11;
/** Bit mask indicating a valid 'carrier phase uncertainty' is stored in the GnssMeasurement. */
const int HAS_CARRIER_PHASE_UNCERTAINTY = 1 << 12;
/** Bit mask indicating a valid automatic gain control is stored in the GnssMeasurement. */
const int HAS_AUTOMATIC_GAIN_CONTROL = 1 << 13;
/** Bit mask indicating a valid full inter-signal bias is stored in the GnssMeasurement. */
const int HAS_FULL_ISB = 1 << 16;
/**
* Bit mask indicating a valid full inter-signal bias uncertainty is stored in the
* GnssMeasurement.
*/
const int HAS_FULL_ISB_UNCERTAINTY = 1 << 17;
/**
* Bit mask indicating a valid satellite inter-signal bias is stored in the GnssMeasurement.
*/
const int HAS_SATELLITE_ISB = 1 << 18;
/**
* Bit mask indicating a valid satellite inter-signal bias uncertainty is stored in the
* GnssMeasurement.
*/
const int HAS_SATELLITE_ISB_UNCERTAINTY = 1 << 19;
/**
* A bitfield of flags indicating the validity of the fields in this GnssMeasurement. The bit
* masks are defined in the constants with prefix HAS_*
*
* Fields for which there is no corresponding flag must be filled in with a valid value. For
* convenience, these are marked as mandatory.
*
* Others fields may have invalid information in them, if not marked as valid by the
* corresponding bit in flags.
*/
int flags;
/**
* Satellite vehicle ID number, as defined in GnssSvInfo::svid
*
* This value is mandatory.
*/
int svid;
/**
* Defines the constellation of the given SV.
*
* This value is mandatory.
*/
GnssSignalType signalType;
/**
* Time offset at which the measurement was taken in nanoseconds.
* The reference receiver's time is specified by GnssData::clock::timeNs.
*
* The sign of timeOffsetNs is given by the following equation:
* measurement time = GnssClock::timeNs + timeOffsetNs
*
* It provides an individual time-stamp for the measurement, and allows
* sub-nanosecond accuracy. It may be zero if all measurements are
* aligned to a common time.
*
* This value is mandatory.
*/
double timeOffsetNs;
/**
* Flags indicating the GNSS measurement state.
*
* The expected behavior here is for GNSS HAL to set all the flags that apply. For example, if
* the state for a satellite is only C/A code locked and bit synchronized, and there is still
* millisecond ambiguity, the state must be set as:
*
* STATE_CODE_LOCK | STATE_BIT_SYNC | STATE_MSEC_AMBIGUOUS
*
* If GNSS is still searching for a satellite, the corresponding state must be set to
* STATE_UNKNOWN(0).
*
* The received satellite time is relative to the beginning of the system week for all
* constellations except for Glonass where it is relative to the beginning of the Glonass system
* day.
*
* The table below indicates the valid range of the received GNSS satellite time. These ranges
* depend on the constellation and code being tracked and the state of the tracking algorithms
* given by the getState method. If the state flag is set, then the valid measurement range is
* zero to the value in the table. The state flag with the widest range indicates the range of
* the received GNSS satellite time value.
*
* +---------------------------+--------------------+-----+-----------+--------------------+------+
* | |GPS/QZSS |GLNS |BDS |GAL |SBAS |
* +---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |State Flag |L1 |L5I |L5Q |L1OF |B1I |B1I |E1B |E1C |E5AQ |L1 |
* | |C/A | | | |(D1) |(D2)| | | |C/A |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_UNKNOWN |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_CODE_LOCK |1ms |1 ms |1 ms |1 ms |1 ms |1 ms|- |- |1 ms |1 ms |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_SYMBOL_SYNC |20ms |10 ms |1 ms |10 ms|20 ms |2 ms|4 ms |4 ms |1 ms |2 ms |
* | |(opt.)| |(opt.)| |(opt.)| |(opt.)|(opt.)|(opt.)| |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_BIT_SYNC |20 ms |20 ms |1 ms |20 ms|20 ms |- |8 ms |- |1 ms |4 ms |
* | | | |(opt.)| | | | | |(opt.)| |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_SUBFRAME_SYNC |6s |6s |- |2 s |6 s |- |- |- |100 ms|- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_TOW_DECODED |1 week|- |- |1 day|1 week|- |1 week|- |- |1 week|
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_TOW_KNOWN |1 week|- |- |1 day|1 week|- |1 week|- |- |1 week|
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_GLO_STRING_SYNC |- |- |- |2 s |- |- |- |- |- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_GLO_TOD_DECODED |- |- |- |1 day|- |- |- |- |- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_GLO_TOD_KNOWN |- |- |- |1 day|- |- |- |- |- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_BDS_D2_BIT_SYNC |- |- |- |- |- |2 ms|- |- |- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_BDS_D2_SUBFRAME_SYNC |- |- |- |- |- |600 |- |- |- |- |
* | | | | | | |ms | | | | |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_GAL_E1BC_CODE_LOCK |- |- |- |- |- |- |4 ms |4 ms |- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_GAL_E1C_2ND_CODE_LOCK|- |- |- |- |- |- |- |100 ms|- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_2ND_CODE_LOCK |- |10 ms |20 ms |- |- |- |- |100 ms|100 ms|- |
* | | |(opt.)| | | | | |(opt.)| | |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_GAL_E1B_PAGE_SYNC |- |- |- |- |- |- |2 s |- |- |- |
* |---------------------------+------+------+------+-----+------+----+------+------+------+------+
* |STATE_SBAS_SYNC |- |- |- |- |- |- |- |- |- |1s |
* +---------------------------+------+------+------+-----+------+----+------+------+------+------+
*
* Note: TOW Known refers to the case where TOW is possibly not decoded over the air but has
* been determined from other sources. If TOW decoded is set then TOW Known must also be set.
*
* Note well: if there is any ambiguity in integer millisecond, STATE_MSEC_AMBIGUOUS must be
* set accordingly, in the 'state' field. This value must be populated if 'state' !=
* STATE_UNKNOWN.
*
* Note on optional flags:
* - For L1 C/A and B1I, STATE_SYMBOL_SYNC is optional since the symbol length is the
* same as the bit length.
* - For L5Q and E5aQ, STATE_BIT_SYNC and STATE_SYMBOL_SYNC are optional since they are
* implied by STATE_CODE_LOCK.
* - STATE_2ND_CODE_LOCK for L5I is optional since it is implied by STATE_SYMBOL_SYNC.
* - STATE_2ND_CODE_LOCK for E1C is optional since it is implied by
* STATE_GAL_E1C_2ND_CODE_LOCK.
* - For E1B and E1C, STATE_SYMBOL_SYNC is optional, because it is implied by
* STATE_GAL_E1BC_CODE_LOCK.
*/
const int STATE_UNKNOWN = 0;
const int STATE_CODE_LOCK = 1 << 0;
const int STATE_BIT_SYNC = 1 << 1;
const int STATE_SUBFRAME_SYNC = 1 << 2;
const int STATE_TOW_DECODED = 1 << 3;
const int STATE_MSEC_AMBIGUOUS = 1 << 4;
const int STATE_SYMBOL_SYNC = 1 << 5;
const int STATE_GLO_STRING_SYNC = 1 << 6;
const int STATE_GLO_TOD_DECODED = 1 << 7;
const int STATE_BDS_D2_BIT_SYNC = 1 << 8;
const int STATE_BDS_D2_SUBFRAME_SYNC = 1 << 9;
const int STATE_GAL_E1BC_CODE_LOCK = 1 << 10;
const int STATE_GAL_E1C_2ND_CODE_LOCK = 1 << 11;
const int STATE_GAL_E1B_PAGE_SYNC = 1 << 12;
const int STATE_SBAS_SYNC = 1 << 13;
const int STATE_TOW_KNOWN = 1 << 14;
const int STATE_GLO_TOD_KNOWN = 1 << 15;
const int STATE_2ND_CODE_LOCK = 1 << 16;
/**
* A bitfield of flags indicating the GnssMeasurementState per satellite sync state. It
* represents the current sync state for the associated satellite.
*
* Based on the sync state, the 'received GNSS tow' field must be interpreted accordingly.
*
* The bit masks are defined in the constants with prefix STATE_.
*
* This value is mandatory.
*/
int state;
/**
* The received GNSS Time-of-Week at the measurement time, in nanoseconds.
* For GNSS & QZSS, this is the received GNSS Time-of-Week at the
* measurement time, in nanoseconds. The value is relative to the
* beginning of the current GNSS week.
*
* Given the highest sync state that can be achieved, per each satellite,
* valid range for this field can be:
* Searching : [ 0 ] : STATE_UNKNOWN
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK set
* Bit sync : [ 0 20ms ] : STATE_BIT_SYNC set
* Subframe sync : [ 0 6s ] : STATE_SUBFRAME_SYNC set
* TOW decoded : [ 0 1week ] : STATE_TOW_DECODED set
* TOW Known : [ 0 1week ] : STATE_TOW_KNOWN set
*
* Note: TOW Known refers to the case where TOW is possibly not decoded
* over the air but has been determined from other sources. If TOW
* decoded is set then TOW Known must also be set.
*
* Note: If there is any ambiguity in integer millisecond,
* STATE_MSEC_AMBIGUOUS must be set accordingly, in the
* 'state' field.
*
* This value must be populated if 'state' != STATE_UNKNOWN.
*
* For Glonass, this is the received Glonass time of day, at the
* measurement time in nanoseconds.
*
* Given the highest sync state that can be achieved, per each satellite,
* valid range for this field can be:
* Searching : [ 0 ] : STATE_UNKNOWN set
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK set
* Symbol sync : [ 0 10ms ] : STATE_SYMBOL_SYNC set
* Bit sync : [ 0 20ms ] : STATE_BIT_SYNC set
* String sync : [ 0 2s ] : STATE_GLO_STRING_SYNC set
* Time of day decoded : [ 0 1day ] : STATE_GLO_TOD_DECODED set
* Time of day known : [ 0 1day ] : STATE_GLO_TOD_KNOWN set
*
* Note: Time of day known refers to the case where it is possibly not
* decoded over the air but has been determined from other sources. If
* Time of day decoded is set then Time of day known must also be set.
*
* For Beidou, this is the received Beidou time of week,
* at the measurement time in nanoseconds.
*
* Given the highest sync state that can be achieved, per each satellite,
* valid range for this field can be:
* Searching : [ 0 ] : STATE_UNKNOWN set.
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK set.
* Bit sync (D2) : [ 0 2ms ] : STATE_BDS_D2_BIT_SYNC set.
* Bit sync (D1) : [ 0 20ms ] : STATE_BIT_SYNC set.
* Subframe (D2) : [ 0 0.6s ] : STATE_BDS_D2_SUBFRAME_SYNC set.
* Subframe (D1) : [ 0 6s ] : STATE_SUBFRAME_SYNC set.
* Time of week decoded : [ 0 1week ] : STATE_TOW_DECODED set.
* Time of week known : [ 0 1week ] : STATE_TOW_KNOWN set
*
* Note: TOW Known refers to the case where TOW is possibly not decoded
* over the air but has been determined from other sources. If TOW
* decoded is set then TOW Known must also be set.
*
* For Galileo, this is the received Galileo time of week,
* at the measurement time in nanoseconds.
*
* E1BC code lock : [ 0 4ms ] : STATE_GAL_E1BC_CODE_LOCK set.
* E1C 2nd code lock : [ 0 100ms] : STATE_GAL_E1C_2ND_CODE_LOCK set.
* E1B page : [ 0 2s ] : STATE_GAL_E1B_PAGE_SYNC set.
* Time of week decoded : [ 0 1week] : STATE_TOW_DECODED is set.
* Time of week known : [ 0 1week] : STATE_TOW_KNOWN set
*
* Note: TOW Known refers to the case where TOW is possibly not decoded
* over the air but has been determined from other sources. If TOW
* decoded is set then TOW Known must also be set.
*
* For SBAS, this is received SBAS time, at the measurement time in
* nanoseconds.
*
* Given the highest sync state that can be achieved, per each satellite,
* valid range for this field can be:
* Searching : [ 0 ] : STATE_UNKNOWN
* C/A code lock: [ 0 1ms ] : STATE_CODE_LOCK is set
* Symbol sync : [ 0 2ms ] : STATE_SYMBOL_SYNC is set
* Message : [ 0 1s ] : STATE_SBAS_SYNC is set
*/
long receivedSvTimeInNs;
/**
* 1-Sigma uncertainty of the Received GNSS Time-of-Week in nanoseconds.
*
* This value must be populated if 'state' != STATE_UNKNOWN.
*/
long receivedSvTimeUncertaintyInNs;
/**
* Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
* It contains the measured C/N0 value for the signal at the antenna port.
*
* If a signal has separate components (e.g. Pilot and Data channels) and
* the receiver only processes one of the components, then the reported
* antennaCN0DbHz reflects only the component that is processed.
*
* This value is mandatory.
*/
double antennaCN0DbHz;
/**
* Baseband Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. It contains the
* measured C/N0 value for the signal measured at the baseband.
*
* This is typically a few dB weaker than the value estimated for C/N0 at the antenna port,
* which is reported in cN0DbHz.
*
* If a signal has separate components (e.g. Pilot and Data channels) and the receiver only
* processes one of the components, then the reported basebandCN0DbHz reflects only the
* component that is processed.
*
* This value is mandatory.
*/
double basebandCN0DbHz;
/**
* Pseudorange rate at the timestamp in m/s. The correction of a given
* Pseudorange Rate value includes corrections for receiver and satellite
* clock frequency errors. Ensure that this field is independent (see
* comment at top of GnssMeasurement struct.)
*
* It is mandatory to provide the 'uncorrected' 'pseudorange rate', and
* provide GnssClock's 'drift' field as well. When providing the
* uncorrected pseudorange rate, do not apply the corrections described above.)
*
* The value includes the 'pseudorange rate uncertainty' in it.
* A positive 'uncorrected' value indicates that the SV is moving away from
* the receiver.
*
* The sign of the 'uncorrected' 'pseudorange rate' and its relation to the
* sign of 'doppler shift' is given by the equation:
* pseudorange rate = -k * doppler shift (where k is a constant)
*
* This must be the most accurate pseudorange rate available, based on
* fresh signal measurements from this channel.
*
* It is mandatory that this value be provided at typical carrier phase PRR
* quality (few cm/sec per second of uncertainty, or better) - when signals
* are sufficiently strong & stable, e.g. signals from a GNSS simulator at >=
* 35 dB-Hz.
*/
double pseudorangeRateMps;
/**
* 1-Sigma uncertainty of the pseudorangeRateMps.
* The uncertainty is represented as an absolute (single sided) value.
*
* This value is mandatory.
*/
double pseudorangeRateUncertaintyMps;
/**
* Flags indicating the Accumulated Delta Range's states.
*
* See the table below for a detailed interpretation of each state.
*
* +---------------------+-------------------+-----------------------------+
* | ADR_STATE | Time of relevance | Interpretation |
* +---------------------+-------------------+-----------------------------+
* | UNKNOWN | ADR(t) | No valid carrier phase |
* | | | information is available |
* | | | at time t. |
* +---------------------+-------------------+-----------------------------+
* | VALID | ADR(t) | Valid carrier phase |
* | | | information is available |
* | | | at time t. This indicates |
* | | | that this measurement can |
* | | | be used as a reference for |
* | | | future measurements. |
* | | | However, to compare it to |
* | | | previous measurements to |
* | | | compute delta range, |
* | | | other bits should be |
* | | | checked. Specifically, it |
* | | | can be used for delta range |
* | | | computation if it is valid |
* | | | and has no reset or cycle |
* | | | slip at this epoch i.e. |
* | | | if VALID_BIT == 1 && |
* | | | CYCLE_SLIP_BIT == 0 && |
* | | | RESET_BIT == 0. |
* +---------------------+-------------------+-----------------------------+
* | RESET | ADR(t) - ADR(t-1) | Carrier phase accumulation |
* | | | has been restarted between |
* | | | current time t and previous |
* | | | time t-1. This indicates |
* | | | that this measurement can |
* | | | be used as a reference for |
* | | | future measurements, but it |
* | | | should not be compared to |
* | | | previous measurements to |
* | | | compute delta range. |
* +---------------------+-------------------+-----------------------------+
* | CYCLE_SLIP | ADR(t) - ADR(t-1) | Cycle slip(s) have been |
* | | | detected between the |
* | | | current time t and previous |
* | | | time t-1. This indicates |
* | | | that this measurement can |
* | | | be used as a reference for |
* | | | future measurements. |
* | | | Clients can use a |
* | | | measurement with a cycle |
* | | | slip to compute delta range |
* | | | against previous |
* | | | measurements at their own |
* | | | risk. |
* +---------------------+-------------------+-----------------------------+
* | HALF_CYCLE_RESOLVED | ADR(t) | Half cycle ambiguity is |
* | | | resolved at time t. |
* +---------------------+-------------------+-----------------------------+
*/
const int ADR_STATE_UNKNOWN = 0;
const int ADR_STATE_VALID = 1 << 0;
const int ADR_STATE_RESET = 1 << 1;
const int ADR_STATE_CYCLE_SLIP = 1 << 2;
const int ADR_STATE_HALF_CYCLE_RESOLVED = 1 << 3;
/**
* A bitfield of flags indicating the accumulated delta range's state. It indicates whether ADR
* is reset or there is a cycle slip(indicating loss of lock).
*
* The bit masks are defined in constants with prefix ADR_STATE_.
*
* This value is mandatory.
*/
int accumulatedDeltaRangeState;
/**
* Accumulated delta range since the last channel reset in meters.
* A positive value indicates that the SV is moving away from the receiver.
*
* The sign of the 'accumulated delta range' and its relation to the sign of
* 'carrier phase' is given by the equation:
* accumulated delta range = -k * carrier phase (where k is a constant)
*
* This value must be populated if 'accumulated delta range state' !=
* ADR_STATE_UNKNOWN.
* However, it is expected that the data is only accurate when:
* 'accumulated delta range state' == ADR_STATE_VALID.
*
* The alignment of the phase measurement will not be adjusted by the receiver so the in-phase
* and quadrature phase components will have a quarter cycle offset as they do when transmitted
* from the satellites. If the measurement is from a combination of the in-phase and quadrature
* phase components, then the alignment of the phase measurement will be aligned to the in-phase
* component.
*/
double accumulatedDeltaRangeM;
/**
* 1-Sigma uncertainty of the accumulated delta range in meters.
* This value must be populated if 'accumulated delta range state' !=
* ADR_STATE_UNKNOWN.
*/
double accumulatedDeltaRangeUncertaintyM;
/**
* Carrier frequency of the signal tracked, for example it can be the
* GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 =
* 1176.45 MHz, varying GLO channels, etc. If the field is not set, it
* is the primary common use central frequency, e.g. L1 = 1575.45 MHz
* for GPS.
*
* For an L1, L5 receiver tracking a satellite on L1 and L5 at the same
* time, two raw measurement structs must be reported for this same
* satellite, in one of the measurement structs, all the values related
* to L1 must be filled, and in the other all of the values related to
* L5 must be filled.
*
* If the data is available, gnssMeasurementFlags must contain
* HAS_CARRIER_FREQUENCY.
*/
float carrierFrequencyHz;
/**
* The number of full carrier cycles between the satellite and the
* receiver. The reference frequency is given by the field
* 'carrierFrequencyHz'. Indications of possible cycle slips and
* resets in the accumulation of this value can be inferred from the
* accumulatedDeltaRangeState flags.
*
* If the data is available, gnssMeasurementFlags must contain
* HAS_CARRIER_CYCLES.
*/
long carrierCycles;
/**
* The RF phase detected by the receiver, in the range [0.0, 1.0].
* This is usually the fractional part of the complete carrier phase
* measurement.
*
* The reference frequency is given by the field 'carrierFrequencyHz'.
* The value contains the 'carrier-phase uncertainty' in it.
*
* If the data is available, gnssMeasurementFlags must contain
* HAS_CARRIER_PHASE.
*/
double carrierPhase;
/**
* 1-Sigma uncertainty of the carrier-phase.
* If the data is available, gnssMeasurementFlags must contain
* HAS_CARRIER_PHASE_UNCERTAINTY.
*/
double carrierPhaseUncertainty;
/**
* An enumeration that indicates the 'multipath' state of the event.
*
* The multipath Indicator is intended to report the presence of overlapping
* signals that manifest as distorted correlation peaks.
*
* - if there is a distorted correlation peak shape, report that multipath
* is MULTIPATH_INDICATOR_PRESENT.
* - if there is no distorted correlation peak shape, report
* MULTIPATH_INDICATOR_NOT_PRESENT
* - if signals are too weak to discern this information, report
* MULTIPATH_INDICATOR_UNKNOWN
*
* Example: when doing the standardized overlapping Multipath Performance
* test (3GPP TS 34.171) the Multipath indicator must report
* MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
* contain multipath, and MULTIPATH_INDICATOR_NOT_PRESENT for those
* signals that are tracked and do not contain multipath.
*/
GnssMultipathIndicator multipathIndicator;
/**
* Signal-to-noise ratio at correlator output in dB.
* If the data is available, GnssMeasurementFlags must contain HAS_SNR.
* This is the power ratio of the "correlation peak height above the
* observed noise floor" to "the noise RMS".
*/
double snrDb;
/**
* Automatic gain control (AGC) level. AGC acts as a variable gain
* amplifier adjusting the power of the incoming signal. The AGC level
* may be used to indicate potential interference. When AGC is at a
* nominal level, this value must be set as 0. Higher gain (and/or lower
* input power) must be output as a positive number. Hence in cases of
* strong jamming, in the band of this signal, this value must go more
* negative.
*
* Note: Different hardware designs (e.g. antenna, pre-amplification, or
* other RF HW components) may also affect the typical output of this
* value on any given hardware design in an open sky test - the
* important aspect of this output is that changes in this value are
* indicative of changes on input signal power in the frequency band for
* this measurement.
*/
double agcLevelDb;
/**
* The full inter-signal bias (ISB) in nanoseconds.
*
* This value is the sum of the estimated receiver-side and the space-segment-side inter-system
* bias, inter-frequency bias and inter-code bias, including
*
* - Receiver inter-constellation bias (with respect to the constellation in
* GnssClock.referenceSignalTypeForIsb)
* - Receiver inter-frequency bias (with respect to the carrier frequency in
* GnssClock.referenceSignalTypeForIsb)
* - Receiver inter-code bias (with respect to the code type in
* GnssClock.referenceSignalTypeForIsb)
* - Master clock bias (e.g., GPS-GAL Time Offset (GGTO), GPS-UTC Time Offset (TauGps), BDS-GLO
* Time Offset (BGTO)) (with respect to the constellation in
* GnssClock.referenceSignalTypeForIsb)
* - Group delay (e.g., Total Group Delay (TGD))
* - Satellite inter-frequency bias (GLO only) (with respect to the carrier frequency in
* GnssClock.referenceSignalTypeForIsb)
* - Satellite inter-code bias (e.g., Differential Code Bias (DCB)) (with respect to the code
* type in GnssClock.referenceSignalTypeForIsb)
*
* If a component of the above is already compensated in the provided
* GnssMeasurement.receivedSvTimeInNs, then it must not be included in the reported full ISB.
*
* The value does not include the inter-frequency Ionospheric bias.
*
* The full ISB of GnssClock.referenceSignalTypeForIsb is defined to be 0.0 nanoseconds.
*/
double fullInterSignalBiasNs;
/**
* 1-sigma uncertainty associated with the full inter-signal bias in nanoseconds.
*/
double fullInterSignalBiasUncertaintyNs;
/**
* The satellite inter-signal bias in nanoseconds.
*
* This value is the sum of the space-segment-side inter-system bias, inter-frequency bias
* and inter-code bias, including
*
* - Master clock bias (e.g., GPS-GAL Time Offset (GGTO), GPS-UTC Time Offset (TauGps), BDS-GLO
* Time Offset (BGTO)) (with respect to the constellation in
* GnssClock.referenceSignalTypeForIsb)
* - Group delay (e.g., Total Group Delay (TGD))
* - Satellite inter-frequency bias (GLO only) (with respect to the carrier frequency in
* GnssClock.referenceSignalTypeForIsb)
* - Satellite inter-code bias (e.g., Differential Code Bias (DCB)) (with respect to the code
* type in GnssClock.referenceSignalTypeForIsb)
*
* The satellite ISB of GnssClock.referenceSignalTypeForIsb is defined to be 0.0 nanoseconds.
*/
double satelliteInterSignalBiasNs;
/**
* 1-sigma uncertainty associated with the satellite inter-signal bias in nanoseconds.
*/
double satelliteInterSignalBiasUncertaintyNs;
}

View file

@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
/**
* Enumeration of available values for the GNSS Measurement's multipath
* indicator.
*/
@VintfStability
@Backing(type="int")
enum GnssMultipathIndicator {
/** The indicator is not available or unknown. */
UNKNOWN = 0,
/** The measurement is indicated to be affected by multipath. */
PRESENT = 1,
/** The measurement is indicated to be not affected by multipath. */
NOT_PRESENT = 2,
}

View file

@ -0,0 +1,149 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
import android.hardware.gnss.GnssConstellationType;
/**
* Represents a GNSS signal type.
*/
@VintfStability
parcelable GnssSignalType {
/**
* Constellation type of the SV that transmits the signal.
*/
GnssConstellationType constellation;
/**
* Carrier frequency of the signal tracked, for example it can be the
* GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 =
* 1176.45 MHz, varying GLO channels, etc. If the field is not set, it
* is the primary common use central frequency, e.g. L1 = 1575.45 MHz
* for GPS.
*
* For an L1, L5 receiver tracking a satellite on L1 and L5 at the same
* time, two raw measurement structs must be reported for this same
* satellite, in one of the measurement structs, all the values related
* to L1 must be filled, and in the other all of the values related to
* L5 must be filled.
*/
double carrierFrequencyHz;
/**
* GNSS signal code type "A" representing GALILEO E1A, GALILEO E6A, IRNSS L5A, IRNSS SA.
*/
const String CODE_TYPE_A = "A";
/**
* GNSS signal code type "B" representing GALILEO E1B, GALILEO E6B, IRNSS L5B, IRNSS SB.
*/
const String CODE_TYPE_B = "B";
/**
* GNSS signal code type "C" representing GPS L1 C/A, GPS L2 C/A, GLONASS G1 C/A,
* GLONASS G2 C/A, GALILEO E1C, GALILEO E6C, SBAS L1 C/A, QZSS L1 C/A, IRNSS L5C.
*/
const String CODE_TYPE_C = "C";
/**
* GNSS signal code type "D" representing BDS B1C D.
*/
const String CODE_TYPE_D = "D";
/**
* GNSS signal code type "I" representing GPS L5 I, GLONASS G3 I, GALILEO E5a I, GALILEO E5b I,
* GALILEO E5a+b I, SBAS L5 I, QZSS L5 I, BDS B1 I, BDS B2 I, BDS B3 I.
*/
const String CODE_TYPE_I = "I";
/**
* GNSS signal code type "L" representing GPS L1C (P), GPS L2C (L), QZSS L1C (P), QZSS L2C (L),
* LEX(6) L.
*/
const String CODE_TYPE_L = "L";
/**
* GNSS signal code type "M" representing GPS L1M, GPS L2M.
*/
const String CODE_TYPE_M = "M";
/**
* GNSS signal code type "N" representing GPS L1 codeless, GPS L2 codeless.
*/
const String CODE_TYPE_N = "N";
/**
* GNSS signal code type "P" representing GPS L1P, GPS L2P, GLONASS G1P, GLONASS G2P, BDS B1C P.
*/
const String CODE_TYPE_P = "P";
/**
* GNSS signal code type "Q" representing GPS L5 Q, GLONASS G3 Q, GALILEO E5a Q, GALILEO E5b Q,
* GALILEO E5a+b Q, SBAS L5 Q, QZSS L5 Q, BDS B1 Q, BDS B2 Q, BDS B3 Q.
*/
const String CODE_TYPE_Q = "Q";
/**
* GNSS signal code type "S" represents GPS L1C (D), GPS L2C (M), QZSS L1C (D), QZSS L2C (M),
* LEX(6) S.
*/
const String CODE_TYPE_S = "S";
/**
* GNSS signal code type "W" representing GPS L1 Z-tracking, GPS L2 Z-tracking.
*/
const String CODE_TYPE_W = "W";
/**
* GNSS signal code type "X" representing GPS L1C (D+P), GPS L2C (M+L), GPS L5 (I+Q),
* GLONASS G3 (I+Q), GALILEO E1 (B+C), GALILEO E5a (I+Q), GALILEO E5b (I+Q), GALILEO E5a+b(I+Q),
* GALILEO E6 (B+C), SBAS L5 (I+Q), QZSS L1C (D+P), QZSS L2C (M+L), QZSS L5 (I+Q),
* LEX(6) (S+L), BDS B1 (I+Q), BDS B1C (D+P), BDS B2 (I+Q), BDS B3 (I+Q), IRNSS L5 (B+C).
*/
const String CODE_TYPE_X = "X";
/**
* GNSS signal code type "Y" representing GPS L1Y, GPS L2Y.
*/
const String CODE_TYPE_Y = "Y";
/**
* GNSS signal code type "Z" representing GALILEO E1 (A+B+C), GALILEO E6 (A+B+C), QZSS L1-SAIF.
*/
const String CODE_TYPE_Z = "Z";
/**
* GNSS signal code type "UNKNOWN" representing the GNSS Measurement's code type is unknown.
*/
const String CODE_TYPE_UNKNOWN = "UNKNOWN";
/**
* The type of code that is currently being tracked in the GNSS signal.
*
* For high precision applications the type of code being tracked needs to be considered
* in-order to properly apply code specific corrections to the pseudorange measurements.
*
* The value is one of the constant Strings with prefix CODE_TYPE_ defined in this parcelable.
*
* This is used to specify the observation descriptor defined in GNSS Observation Data File
* Header Section Description in the RINEX standard (Version 3.XX). In RINEX Version 3.03,
* in Appendix Table A2 Attributes are listed as uppercase letters (for instance, "A" for
* "A channel"). In the future, if for instance a code "G" was added in the official RINEX
* standard, "G" could be specified here.
*/
String codeType;
}

View file

@ -17,9 +17,10 @@
package android.hardware.gnss;
import android.hardware.gnss.IGnssCallback;
import android.hardware.gnss.IGnssConfiguration;
import android.hardware.gnss.IGnssMeasurementInterface;
import android.hardware.gnss.IGnssPowerIndication;
import android.hardware.gnss.IGnssPsds;
import android.hardware.gnss.IGnssConfiguration;
/**
* Represents the standard GNSS (Global Navigation Satellite System) interface.
@ -33,14 +34,6 @@ interface IGnss {
*/
const int ERROR_INVALID_ARGUMENT = 1;
/** Bit mask indicating a valid timestampNs is stored in the ElapsedRealtime parcelable. */
const int ELAPSED_REALTIME_HAS_TIMESTAMP_NS = 1 << 0;
/**
* Bit mask indicating a valid timeUncertaintyNs is stored in the ElapsedRealtime parcelable.
*/
const int ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS = 1 << 1;
/**
* Opens the interface and provides the callback routines to the implementation of this
* interface.
@ -74,6 +67,8 @@ interface IGnss {
/**
* This method returns the IGnssPsds interface.
*
* This method must return non-null.
*
* @return Handle to the IGnssPsds interface.
*/
IGnssPsds getExtensionPsds();
@ -81,13 +76,26 @@ interface IGnss {
/**
* This method returns the IGnssConfiguration interface.
*
* This method must return non-null.
*
* @return Handle to the IGnssConfiguration interface.
*/
IGnssConfiguration getExtensionGnssConfiguration();
/**
* This methods returns the IGnssMeasurementInterface interface.
*
* This method must return non-null.
*
* @return Handle to the IGnssMeasurementInterface interface.
*/
IGnssMeasurementInterface getExtensionGnssMeasurement();
/**
* This method returns the IGnssPowerIndication interface.
*
* This method must return non-null.
*
* @return Handle to the IGnssPowerIndication interface.
*/
IGnssPowerIndication getExtensionGnssPowerIndication();

View file

@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
import android.hardware.gnss.GnssData;
/**
* The callback interface to report GNSS Measurement from the HAL.
*/
@VintfStability
interface IGnssMeasurementCallback {
/**
* Callback for the hal to pass a GnssData structure back to the client.
*
* @param data Contains a reading of GNSS measurements.
*/
void gnssMeasurementCb(in GnssData data);
}

View file

@ -0,0 +1,55 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
package android.hardware.gnss;
import android.hardware.gnss.IGnssMeasurementCallback;
/**
* Extended interface for GNSS Measurement support.
*/
@VintfStability
interface IGnssMeasurementInterface {
/**
* Initializes the interface and registers the callback routines with the HAL. After a
* successful call to 'setCallback' the HAL must begin to provide updates at an average
* output rate of 1Hz (occasional intra-measurement time offsets in the range from 0-2000msec
* can be tolerated.)
*
* @param callback Handle to GnssMeasurement callback interface.
* @param enableFullTracking If true, GNSS chipset must switch off duty cycling. In such mode
* no clock discontinuities are expected and, when supported, carrier phase should be
* continuous in good signal conditions. All non-blocklisted, healthy constellations,
* satellites and frequency bands that the chipset supports must be reported in this mode.
* The GNSS chipset is allowed to consume more power in this mode. If false, API must
* optimize power via duty cycling, constellations and frequency limits, etc.
*
* @return initRet Returns SUCCESS if successful. Returns ERROR_ALREADY_INIT if a callback has
* already been registered without a corresponding call to 'close'. Returns ERROR_GENERIC
* for any other error. The HAL must not generate any other updates upon returning this
* error code.
*/
void setCallback(in IGnssMeasurementCallback callback, in boolean enableFullTracking);
/**
* Stops updates from the HAL, and unregisters the callback routines. After a call to close(),
* the previously registered callbacks must be considered invalid by the HAL.
*
* If close() is invoked without a previous setCallback, this function must perform
* no work.
*/
void close();
}

View file

@ -50,6 +50,7 @@ cc_binary {
"GnssPowerIndication.cpp",
"GnssPsds.cpp",
"GnssConfiguration.cpp",
"GnssMeasurementInterface.cpp",
"service.cpp",
],
static_libs: [

View file

@ -19,6 +19,7 @@
#include "Gnss.h"
#include <log/log.h>
#include "GnssConfiguration.h"
#include "GnssMeasurementInterface.h"
#include "GnssPowerIndication.h"
#include "GnssPsds.h"
@ -74,4 +75,12 @@ ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement(
std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) {
ALOGD("Gnss::getExtensionGnssMeasurement");
*iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>();
return ndk::ScopedAStatus::ok();
}
} // namespace aidl::android::hardware::gnss

View file

@ -18,6 +18,7 @@
#include <aidl/android/hardware/gnss/BnGnss.h>
#include <aidl/android/hardware/gnss/BnGnssConfiguration.h>
#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
#include <aidl/android/hardware/gnss/BnGnssPowerIndication.h>
#include <aidl/android/hardware/gnss/BnGnssPsds.h>
#include "GnssConfiguration.h"
@ -33,6 +34,8 @@ class Gnss : public BnGnss {
std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) override;
ndk::ScopedAStatus getExtensionGnssPowerIndication(
std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) override;
ndk::ScopedAStatus getExtensionGnssMeasurement(
std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) override;
std::shared_ptr<GnssConfiguration> mGnssConfiguration;

View file

@ -24,8 +24,6 @@
namespace aidl::android::hardware::gnss {
using android::hardware::gnss::GnssConstellationType;
struct BlocklistedSourceHash {
inline int operator()(const BlocklistedSource& source) const {
return int(source.constellation) * 1000 + int(source.svid);
@ -42,7 +40,8 @@ using GnssSvInfoV2_1 = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInf
using std::vector;
using BlocklistedSourceSet =
std::unordered_set<BlocklistedSource, BlocklistedSourceHash, BlocklistedSourceEqual>;
using BlocklistedConstellationSet = std::unordered_set<GnssConstellationType>;
using BlocklistedConstellationSet =
std::unordered_set<android::hardware::gnss::GnssConstellationType>;
struct GnssConfiguration : public BnGnssConfiguration {
public:

View file

@ -17,11 +17,10 @@
#define LOG_TAG "GnssHidlHal"
#include "GnssHidlHal.h"
//#include <android/hardware/gnss/1.0/IGnssCallback.h>
namespace aidl::android::hardware::gnss {
namespace V1_0 = ::android::hardware::gnss::V1_0;
using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo;
GnssHidlHal::GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl) : mGnssAidl(gnssAidl) {
Gnss* iGnss = mGnssAidl.get();
@ -45,8 +44,8 @@ hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1(
if (mGnssConfigurationAidl->isBlocklistedV2_1(gnssSvInfoList[i])) {
ALOGD("Blocklisted constellation: %d, svid: %d",
(int)gnssSvInfoList[i].v2_0.constellation, gnssSvInfoList[i].v2_0.v1_0.svid);
gnssSvInfoList[i].v2_0.v1_0.svFlag &=
~static_cast<uint8_t>(V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX);
gnssSvInfoList[i].v2_0.v1_0.svFlag &= ~static_cast<uint8_t>(
::android::hardware::gnss::V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX);
}
}
return gnssSvInfoList;

View file

@ -22,16 +22,16 @@
namespace aidl::android::hardware::gnss {
using ::android::hardware::gnss::common::implementation::GnssTemplate;
using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo;
class GnssHidlHal : public GnssTemplate<::android::hardware::gnss::V2_1::IGnss> {
class GnssHidlHal : public ::android::hardware::gnss::common::implementation::GnssTemplate<
::android::hardware::gnss::V2_1::IGnss> {
public:
GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl);
private:
hidl_vec<GnssSvInfo> filterBlocklistedSatellitesV2_1(
hidl_vec<GnssSvInfo> gnssSvInfoList) override;
hidl_vec<::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo>
filterBlocklistedSatellitesV2_1(
hidl_vec<::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList)
override;
std::shared_ptr<Gnss> mGnssAidl;
std::shared_ptr<GnssConfiguration> mGnssConfigurationAidl;

View file

@ -0,0 +1,90 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
#define LOG_TAG "GnssMeasIfaceAidl"
#include "GnssMeasurementInterface.h"
#include <aidl/android/hardware/gnss/BnGnss.h>
#include <log/log.h>
#include "Utils.h"
namespace aidl::android::hardware::gnss {
using Utils = ::android::hardware::gnss::common::Utils;
std::shared_ptr<IGnssMeasurementCallback> GnssMeasurementInterface::sCallback = nullptr;
GnssMeasurementInterface::GnssMeasurementInterface() : mMinIntervalMillis(1000) {}
GnssMeasurementInterface::~GnssMeasurementInterface() {
stop();
}
ndk::ScopedAStatus GnssMeasurementInterface::setCallback(
const std::shared_ptr<IGnssMeasurementCallback>& callback, const bool enableFullTracking) {
ALOGD("setCallback: enableFullTracking: %d", (int)enableFullTracking);
std::unique_lock<std::mutex> lock(mMutex);
sCallback = callback;
if (mIsActive) {
ALOGW("GnssMeasurement callback already set. Resetting the callback...");
stop();
}
start();
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus GnssMeasurementInterface::close() {
ALOGD("close");
stop();
std::unique_lock<std::mutex> lock(mMutex);
sCallback = nullptr;
return ndk::ScopedAStatus::ok();
}
void GnssMeasurementInterface::start() {
ALOGD("start");
mIsActive = true;
mThread = std::thread([this]() {
while (mIsActive == true) {
auto measurement = Utils::getMockMeasurement();
this->reportMeasurement(measurement);
std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMillis));
}
});
}
void GnssMeasurementInterface::stop() {
ALOGD("stop");
mIsActive = false;
if (mThread.joinable()) {
mThread.join();
}
}
void GnssMeasurementInterface::reportMeasurement(const GnssData& data) {
ALOGD("reportMeasurement()");
std::unique_lock<std::mutex> lock(mMutex);
if (sCallback == nullptr) {
ALOGE("%s: GnssMeasurement::sCallback is null.", __func__);
return;
}
sCallback->gnssMeasurementCb(data);
}
} // namespace aidl::android::hardware::gnss

View file

@ -0,0 +1,51 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
#pragma once
#include <aidl/android/hardware/gnss/BnGnssMeasurementCallback.h>
#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
#include <atomic>
#include <mutex>
#include <thread>
namespace aidl::android::hardware::gnss {
struct GnssMeasurementInterface : public BnGnssMeasurementInterface {
public:
GnssMeasurementInterface();
~GnssMeasurementInterface();
ndk::ScopedAStatus setCallback(const std::shared_ptr<IGnssMeasurementCallback>& callback,
const bool enableFullTracking) override;
ndk::ScopedAStatus close() override;
private:
void start();
void stop();
void reportMeasurement(const GnssData&);
std::atomic<long> mMinIntervalMillis;
std::atomic<bool> mIsActive;
std::thread mThread;
// Guarded by mMutex
static std::shared_ptr<IGnssMeasurementCallback> sCallback;
// Synchronization lock for sCallback
mutable std::mutex mMutex;
};
} // namespace aidl::android::hardware::gnss

View file

@ -19,6 +19,7 @@
#include "GnssPowerIndication.h"
#include <aidl/android/hardware/gnss/BnGnss.h>
#include <log/log.h>
#include <utils/SystemClock.h>
namespace aidl::android::hardware::gnss {
@ -43,10 +44,9 @@ ndk::ScopedAStatus GnssPowerIndication::requestGnssPowerStats() {
std::unique_lock<std::mutex> lock(mMutex);
ElapsedRealtime elapsedRealtime = {
.flags = IGnss::ELAPSED_REALTIME_HAS_TIMESTAMP_NS |
IGnss::ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS,
.timestampNs = (long)1323542,
.timeUncertaintyNs = (long)1000,
.flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
.timestampNs = ::android::elapsedRealtimeNano(),
.timeUncertaintyNs = 1000,
};
GnssPowerStats gnssPowerStats = {
.elapsedRealtime = elapsedRealtime,

View file

@ -22,6 +22,7 @@ cc_test {
"gnss_hal_test.cpp",
"gnss_hal_test_cases.cpp",
"GnssCallbackAidl.cpp",
"GnssMeasurementCallbackAidl.cpp",
"GnssPowerIndicationCallback.cpp",
"VtsHalGnssTargetTest.cpp",
],

View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
#define LOG_TAG "GnssMeasurementCallbackAidl"
#include "GnssMeasurementCallbackAidl.h"
#include <inttypes.h>
#include <log/log.h>
using android::hardware::gnss::GnssData;
android::binder::Status GnssMeasurementCallbackAidl::gnssMeasurementCb(const GnssData& gnssData) {
ALOGI("gnssMeasurementCb");
ALOGI("elapsedRealtime: flags = %d, timestampNs: %" PRId64 ", timeUncertaintyNs=%lf",
gnssData.elapsedRealtime.flags, gnssData.elapsedRealtime.timestampNs,
gnssData.elapsedRealtime.timeUncertaintyNs);
for (const auto& measurement : gnssData.measurements) {
ALOGI("measurement.receivedSvTimeInNs=%" PRId64, measurement.receivedSvTimeInNs);
}
gnss_data_cbq_.store(gnssData);
return android::binder::Status::ok();
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 2020 The Android Open Source 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.
*/
#pragma once
#include <android/hardware/gnss/BnGnssMeasurementCallback.h>
#include "GnssCallbackEventQueue.h"
/** Implementation for IGnssMeasurementCallback. */
class GnssMeasurementCallbackAidl : public android::hardware::gnss::BnGnssMeasurementCallback {
public:
GnssMeasurementCallbackAidl() : gnss_data_cbq_("gnss_data") {}
~GnssMeasurementCallbackAidl() {}
android::binder::Status gnssMeasurementCb(
const android::hardware::gnss::GnssData& gnssData) override;
android::hardware::gnss::common::GnssCallbackEventQueue<android::hardware::gnss::GnssData>
gnss_data_cbq_;
};

View file

@ -25,7 +25,6 @@ class GnssPowerIndicationCallback : public android::hardware::gnss::BnGnssPowerI
public:
GnssPowerIndicationCallback()
: capabilities_cbq_("capabilities"),
other_mode_names_cbq_("other_mode_names"),
gnss_power_stats_cbq_("gnss_power_stats") {}
~GnssPowerIndicationCallback() {}
@ -35,9 +34,6 @@ class GnssPowerIndicationCallback : public android::hardware::gnss::BnGnssPowerI
android::hardware::gnss::common::GnssCallbackEventQueue<int> capabilities_cbq_;
int last_capabilities_;
android::hardware::gnss::common::GnssCallbackEventQueue<std::vector<std::string>>
other_mode_names_cbq_;
std::vector<std::string> last_other_mode_names_;
android::hardware::gnss::common::GnssCallbackEventQueue<android::hardware::gnss::GnssPowerStats>
gnss_power_stats_cbq_;
android::hardware::gnss::GnssPowerStats last_gnss_power_stats_;

View file

@ -36,7 +36,7 @@ using android::hardware::gnss::BlocklistedSource;
using android::hardware::gnss::IGnssConfiguration;
// The main test class for GNSS HAL.
class GnssHalTest : public GnssHalTestTemplate<IGnss_V2_1> {
class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<IGnss_V2_1> {
public:
GnssHalTest(){};
~GnssHalTest(){};

View file

@ -16,19 +16,30 @@
#define LOG_TAG "GnssHalTestCases"
#include <android/hardware/gnss/IGnss.h>
#include <android/hardware/gnss/IGnssMeasurementCallback.h>
#include <android/hardware/gnss/IGnssMeasurementInterface.h>
#include <android/hardware/gnss/IGnssPowerIndication.h>
#include <android/hardware/gnss/IGnssPsds.h>
#include "GnssMeasurementCallbackAidl.h"
#include "GnssPowerIndicationCallback.h"
#include "gnss_hal_test.h"
using android::sp;
using android::hardware::gnss::BlocklistedSource;
using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
using android::hardware::gnss::ElapsedRealtime;
using android::hardware::gnss::GnssClock;
using android::hardware::gnss::GnssMeasurement;
using android::hardware::gnss::IGnss;
using android::hardware::gnss::IGnssConfiguration;
using android::hardware::gnss::IGnssMeasurementCallback;
using android::hardware::gnss::IGnssMeasurementInterface;
using android::hardware::gnss::IGnssPowerIndication;
using android::hardware::gnss::IGnssPsds;
using android::hardware::gnss::PsdsType;
using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
/*
* SetupTeardownCreateCleanup:
* Requests the gnss HAL then calls cleanup
@ -52,6 +63,62 @@ TEST_P(GnssHalTest, TestPsdsExtension) {
ASSERT_FALSE(status.isOk());
}
/*
* TestGnssMeasurementExtension:
* 1. Gets the GnssMeasurementExtension and verifies that it returns a non-null extension.
* 2. Sets a GnssMeasurementCallback, waits for a measurement, and verifies fields are valid.
*/
TEST_P(GnssHalTest, TestGnssMeasurementExtension) {
const int kFirstGnssMeasurementTimeoutSeconds = 10;
sp<IGnssMeasurementInterface> iGnssMeasurement;
auto status = aidl_gnss_hal_->getExtensionGnssMeasurement(&iGnssMeasurement);
ASSERT_TRUE(status.isOk());
ASSERT_TRUE(iGnssMeasurement != nullptr);
auto callback = sp<GnssMeasurementCallbackAidl>::make();
status = iGnssMeasurement->setCallback(callback, /* enableFullTracking= */ true);
ASSERT_TRUE(status.isOk());
android::hardware::gnss::GnssData lastMeasurement;
ASSERT_TRUE(callback->gnss_data_cbq_.retrieve(lastMeasurement,
kFirstGnssMeasurementTimeoutSeconds));
EXPECT_EQ(callback->gnss_data_cbq_.calledCount(), 1);
ASSERT_TRUE(lastMeasurement.measurements.size() > 0);
// Validity check GnssData fields
ASSERT_TRUE(
lastMeasurement.elapsedRealtime.flags >= 0 &&
lastMeasurement.elapsedRealtime.flags <=
(ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS));
if (lastMeasurement.elapsedRealtime.flags & ElapsedRealtime::HAS_TIMESTAMP_NS) {
ASSERT_TRUE(lastMeasurement.elapsedRealtime.timestampNs > 0);
}
if (lastMeasurement.elapsedRealtime.flags & ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS) {
ASSERT_TRUE(lastMeasurement.elapsedRealtime.timeUncertaintyNs > 0);
}
ASSERT_TRUE(lastMeasurement.clock.gnssClockFlags >= 0 &&
lastMeasurement.clock.gnssClockFlags <=
(GnssClock::HAS_LEAP_SECOND | GnssClock::HAS_TIME_UNCERTAINTY |
GnssClock::HAS_FULL_BIAS | GnssClock::HAS_BIAS |
GnssClock::HAS_BIAS_UNCERTAINTY | GnssClock::HAS_DRIFT |
GnssClock::HAS_DRIFT_UNCERTAINTY));
for (const auto& measurement : lastMeasurement.measurements) {
ASSERT_TRUE(
measurement.flags >= 0 &&
measurement.flags <=
(GnssMeasurement::HAS_SNR | GnssMeasurement::HAS_CARRIER_FREQUENCY |
GnssMeasurement::HAS_CARRIER_CYCLES | GnssMeasurement::HAS_CARRIER_PHASE |
GnssMeasurement::HAS_CARRIER_PHASE_UNCERTAINTY |
GnssMeasurement::HAS_AUTOMATIC_GAIN_CONTROL |
GnssMeasurement::HAS_FULL_ISB | GnssMeasurement::HAS_FULL_ISB_UNCERTAINTY |
GnssMeasurement::HAS_SATELLITE_ISB |
GnssMeasurement::HAS_SATELLITE_ISB_UNCERTAINTY));
}
status = iGnssMeasurement->close();
ASSERT_TRUE(status.isOk());
}
/*
* TestGnssPowerIndication
* 1. Gets the GnssPowerIndicationExtension.

View file

@ -42,5 +42,6 @@ cc_library_static {
"android.hardware.gnss@2.1",
"android.hardware.gnss.measurement_corrections@1.1",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss-ndk_platform",
],
}

View file

@ -17,6 +17,7 @@
#include <Constants.h>
#include <MockLocation.h>
#include <Utils.h>
#include <aidl/android/hardware/gnss/BnGnss.h>
#include <utils/SystemClock.h>
namespace android {
@ -24,16 +25,28 @@ namespace hardware {
namespace gnss {
namespace common {
using IGnss = aidl::android::hardware::gnss::IGnss;
using IGnssMeasurementCallback = aidl::android::hardware::gnss::IGnssMeasurementCallback;
using GnssMeasurement = aidl::android::hardware::gnss::GnssMeasurement;
using GnssSvFlags = V1_0::IGnssCallback::GnssSvFlags;
using GnssMeasurementFlagsV1_0 = V1_0::IGnssMeasurementCallback::GnssMeasurementFlags;
using GnssMeasurementFlagsV2_1 = V2_1::IGnssMeasurementCallback::GnssMeasurementFlags;
using GnssMeasurementStateV2_0 = V2_0::IGnssMeasurementCallback::GnssMeasurementState;
using ElapsedRealtime = V2_0::ElapsedRealtime;
using ElapsedRealtime = aidl::android::hardware::gnss::ElapsedRealtime;
using ElapsedRealtimeFlags = V2_0::ElapsedRealtimeFlags;
using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
using IGnssMeasurementCallbackV2_0 = V2_0::IGnssMeasurementCallback;
using GnssSignalType = V2_1::GnssSignalType;
using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
using GnssSvInfoV1_0 = V1_0::IGnssCallback::GnssSvInfo;
using GnssSvInfoV2_0 = V2_0::IGnssCallback::GnssSvInfo;
using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
using GnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo;
using Row = V2_1::IGnssAntennaInfoCallback::Row;
using Coord = V2_1::IGnssAntennaInfoCallback::Coord;
GnssDataV2_1 Utils::getMockMeasurementV2_1() {
GnssDataV2_0 gnssDataV2_0 = Utils::getMockMeasurementV2_0();
V2_1::IGnssMeasurementCallback::GnssMeasurement gnssMeasurementV2_1 = {
@ -110,7 +123,7 @@ GnssDataV2_0 Utils::getMockMeasurementV2_0() {
.driftUncertaintyNsps = 310.64968328491528,
.hwClockDiscontinuityCount = 1};
ElapsedRealtime timestamp = {
V2_0::ElapsedRealtime timestamp = {
.flags = ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS,
.timestampNs = static_cast<uint64_t>(::android::elapsedRealtimeNano()),
@ -124,6 +137,52 @@ GnssDataV2_0 Utils::getMockMeasurementV2_0() {
return gnssData;
}
aidl::android::hardware::gnss::GnssData Utils::getMockMeasurement() {
aidl::android::hardware::gnss::GnssSignalType signalType = {
.constellation = aidl::android::hardware::gnss::GnssConstellationType::GLONASS,
.carrierFrequencyHz = 1.59975e+09,
.codeType = aidl::android::hardware::gnss::GnssSignalType::CODE_TYPE_C,
};
aidl::android::hardware::gnss::GnssMeasurement measurement = {
.flags = GnssMeasurement::HAS_CARRIER_FREQUENCY,
.svid = 6,
.signalType = signalType,
.timeOffsetNs = 0.0,
.receivedSvTimeInNs = 8195997131077,
.receivedSvTimeUncertaintyInNs = 15,
.antennaCN0DbHz = 30.0,
.pseudorangeRateMps = -484.13739013671875,
.pseudorangeRateUncertaintyMps = 1.0379999876022339,
.accumulatedDeltaRangeState = GnssMeasurement::ADR_STATE_UNKNOWN,
.accumulatedDeltaRangeM = 0.0,
.accumulatedDeltaRangeUncertaintyM = 0.0,
.multipathIndicator = aidl::android::hardware::gnss::GnssMultipathIndicator::UNKNOWN,
.state = GnssMeasurement::STATE_CODE_LOCK | GnssMeasurement::STATE_BIT_SYNC |
GnssMeasurement::STATE_SUBFRAME_SYNC | GnssMeasurement::STATE_TOW_DECODED |
GnssMeasurement::STATE_GLO_STRING_SYNC |
GnssMeasurement::STATE_GLO_TOD_DECODED};
aidl::android::hardware::gnss::GnssClock clock = {.timeNs = 2713545000000,
.fullBiasNs = -1226701900521857520,
.biasNs = 0.59689998626708984,
.biasUncertaintyNs = 47514.989972114563,
.driftNsps = -51.757811607455452,
.driftUncertaintyNsps = 310.64968328491528,
.hwClockDiscontinuityCount = 1};
ElapsedRealtime timestamp = {
.flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
.timestampNs = ::android::elapsedRealtimeNano(),
// This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
// In an actual implementation provide an estimate of the synchronization uncertainty
// or don't set the field.
.timeUncertaintyNs = 1000000};
aidl::android::hardware::gnss::GnssData gnssData = {
.measurements = {measurement}, .clock = clock, .elapsedRealtime = timestamp};
return gnssData;
}
V2_0::GnssLocation Utils::getMockLocationV2_0() {
const V2_0::ElapsedRealtime timestamp = {
.flags = V2_0::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |

View file

@ -26,11 +26,6 @@ namespace android {
namespace hardware {
namespace gnss {
namespace common {
using ::android::sp;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
constexpr char GPGA_RECORD_TAG[] = "$GPGGA";
constexpr char GPRMC_RECORD_TAG[] = "$GPRMC";

View file

@ -17,6 +17,7 @@
#ifndef android_hardware_gnss_common_default_Utils_H_
#define android_hardware_gnss_common_default_Utils_H_
#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
#include <android/hardware/gnss/1.0/IGnss.h>
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.1/IGnss.h>
@ -28,28 +29,22 @@ namespace hardware {
namespace gnss {
namespace common {
using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
using GnssSvInfoV1_0 = V1_0::IGnssCallback::GnssSvInfo;
using GnssSvInfoV2_0 = V2_0::IGnssCallback::GnssSvInfo;
using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
using GnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo;
using Row = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::Row;
using Coord = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::Coord;
struct Utils {
static GnssDataV2_0 getMockMeasurementV2_0();
static GnssDataV2_1 getMockMeasurementV2_1();
static aidl::android::hardware::gnss::GnssData getMockMeasurement();
static V2_0::IGnssMeasurementCallback::GnssData getMockMeasurementV2_0();
static V2_1::IGnssMeasurementCallback::GnssData getMockMeasurementV2_1();
static V2_0::GnssLocation getMockLocationV2_0();
static V1_0::GnssLocation getMockLocationV1_0();
static hidl_vec<GnssSvInfoV2_1> getMockSvInfoListV2_1();
static GnssSvInfoV2_1 getMockSvInfoV2_1(GnssSvInfoV2_0 gnssSvInfoV2_0, float basebandCN0DbHz);
static GnssSvInfoV2_0 getMockSvInfoV2_0(GnssSvInfoV1_0 gnssSvInfoV1_0,
V2_0::GnssConstellationType type);
static GnssSvInfoV1_0 getMockSvInfoV1_0(int16_t svid, V1_0::GnssConstellationType type,
float cN0DbHz, float elevationDegrees,
float azimuthDegrees);
static hidl_vec<GnssAntennaInfo> getMockAntennaInfos();
static hidl_vec<V2_1::IGnssCallback::GnssSvInfo> getMockSvInfoListV2_1();
static V2_1::IGnssCallback::GnssSvInfo getMockSvInfoV2_1(
V2_0::IGnssCallback::GnssSvInfo gnssSvInfoV2_0, float basebandCN0DbHz);
static V2_0::IGnssCallback::GnssSvInfo getMockSvInfoV2_0(
V1_0::IGnssCallback::GnssSvInfo gnssSvInfoV1_0, V2_0::GnssConstellationType type);
static V1_0::IGnssCallback::GnssSvInfo getMockSvInfoV1_0(int16_t svid,
V1_0::GnssConstellationType type,
float cN0DbHz, float elevationDegrees,
float azimuthDegrees);
static hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo> getMockAntennaInfos();
};
} // namespace common

View file

@ -23,29 +23,25 @@
namespace android::hardware::gnss::V2_1::implementation {
using ::android::sp;
using ::android::hardware::Return;
using ::android::hardware::Void;
using IGnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfo;
using IGnssAntennaInfoCallback = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
struct GnssAntennaInfo : public IGnssAntennaInfo {
struct GnssAntennaInfo : public ::android::hardware::gnss::V2_1::IGnssAntennaInfo {
GnssAntennaInfo();
~GnssAntennaInfo();
// Methods from ::android::hardware::gnss::V2_1::IGnssAntennaInfo follow.
Return<GnssAntennaInfoStatus> setCallback(
const sp<IGnssAntennaInfoCallback>& callback) override;
const sp<::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback>& callback) override;
Return<void> close() override;
private:
void start();
void stop();
void reportAntennaInfo(
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& antennaInfo) const;
const hidl_vec<
::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>&
antennaInfo) const;
// Guarded by mMutex
static sp<IGnssAntennaInfoCallback> sCallback;
static sp<::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback> sCallback;
std::atomic<long> mMinIntervalMillis;
std::atomic<bool> mIsActive;

View file

@ -25,35 +25,27 @@
namespace android::hardware::gnss::V2_1::implementation {
using ::android::sp;
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 BlacklistedSourceV2_1 =
::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource;
using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
struct BlacklistedSourceHashV2_1 {
inline int operator()(const BlacklistedSourceV2_1& source) const {
inline int operator()(
const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& source)
const {
return int(source.constellation) * 1000 + int(source.svid);
}
};
struct BlacklistedSourceEqualV2_1 {
inline bool operator()(const BlacklistedSourceV2_1& s1, const BlacklistedSourceV2_1& s2) const {
inline bool operator()(
const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& s1,
const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& s2)
const {
return (s1.constellation == s2.constellation) && (s1.svid == s2.svid);
}
};
using BlacklistedSourceSetV2_1 =
std::unordered_set<BlacklistedSourceV2_1, BlacklistedSourceHashV2_1,
BlacklistedSourceEqualV2_1>;
using BlacklistedConstellationSetV2_1 = std::unordered_set<GnssConstellationTypeV2_0>;
std::unordered_set<::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource,
BlacklistedSourceHashV2_1, BlacklistedSourceEqualV2_1>;
using BlacklistedConstellationSetV2_1 = std::unordered_set<V2_0::GnssConstellationType>;
struct GnssConfiguration : public IGnssConfiguration {
// Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
@ -78,7 +70,7 @@ struct GnssConfiguration : public IGnssConfiguration {
Return<bool> setBlacklist_2_1(
const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& blacklist) override;
Return<bool> isBlacklistedV2_1(const GnssSvInfoV2_1& gnssSvInfo) const;
Return<bool> isBlacklistedV2_1(const V2_1::IGnssCallback::GnssSvInfo& gnssSvInfo) const;
private:
mutable std::recursive_mutex mMutex;

View file

@ -21,15 +21,8 @@
namespace android::hardware::gnss::V1_1::implementation {
using ::android::sp;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using V1_0::IGnssDebug;
/* Interface for GNSS Debug support. */
struct GnssDebug : public IGnssDebug {
struct GnssDebug : public V1_0::IGnssDebug {
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
* These declarations were generated from IGnssDebug.hal.

View file

@ -25,17 +25,6 @@
namespace android::hardware::gnss::V2_1::implementation {
using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
using ::android::sp;
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;
struct GnssMeasurement : public IGnssMeasurement {
GnssMeasurement();
~GnssMeasurement();
@ -59,8 +48,8 @@ struct GnssMeasurement : public IGnssMeasurement {
private:
void start();
void stop();
void reportMeasurement(const GnssDataV2_0&);
void reportMeasurement(const GnssDataV2_1&);
void reportMeasurement(const V2_0::IGnssMeasurementCallback::GnssData&);
void reportMeasurement(const V2_1::IGnssMeasurementCallback::GnssData&);
// Guarded by mMutex
static sp<V2_1::IGnssMeasurementCallback> sCallback_2_1;

View file

@ -22,9 +22,6 @@
namespace android::hardware::gnss::measurement_corrections::V1_1::implementation {
using ::android::sp;
using ::android::hardware::Return;
struct GnssMeasurementCorrections : public IMeasurementCorrections {
GnssMeasurementCorrections();
~GnssMeasurementCorrections();

View file

@ -39,16 +39,6 @@
namespace android::hardware::gnss::common::implementation {
using GnssSvInfo = V2_1::IGnssCallback::GnssSvInfo;
using common::NmeaFixInfo;
using common::Utils;
using measurement_corrections::V1_1::implementation::GnssMeasurementCorrections;
using V2_1::implementation::GnssAntennaInfo;
using V2_1::implementation::GnssConfiguration;
using V2_1::implementation::GnssMeasurement;
constexpr int INPUT_BUFFER_SIZE = 128;
constexpr char CMD_GET_LOCATION[] = "CMD_GET_LOCATION";
constexpr char GNSS_PATH[] = "/dev/gnss0";
@ -120,7 +110,7 @@ struct GnssTemplate : public T_IGnss {
std::unique_ptr<V2_0::GnssLocation> getLocationFromHW();
void reportLocation(const V2_0::GnssLocation&) const;
void reportLocation(const V1_0::GnssLocation&) const;
void reportSvStatus(const hidl_vec<GnssSvInfo>&) const;
void reportSvStatus(const hidl_vec<V2_1::IGnssCallback::GnssSvInfo>&) const;
Return<void> help(const hidl_handle& fd);
Return<void> setLocation(const hidl_handle& fd, const hidl_vec<hidl_string>& options);
@ -131,15 +121,15 @@ struct GnssTemplate : public T_IGnss {
static sp<V1_0::IGnssCallback> sGnssCallback_1_0;
std::atomic<long> mMinIntervalMs;
sp<GnssConfiguration> mGnssConfiguration;
sp<V2_1::implementation::GnssConfiguration> mGnssConfiguration;
std::atomic<bool> mIsActive;
std::atomic<bool> mHardwareModeChecked;
std::atomic<int> mGnssFd;
std::thread mThread;
mutable std::mutex mMutex;
virtual hidl_vec<GnssSvInfo> filterBlocklistedSatellitesV2_1(
hidl_vec<GnssSvInfo> gnssSvInfoList);
virtual hidl_vec<V2_1::IGnssCallback::GnssSvInfo> filterBlocklistedSatellitesV2_1(
hidl_vec<V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList);
};
template <class T_IGnss>
@ -154,7 +144,7 @@ sp<V1_0::IGnssCallback> GnssTemplate<T_IGnss>::sGnssCallback_1_0 = nullptr;
template <class T_IGnss>
GnssTemplate<T_IGnss>::GnssTemplate()
: mMinIntervalMs(1000),
mGnssConfiguration{new GnssConfiguration()},
mGnssConfiguration{new V2_1::implementation::GnssConfiguration()},
mHardwareModeChecked(false),
mGnssFd(-1) {}
@ -237,8 +227,8 @@ Return<bool> GnssTemplate<T_IGnss>::start() {
}
template <class T_IGnss>
hidl_vec<GnssSvInfo> GnssTemplate<T_IGnss>::filterBlocklistedSatellitesV2_1(
hidl_vec<GnssSvInfo> gnssSvInfoList) {
hidl_vec<V2_1::IGnssCallback::GnssSvInfo> GnssTemplate<T_IGnss>::filterBlocklistedSatellitesV2_1(
hidl_vec<V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList) {
ALOGD("filterBlocklistedSatellitesV2_1");
for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) {
if (mGnssConfiguration->isBlacklistedV2_1(gnssSvInfoList[i])) {
@ -348,7 +338,7 @@ Return<sp<V1_0::IGnssNi>> GnssTemplate<T_IGnss>::getExtensionGnssNi() {
template <class T_IGnss>
Return<sp<V1_0::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement() {
ALOGD("Gnss::getExtensionGnssMeasurement");
return new GnssMeasurement();
return new V2_1::implementation::GnssMeasurement();
}
template <class T_IGnss>
@ -501,14 +491,14 @@ Return<sp<V2_0::IAGnssRil>> GnssTemplate<T_IGnss>::getExtensionAGnssRil_2_0() {
template <class T_IGnss>
Return<sp<V2_0::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_2_0() {
ALOGD("Gnss::getExtensionGnssMeasurement_2_0");
return new GnssMeasurement();
return new V2_1::implementation::GnssMeasurement();
}
template <class T_IGnss>
Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
GnssTemplate<T_IGnss>::getExtensionMeasurementCorrections() {
ALOGD("Gnss::getExtensionMeasurementCorrections()");
return new GnssMeasurementCorrections();
return new measurement_corrections::V1_1::implementation::GnssMeasurementCorrections();
}
template <class T_IGnss>
@ -569,7 +559,7 @@ Return<bool> GnssTemplate<T_IGnss>::setCallback_2_1(const sp<V2_1::IGnssCallback
template <class T_IGnss>
Return<sp<V2_1::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_2_1() {
ALOGD("Gnss::getExtensionGnssMeasurement_2_1");
return new GnssMeasurement();
return new V2_1::implementation::GnssMeasurement();
}
template <class T_IGnss>
@ -582,17 +572,18 @@ template <class T_IGnss>
Return<sp<measurement_corrections::V1_1::IMeasurementCorrections>>
GnssTemplate<T_IGnss>::getExtensionMeasurementCorrections_1_1() {
ALOGD("Gnss::getExtensionMeasurementCorrections_1_1()");
return new GnssMeasurementCorrections();
return new measurement_corrections::V1_1::implementation::GnssMeasurementCorrections();
}
template <class T_IGnss>
Return<sp<V2_1::IGnssAntennaInfo>> GnssTemplate<T_IGnss>::getExtensionGnssAntennaInfo() {
ALOGD("Gnss::getExtensionGnssAntennaInfo");
return new GnssAntennaInfo();
return new V2_1::implementation::GnssAntennaInfo();
}
template <class T_IGnss>
void GnssTemplate<T_IGnss>::reportSvStatus(const hidl_vec<GnssSvInfo>& svInfoList) const {
void GnssTemplate<T_IGnss>::reportSvStatus(
const hidl_vec<V2_1::IGnssCallback::GnssSvInfo>& svInfoList) const {
std::unique_lock<std::mutex> lock(mMutex);
// TODO(skz): update this to call 2_0 callback if non-null
if (sGnssCallback_2_1 == nullptr) {

View file

@ -21,6 +21,9 @@
namespace android::hardware::gnss::V2_1::implementation {
using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
using BlacklistedSourceV2_1 = V2_1::IGnssConfiguration::BlacklistedSource;
// Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setSuplEs(bool enable) {
ALOGD("setSuplEs enable: %d", enable);
@ -69,7 +72,7 @@ Return<bool> GnssConfiguration::setEsExtensionSec(uint32_t emergencyExtensionSec
// Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setBlacklist_2_1(
const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& sourceList) {
const hidl_vec<BlacklistedSourceV2_1>& sourceList) {
std::unique_lock<std::recursive_mutex> lock(mMutex);
mBlacklistedConstellationSet.clear();
mBlacklistedSourceSet.clear();

View file

@ -114,7 +114,7 @@ void GnssMeasurement::stop() {
}
}
void GnssMeasurement::reportMeasurement(const GnssDataV2_0& data) {
void GnssMeasurement::reportMeasurement(const V2_0::IGnssMeasurementCallback::GnssData& data) {
ALOGD("reportMeasurement()");
std::unique_lock<std::mutex> lock(mMutex);
if (sCallback_2_0 == nullptr) {
@ -127,7 +127,7 @@ void GnssMeasurement::reportMeasurement(const GnssDataV2_0& data) {
}
}
void GnssMeasurement::reportMeasurement(const GnssDataV2_1& data) {
void GnssMeasurement::reportMeasurement(const V2_1::IGnssMeasurementCallback::GnssData& data) {
ALOGD("reportMeasurement()");
std::unique_lock<std::mutex> lock(mMutex);
if (sCallback_2_1 == nullptr) {

View file

@ -23,36 +23,10 @@
#include <gtest/gtest.h>
#include <chrono>
using ::android::hardware::gnss::common::Utils;
using android::hardware::hidl_vec;
using android::hardware::Return;
using android::hardware::Void;
using android::hardware::gnss::common::GnssCallback;
using android::hardware::gnss::common::GnssCallbackEventQueue;
using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
using android::hardware::gnss::V1_0::GnssLocationFlags;
using android::hardware::gnss::V2_0::GnssConstellationType;
using android::hardware::gnss::V2_1::IGnssAntennaInfo;
using android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
using GnssLocation_1_0 = android::hardware::gnss::V1_0::GnssLocation;
using GnssLocation_2_0 = android::hardware::gnss::V2_0::GnssLocation;
using IGnssCallback_1_0 = android::hardware::gnss::V1_0::IGnssCallback;
using IGnssCallback_2_0 = android::hardware::gnss::V2_0::IGnssCallback;
using IGnssCallback_2_1 = android::hardware::gnss::V2_1::IGnssCallback;
using IGnssMeasurementCallback_1_0 = android::hardware::gnss::V1_0::IGnssMeasurementCallback;
using IGnssMeasurementCallback_1_1 = android::hardware::gnss::V1_1::IGnssMeasurementCallback;
using IGnssMeasurementCallback_2_0 = android::hardware::gnss::V2_0::IGnssMeasurementCallback;
using IGnssMeasurementCallback_2_1 = android::hardware::gnss::V2_1::IGnssMeasurementCallback;
using android::sp;
#define TIMEOUT_SEC 2 // for basic commands/responses
namespace android::hardware::gnss::common {
// The main test class for GNSS HAL.
template <class T_IGnss>
class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
@ -62,34 +36,37 @@ class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
virtual void TearDown() override;
/* Callback class for GnssMeasurement. */
class GnssMeasurementCallback : public IGnssMeasurementCallback_2_1 {
class GnssMeasurementCallback : public V2_1::IGnssMeasurementCallback {
public:
GnssCallbackEventQueue<IGnssMeasurementCallback_2_1::GnssData> measurement_cbq_;
GnssCallbackEventQueue<V2_1::IGnssMeasurementCallback::GnssData> measurement_cbq_;
GnssMeasurementCallback() : measurement_cbq_("measurement"){};
virtual ~GnssMeasurementCallback() = default;
// Methods from V1_0::IGnssMeasurementCallback follow.
Return<void> GnssMeasurementCb(const IGnssMeasurementCallback_1_0::GnssData&) override {
Return<void> GnssMeasurementCb(const V1_0::IGnssMeasurementCallback::GnssData&) override {
return Void();
}
// Methods from V1_1::IGnssMeasurementCallback follow.
Return<void> gnssMeasurementCb(const IGnssMeasurementCallback_1_1::GnssData&) override {
Return<void> gnssMeasurementCb(const V1_1::IGnssMeasurementCallback::GnssData&) override {
return Void();
}
// Methods from V2_0::IGnssMeasurementCallback follow.
Return<void> gnssMeasurementCb_2_0(const IGnssMeasurementCallback_2_0::GnssData&) override {
Return<void> gnssMeasurementCb_2_0(
const V2_0::IGnssMeasurementCallback::GnssData&) override {
return Void();
}
// Methods from V2_1::IGnssMeasurementCallback follow.
Return<void> gnssMeasurementCb_2_1(const IGnssMeasurementCallback_2_1::GnssData&) override;
Return<void> gnssMeasurementCb_2_1(
const V2_1::IGnssMeasurementCallback::GnssData&) override;
};
/* Callback class for GnssMeasurementCorrections. */
class GnssMeasurementCorrectionsCallback : public IMeasurementCorrectionsCallback {
class GnssMeasurementCorrectionsCallback
: public measurement_corrections::V1_0::IMeasurementCorrectionsCallback {
public:
uint32_t last_capabilities_;
GnssCallbackEventQueue<uint32_t> capabilities_cbq_;
@ -102,9 +79,9 @@ class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
};
/* Callback class for GnssAntennaInfo. */
class GnssAntennaInfoCallback : public IGnssAntennaInfoCallback {
class GnssAntennaInfoCallback : public V2_1::IGnssAntennaInfoCallback {
public:
GnssCallbackEventQueue<hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>>
GnssCallbackEventQueue<hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>>
antenna_info_cbq_;
GnssAntennaInfoCallback() : antenna_info_cbq_("info"){};
@ -112,7 +89,7 @@ class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
// Methods from V2_1::GnssAntennaInfoCallback follow.
Return<void> gnssAntennaInfoCb(
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
const hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
};
/*
@ -138,7 +115,7 @@ class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
*
* check_speed: true if speed related fields are also verified.
*/
void CheckLocation(const GnssLocation_2_0& location, const bool check_speed);
void CheckLocation(const V2_0::GnssLocation& location, const bool check_speed);
/*
* StartAndCheckLocations:
@ -170,7 +147,7 @@ class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
* Note that location is not stopped in this method. The client should call
* StopAndClearLocations() after the call.
*/
GnssConstellationType startLocationAndGetNonGpsConstellation(
V2_0::GnssConstellationType startLocationAndGetNonGpsConstellation(
const int locations_to_await, const int gnss_sv_info_list_timeout);
sp<T_IGnss> gnss_hal_; // GNSS HAL to call into
@ -283,7 +260,7 @@ bool GnssHalTestTemplate<T_IGnss>::StartAndCheckFirstLocation() {
}
template <class T_IGnss>
void GnssHalTestTemplate<T_IGnss>::CheckLocation(const GnssLocation_2_0& location,
void GnssHalTestTemplate<T_IGnss>::CheckLocation(const V2_0::GnssLocation& location,
bool check_speed) {
const bool check_more_accuracies =
(gnss_cb_->info_cbq_.calledCount() > 0 && gnss_cb_->last_info_.yearOfHw >= 2017);
@ -315,7 +292,7 @@ void GnssHalTestTemplate<T_IGnss>::StartAndCheckLocations(int count) {
}
template <class T_IGnss>
GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsConstellation(
V2_0::GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsConstellation(
const int locations_to_await, const int gnss_sv_info_list_timeout) {
gnss_cb_->location_cbq_.reset();
StartAndCheckLocations(locations_to_await);
@ -328,29 +305,29 @@ GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsCon
sv_info_list_cbq_size, locations_to_await, location_called_count);
// Find first non-GPS constellation to blacklist
GnssConstellationType constellation_to_blacklist = GnssConstellationType::UNKNOWN;
V2_0::GnssConstellationType constellation_to_blacklist = V2_0::GnssConstellationType::UNKNOWN;
for (int i = 0; i < sv_info_list_cbq_size; ++i) {
hidl_vec<IGnssCallback_2_1::GnssSvInfo> sv_info_vec;
hidl_vec<V2_1::IGnssCallback::GnssSvInfo> sv_info_vec;
gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_vec, gnss_sv_info_list_timeout);
for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
const auto& gnss_sv = sv_info_vec[iSv];
if ((gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX) &&
(gnss_sv.v2_0.constellation != GnssConstellationType::UNKNOWN) &&
(gnss_sv.v2_0.constellation != GnssConstellationType::GPS)) {
if ((gnss_sv.v2_0.v1_0.svFlag & V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX) &&
(gnss_sv.v2_0.constellation != V2_0::GnssConstellationType::UNKNOWN) &&
(gnss_sv.v2_0.constellation != V2_0::GnssConstellationType::GPS)) {
// found a non-GPS constellation
constellation_to_blacklist = gnss_sv.v2_0.constellation;
break;
}
}
if (constellation_to_blacklist != GnssConstellationType::UNKNOWN) {
if (constellation_to_blacklist != V2_0::GnssConstellationType::UNKNOWN) {
break;
}
}
if (constellation_to_blacklist == GnssConstellationType::UNKNOWN) {
if (constellation_to_blacklist == V2_0::GnssConstellationType::UNKNOWN) {
ALOGI("No non-GPS constellations found, constellation blacklist test less effective.");
// Proceed functionally to blacklist something.
constellation_to_blacklist = GnssConstellationType::GLONASS;
constellation_to_blacklist = V2_0::GnssConstellationType::GLONASS;
}
return constellation_to_blacklist;
@ -358,7 +335,7 @@ GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsCon
template <class T_IGnss>
Return<void> GnssHalTestTemplate<T_IGnss>::GnssMeasurementCallback::gnssMeasurementCb_2_1(
const IGnssMeasurementCallback_2_1::GnssData& data) {
const V2_1::IGnssMeasurementCallback::GnssData& data) {
ALOGD("GnssMeasurement v2.1 received. Size = %d", (int)data.measurements.size());
measurement_cbq_.store(data);
return Void();
@ -374,8 +351,10 @@ Return<void> GnssHalTestTemplate<T_IGnss>::GnssMeasurementCorrectionsCallback::s
template <class T_IGnss>
Return<void> GnssHalTestTemplate<T_IGnss>::GnssAntennaInfoCallback::gnssAntennaInfoCb(
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos) {
const hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos) {
ALOGD("GnssAntennaInfo v2.1 received. Size = %d", (int)gnssAntennaInfos.size());
antenna_info_cbq_.store(gnssAntennaInfos);
return Void();
}
} // namespace android::hardware::gnss::common