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

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

Merge "Check gnssPowerStats increase after getting a location" into sc-dev

parents 98d71e7f 669be841
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <log/log.h>
#include "GnssConfiguration.h"
#include "GnssMeasurementInterface.h"
#include "GnssPowerIndication.h"
#include "GnssPsds.h"

namespace aidl::android::hardware::gnss {
@@ -73,8 +72,11 @@ ndk::ScopedAStatus Gnss::getExtensionGnssConfiguration(
ndk::ScopedAStatus Gnss::getExtensionGnssPowerIndication(
        std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) {
    ALOGD("Gnss::getExtensionGnssPowerIndication");
    if (mGnssPowerIndication == nullptr) {
        mGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
    }

    *iGnssPowerIndication = SharedRefBase::make<GnssPowerIndication>();
    *iGnssPowerIndication = mGnssPowerIndication;
    return ndk::ScopedAStatus::ok();
}

+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <aidl/android/hardware/gnss/BnGnssPowerIndication.h>
#include <aidl/android/hardware/gnss/BnGnssPsds.h>
#include "GnssConfiguration.h"
#include "GnssPowerIndication.h"

namespace aidl::android::hardware::gnss {

@@ -38,6 +39,7 @@ class Gnss : public BnGnss {
            std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) override;

    std::shared_ptr<GnssConfiguration> mGnssConfiguration;
    std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;

  private:
    static std::shared_ptr<IGnssCallback> sGnssCallback;
+13 −1
Original line number Diff line number Diff line
@@ -31,11 +31,19 @@ GnssHidlHal::GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl) : mGnssAidl(gnss
    } else {
        mGnssConfigurationAidl = iGnss->mGnssConfiguration;
    }

    std::shared_ptr<IGnssPowerIndication> iGnssPowerIndication;
    status = iGnss->getExtensionGnssPowerIndication(&iGnssPowerIndication);
    if (!status.isOk()) {
        ALOGE("Failed to getExtensionGnssPowerIndication.");
    } else {
        mGnssPowerIndicationAidl = iGnss->mGnssPowerIndication;
    }
};

hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1(
        hidl_vec<GnssSvInfo> gnssSvInfoList) {
    ALOGD("filterBlocklistSatellitesV2_1 - overridden by GnssHidlHal class");
    ALOGD("GnssHidlHal::filterBlocklistSatellitesV2_1");
    if (mGnssConfigurationAidl == nullptr) {
        ALOGE("Handle to AIDL GnssConfiguration is not available.");
        return gnssSvInfoList;
@@ -51,4 +59,8 @@ hidl_vec<GnssSvInfo> GnssHidlHal::filterBlocklistedSatellitesV2_1(
    return gnssSvInfoList;
}

void GnssHidlHal::notePowerConsumption() {
    mGnssPowerIndicationAidl->notePowerConsumption();
}

}  // namespace aidl::android::hardware::gnss
+2 −0
Original line number Diff line number Diff line
@@ -32,9 +32,11 @@ class GnssHidlHal : public ::android::hardware::gnss::common::implementation::Gn
    filterBlocklistedSatellitesV2_1(
            hidl_vec<::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList)
            override;
    void notePowerConsumption() override;

    std::shared_ptr<Gnss> mGnssAidl;
    std::shared_ptr<GnssConfiguration> mGnssConfigurationAidl;
    std::shared_ptr<GnssPowerIndication> mGnssPowerIndicationAidl;
};

}  // namespace aidl::android::hardware::gnss
+9 −3
Original line number Diff line number Diff line
@@ -50,13 +50,19 @@ ndk::ScopedAStatus GnssPowerIndication::requestGnssPowerStats() {
    };
    GnssPowerStats gnssPowerStats = {
            .elapsedRealtime = elapsedRealtime,
            .totalEnergyMilliJoule = 1.59975e+3,
            .singlebandTrackingModeEnergyMilliJoule = 1.2342e+3,
            .multibandTrackingModeEnergyMilliJoule = 3.653e+2,
            .totalEnergyMilliJoule = 1.500e+3 + numLocationReported * 22.0,
            .singlebandTrackingModeEnergyMilliJoule = 0.0,
            .multibandTrackingModeEnergyMilliJoule = 1.28e+2 + numLocationReported * 4.0,
            .singlebandAcquisitionModeEnergyMilliJoule = 0.0,
            .multibandAcquisitionModeEnergyMilliJoule = 3.65e+2 + numLocationReported * 15.0,
            .otherModesEnergyMilliJoule = {1.232e+2, 3.234e+3},
    };
    sCallback->gnssPowerStatsCb(gnssPowerStats);
    return ndk::ScopedAStatus::ok();
}

void GnssPowerIndication::notePowerConsumption() {
    numLocationReported++;
}

}  // namespace aidl::android::hardware::gnss
Loading