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

Commit ab2527a4 authored by Yu-Han Yang's avatar Yu-Han Yang Committed by Android (Google) Code Review
Browse files

Merge "Add register/unregister methods for SvStatus and NMEA (hardware/interfaces)"

parents e599ad04 69f0f8ba
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ interface IGnss {
  void setPositionMode(in android.hardware.gnss.IGnss.PositionModeOptions options);
  android.hardware.gnss.IGnssAntennaInfo getExtensionGnssAntennaInfo();
  @nullable android.hardware.gnss.measurement_corrections.IMeasurementCorrectionsInterface getExtensionMeasurementCorrections();
  void startSvStatus();
  void stopSvStatus();
  void startNmea();
  void stopNmea();
  const int ERROR_INVALID_ARGUMENT = 1;
  const int ERROR_ALREADY_INIT = 2;
  const int ERROR_GENERIC = 3;
+21 −0
Original line number Diff line number Diff line
@@ -320,4 +320,25 @@ interface IGnss {
     * @return Handle to the IMeasurementCorrectionsInterface.
     */
    @nullable IMeasurementCorrectionsInterface getExtensionMeasurementCorrections();

    /**
     * Starts a SvStatus output stream using the IGnssCallback gnssSvStatusCb().
     */
    void startSvStatus();

    /**
     * Stops the SvStatus output stream.
     */
    void stopSvStatus();

    /**
     * Starts an NMEA (National Marine Electronics Association) output stream using the
     * IGnssCallback gnssNmeaCb().
     */
    void startNmea();

    /**
     * Stops the NMEA output stream.
     */
    void stopNmea();
}
+4 −0
Original line number Diff line number Diff line
@@ -202,6 +202,10 @@ interface IGnssCallback {
    /**
     * Callback for the HAL to pass a vector of GnssSvInfo back to the client.
     *
     * If GnssMeasurement is registered, the SvStatus report interval is the same as the measurement
     * interval, i.e., the interval the measurement engine runs at. If GnssMeasurement is not
     * registered, the SvStatus interval is the same as the location interval.
     *
     * @param svInfo SV status information from HAL.
     */
    void gnssSvStatusCb(in GnssSvInfo[] svInfoList);
+31 −5
Original line number Diff line number Diff line
@@ -87,15 +87,13 @@ ScopedAStatus Gnss::start() {
    mIsActive = true;
    this->reportGnssStatusValue(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
    mThread = std::thread([this]() {
        auto svStatus = filterBlocklistedSatellites(Utils::getMockSvInfoList());
        this->reportSvStatus(svStatus);
        this->reportSvStatus();
        if (!mFirstFixReceived) {
            std::this_thread::sleep_for(std::chrono::milliseconds(TTFF_MILLIS));
            mFirstFixReceived = true;
        }
        while (mIsActive == true) {
            auto svStatus = filterBlocklistedSatellites(Utils::getMockSvInfoList());
            this->reportSvStatus(svStatus);
            this->reportSvStatus();

            auto currentLocation = getLocationFromHW();
            mGnssPowerIndication->notePowerConsumption();
@@ -124,6 +122,13 @@ void Gnss::reportLocation(const GnssLocation& location) const {
    return;
}

void Gnss::reportSvStatus() const {
    if (mIsSvStatusActive) {
        auto svStatus = filterBlocklistedSatellites(Utils::getMockSvInfoList());
        reportSvStatus(svStatus);
    }
}

void Gnss::reportSvStatus(const std::vector<GnssSvInfo>& svInfoList) const {
    std::unique_lock<std::mutex> lock(mMutex);
    if (sGnssCallback == nullptr) {
@@ -136,7 +141,8 @@ void Gnss::reportSvStatus(const std::vector<GnssSvInfo>& svInfoList) const {
    }
}

std::vector<GnssSvInfo> Gnss::filterBlocklistedSatellites(std::vector<GnssSvInfo> gnssSvInfoList) {
std::vector<GnssSvInfo> Gnss::filterBlocklistedSatellites(
        std::vector<GnssSvInfo> gnssSvInfoList) const {
    ALOGD("filterBlocklistedSatellites");
    for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) {
        if (mGnssConfiguration->isBlocklisted(gnssSvInfoList[i])) {
@@ -168,6 +174,26 @@ ScopedAStatus Gnss::stop() {
    return ScopedAStatus::ok();
}

ScopedAStatus Gnss::startSvStatus() {
    ALOGD("startSvStatus");
    mIsSvStatusActive = true;
    return ScopedAStatus::ok();
}

ScopedAStatus Gnss::stopSvStatus() {
    ALOGD("stopSvStatus");
    mIsSvStatusActive = false;
    return ScopedAStatus::ok();
}
ScopedAStatus Gnss::startNmea() {
    ALOGD("startNmea");
    return ScopedAStatus::ok();
}
ScopedAStatus Gnss::stopNmea() {
    ALOGD("stopNmea");
    return ScopedAStatus::ok();
}

ScopedAStatus Gnss::close() {
    ALOGD("close");
    sGnssCallback = nullptr;
+7 −1
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ class Gnss : public BnGnss {
    ndk::ScopedAStatus injectBestLocation(const GnssLocation& location) override;
    ndk::ScopedAStatus deleteAidingData(GnssAidingData aidingDataFlags) override;
    ndk::ScopedAStatus setPositionMode(const PositionModeOptions& options) override;
    ndk::ScopedAStatus startSvStatus() override;
    ndk::ScopedAStatus stopSvStatus() override;
    ndk::ScopedAStatus startNmea() override;
    ndk::ScopedAStatus stopNmea() override;

    ndk::ScopedAStatus getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) override;
    ndk::ScopedAStatus getExtensionGnssConfiguration(
@@ -83,9 +87,10 @@ class Gnss : public BnGnss {

  private:
    void reportLocation(const GnssLocation&) const;
    void reportSvStatus() const;
    void reportSvStatus(const std::vector<IGnssCallback::GnssSvInfo>& svInfoList) const;
    std::vector<IGnssCallback::GnssSvInfo> filterBlocklistedSatellites(
            std::vector<IGnssCallback::GnssSvInfo> gnssSvInfoList);
            std::vector<IGnssCallback::GnssSvInfo> gnssSvInfoList) const;
    void reportGnssStatusValue(const IGnssCallback::GnssStatusValue gnssStatusValue) const;
    std::unique_ptr<GnssLocation> getLocationFromHW();

@@ -93,6 +98,7 @@ class Gnss : public BnGnss {

    std::atomic<long> mMinIntervalMs;
    std::atomic<bool> mIsActive;
    std::atomic<bool> mIsSvStatusActive;
    std::atomic<bool> mFirstFixReceived;
    std::thread mThread;

Loading