package android.hardware.gnss@1.0;

/** Extended interface for DEBUG support. */
interface IGnssDebug {
    enum SatelliteEphemerisType : uint8_t {
        /** Ephemeris is known for this satellite. */
        EPHEMERIS,
        /**
         * Ephemeris is not known, but Almanac (approximate location) is known.
         */
        ALMANAC_ONLY,
        /**
         * Both ephemeris & almanac are not known (e.g. during a cold start
         * blind search.)
         */
        NOT_AVAILABLE
    };

    enum SatelliteEphemerisSource : uint8_t {
        /**
         * The ephemeris (or almanac only) information was demodulated from the
         * signal received on the device
         */
        DEMODULATED,
        /**
         * The ephemeris (or almanac only) information was received from a SUPL
         * server.
         */
        SUPL_PROVIDED,
        /**
         * The ephemeris (or almanac only) information was provided by another
         * server.
         */
        OTHER_SERVER_PROVIDED,
        /**
         * The ephemeris (or almanac only) information was provided by another
         * method, e.g. injected via a local debug tool, from build defaults
         * (e.g. almanac), or is from a satellite
         * with SatelliteEphemerisType::NOT_AVAILABLE.
         */
        OTHER
    };

    enum SatelliteEphemerisHealth : uint8_t {
        /** The ephemeris is known good. */
        GOOD,
        /** The ephemeris is known bad. */
        BAD,
        /** The ephemeris is unknown to be good or bad. */
        UNKNOWN
    };

    /**
     * Provides the current best known position from any
     * source (GNSS or injected assistance).
     */
    struct PositionDebug {
        /**
         * Validity of the data in this struct. False only if no
         * latitude/longitude information is known.
         */
        bool valid;
        /** Latitude expressed in degrees */
        double latitudeDegrees;
        /** Longitude expressed in degrees */
        double longitudeDegrees;
        /** Altitude above ellipsoid expressed in meters */
        float altitudeMeters;
        /** Represents horizontal speed in meters per second. */
        float speedMetersPerSec;
        /** Represents heading in degrees. */
        float bearingDegrees;
        /**
         * Estimated horizontal accuracy of position expressed in meters,
         * radial, 68% confidence.
         */
        double horizontalAccuracyMeters;
        /**
         * Estimated vertical accuracy of position expressed in meters, with
         * 68% confidence.
         */
        double verticalAccuracyMeters;
        /**
         * Estimated speed accuracy in meters per second with 68% confidence.
         */
        double speedAccuracyMetersPerSecond;
        /**
         * estimated bearing accuracy degrees with 68% confidence.
         */
        double bearingAccuracyDegrees;
        /**
         * Time duration before this report that this position information was
         * valid.  This can, for example, be a previous injected location with
         * an age potentially thousands of seconds old, or
         * extrapolated to the current time (with appropriately increased
         * accuracy estimates), with a (near) zero age.
         */
        float ageSeconds;
    };

    /**
     * Provides the current best known UTC time estimate.
     * If no fresh information is available, e.g. after a delete all,
     * then whatever the effective defaults are on the device must be
     * provided (e.g. Jan. 1, 2017, with an uncertainty of 5 years) expressed
     * in the specified units.
     */
    struct TimeDebug {
        /** UTC time estimate. */
        GnssUtcTime timeEstimate;
        /** 68% error estimate in time. */
        float timeUncertaintyNs;
        /**
         * 68% error estimate in local clock drift,
         * in nanoseconds per second (also known as parts per billion - ppb.)
         */
        float frequencyUncertaintyNsPerSec;
    };

    /**
     * Provides a single satellite info that has decoded navigation data.
     */
    struct SatelliteData {
        /** Satellite vehicle ID number */
        int16_t svid;
        /** Defines the constellation type of the given SV. */
        GnssConstellationType constellation;

        /**
         * Defines the standard broadcast ephemeris or almanac availability for
         * the satellite.  To report status of predicted orbit and clock
         * information, see the serverPrediction fields below.
         */
        SatelliteEphemerisType ephemerisType;
        /** Defines the ephemeris source of the satellite. */
        SatelliteEphemerisSource ephemerisSource;
        /**
         * Defines whether the satellite is known healthy
         * (safe for use in location calculation.)
         */
        SatelliteEphemerisHealth ephemerisHealth;
        /**
         * Time duration from this report (current time), minus the
         * effective time of the ephemeris source (e.g. TOE, TOA.)
         * Set to 0 when ephemerisType is NOT_AVAILABLE.
         */
        float ephemerisAgeSeconds;

        /**
         * True if a server has provided a predicted orbit and clock model for
         * this satellite.
         */
        bool serverPredictionIsAvailable;
        /**
         * Time duration from this report (current time) minus the time of the
         * start of the server predicted information.  For example, a 1 day
         * old prediction would be reported as 86400 seconds here.
         */
        float serverPredictionAgeSeconds;
    };

    /**
     * Provides a set of debug information that is filled by the GNSS chipset
     * when the method getDebugData() is invoked.
     */
    struct DebugData {
        /** Current best known position. */
        PositionDebug position;
        /** Current best know time estimate */
        TimeDebug time;
        /**
         * Provides a list of the available satellite data, for all
         * satellites and constellations the device can track,
         * including GnssConstellationType UNKNOWN.
         */
        vec<SatelliteData> satelliteDataArray;
    };

    /**
     * This methods requests position, time and satellite ephemeris debug information
     * from the HAL.
     *
     * @return ret debugData information from GNSS Hal that contains the current best
     * known position, best known time estimate and a complete list of
     * constellations that the device can track.
     */
    getDebugData() generates (DebugData debugData);
};