Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14073d9f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Clarify setCallback() can be called without a previous close() call" am: 1fcce708

parents 0b274d6a 1fcce708
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ interface IGnssMeasurementInterface {
     * output rate of 1Hz (occasional intra-measurement time offsets in the range from 0-2000msec
     * can be tolerated.)
     *
     * If setCallback() is invoked without a previous close(), the HAL must use the new callback
     * and parameters to provide updates.
     *
     * @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
@@ -104,6 +107,9 @@ interface IGnssMeasurementInterface {
    /**
     * Initializes the interface and registers the callback routines with the HAL.
     *
     * If setCallbackWithOptions() is invoked without a previous close(), the HAL must use the new
     * callback and options to provide updates.
     *
     * @param options See Options definition.
     */
    void setCallbackWithOptions(in IGnssMeasurementCallback callback, in Options options);
+29 −0
Original line number Diff line number Diff line
@@ -1494,3 +1494,32 @@ TEST_P(GnssHalTest, TestGnssMeasurementIntervals_LocationOnAfterMeasurement) {
        assertMeanAndStdev(locationIntervalMs, deltas);
    }
}

TEST_P(GnssHalTest, TestGnssMeasurementSetCallback) {
    if (aidl_gnss_hal_->getInterfaceVersion() <= 2) {
        return;
    }

    sp<IGnssMeasurementInterface> iGnssMeasurement;
    auto status = aidl_gnss_hal_->getExtensionGnssMeasurement(&iGnssMeasurement);
    ASSERT_TRUE(status.isOk());
    ASSERT_TRUE(iGnssMeasurement != nullptr);

    ALOGD("TestGnssMeasurementSetCallback");
    auto callback = sp<GnssMeasurementCallbackAidl>::make();
    std::vector<int> deltas;

    // setCallback at 20s interval and wait for 1 measurement
    startMeasurementWithInterval(20000, iGnssMeasurement, callback);
    collectMeasurementIntervals(callback, /* numEvents= */ 1, /* timeoutSeconds= */ 10, deltas);

    // setCallback at 1s interval and wait for 5 measurements
    startMeasurementWithInterval(1000, iGnssMeasurement, callback);
    collectMeasurementIntervals(callback, /* numEvents= */ 5, /* timeoutSeconds= */ 10, deltas);

    // verify the measurements were received at 1Hz
    assertMeanAndStdev(1000, deltas);

    status = iGnssMeasurement->close();
    ASSERT_TRUE(status.isOk());
}