IGpsDebug Interface for GPS Hal

Bug: 31974439
Test: mma
Change-Id: I09097b158833c943cb5e7578673c454e63668278
diff --git a/gnss/1.0/Android.bp b/gnss/1.0/Android.bp
index 730087f..a97531d 100644
--- a/gnss/1.0/Android.bp
+++ b/gnss/1.0/Android.bp
@@ -12,6 +12,7 @@
         "IAGnssRilCallback.hal",
         "IGnss.hal",
         "IGnssCallback.hal",
+        "IGnssDebug.hal",
         "IGnssGeofenceCallback.hal",
         "IGnssGeofencing.hal",
         "IGnssMeasurement.hal",
@@ -31,6 +32,7 @@
         "android/hardware/gnss/1.0/AGnssRilCallbackAll.cpp",
         "android/hardware/gnss/1.0/GnssAll.cpp",
         "android/hardware/gnss/1.0/GnssCallbackAll.cpp",
+        "android/hardware/gnss/1.0/GnssDebugAll.cpp",
         "android/hardware/gnss/1.0/GnssGeofenceCallbackAll.cpp",
         "android/hardware/gnss/1.0/GnssGeofencingAll.cpp",
         "android/hardware/gnss/1.0/GnssMeasurementAll.cpp",
@@ -56,6 +58,7 @@
         "IAGnssRilCallback.hal",
         "IGnss.hal",
         "IGnssCallback.hal",
+        "IGnssDebug.hal",
         "IGnssGeofenceCallback.hal",
         "IGnssGeofencing.hal",
         "IGnssMeasurement.hal",
@@ -99,6 +102,11 @@
         "android/hardware/gnss/1.0/BnGnssCallback.h",
         "android/hardware/gnss/1.0/BpGnssCallback.h",
         "android/hardware/gnss/1.0/BsGnssCallback.h",
+        "android/hardware/gnss/1.0/IGnssDebug.h",
+        "android/hardware/gnss/1.0/IHwGnssDebug.h",
+        "android/hardware/gnss/1.0/BnGnssDebug.h",
+        "android/hardware/gnss/1.0/BpGnssDebug.h",
+        "android/hardware/gnss/1.0/BsGnssDebug.h",
         "android/hardware/gnss/1.0/IGnssGeofenceCallback.h",
         "android/hardware/gnss/1.0/IHwGnssGeofenceCallback.h",
         "android/hardware/gnss/1.0/BnGnssGeofenceCallback.h",
diff --git a/gnss/1.0/IGnss.hal b/gnss/1.0/IGnss.hal
index 0f16124..bc19e78 100644
--- a/gnss/1.0/IGnss.hal
+++ b/gnss/1.0/IGnss.hal
@@ -18,9 +18,10 @@
 
 import IAGnss;
 import IAGnssRil;
+import IGnssCallback;
+import IGnssDebug;
 import IGnssMeasurement;
 import IGnssNavigationMessage;
-import IGnssCallback;
 import IGnssGeofencing;
 import IGnssNi;
 import IGnssXtra;
@@ -200,4 +201,10 @@
      */
     getExtensionXtra() generates (IGnssXtra infc);
 
+    /*
+     * This method returns the IGnssDebug interface.
+     *
+     * @return infc Handle to the IGnssDebug interface.
+     */
+    getExtensionGnssDebug() generates (IGnssDebug infc);
 };
diff --git a/gnss/1.0/IGnssDebug.hal b/gnss/1.0/IGnssDebug.hal
new file mode 100644
index 0000000..b0ac69d
--- /dev/null
+++ b/gnss/1.0/IGnssDebug.hal
@@ -0,0 +1,122 @@
+package android.hardware.gnss@1.0;
+
+/* Extended interface for DEBUG support. */
+interface IGnssDebug {
+    enum SatelliteEphemerisType : uint32_t {
+        /* no information is known to the gnss hardware, about this satellite */
+        UNKNOWN,
+        /*  this satellite is known to exist */
+        KNOWN,
+        /*  this satellite is not known to exist */
+        NONEXISTENT,
+        /* Only Almanac (approximate) location known for this satellite */
+        ALMANAC_ONLY,
+        /* Ephemeris is known from demodulating the signal on device */
+        DEMODULATED,
+        /* Ephemeris has been provided by SUPL */
+        SUPL_PROVIDED,
+        /* Ephemeris has been provided by another server */
+        OTHER_SERVER_PROVIDED,
+        /*
+         * Predicted ephemeris has been provided by a server
+         * (e.g. Xtra, Extended Ephemeris, etc...)
+         */
+        SERVER_PREDICTED,
+        /*
+         * Predicted ephemeris in use, generated locally on the device (e.g. from prior
+         * ephemeris)
+         */
+        LOCALLY_PREDICTED
+    };
+
+    /*
+     * 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 altitudeDegrees;
+        /*
+         * estimated horizontal accuracy of position expressed in meters, radial,
+         * 68% confidence.
+         */
+        double accuracyMeters;
+        /*
+         * Time duration before this report that this position information was
+         * valid.
+         */
+        float ageSeconds;
+    };
+
+    /*
+     * Provides the current best known UTC time estimate.
+     */
+    struct TimeDebug {
+        /*
+         * Validity of the data in the struct.
+         * False if current time is unknown.
+         */
+        bool valid;
+        /*
+         * UTC time estimate.
+         */
+        GnssUtcTime timeEstimate;
+        /* 68% error estimate in time. */
+        float timeUncertaintyNs;
+    };
+
+    /*
+     * 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 ephemeris type of the satellite. */
+        SatelliteEphemerisType ephemerisType;
+        /*
+         * Time duration before this report, that the ephemeris source was last
+         * updated, e.g. latest demodulation, or latest server download.
+         * Set to 0 when ephemerisType is UNKNOWN.
+         */
+        float ephemerisAgeSeconds;
+    };
+
+    /*
+     * 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 decoded satellite ephemeris.
+         * Should provide a complete list for all constellations 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);
+};