Check gnssPowerStats increase after getting a location
Bug: 168123084
Test: on device
Change-Id: I5a306f91d1223cdc9f3616583d59cd2c707c80ea
diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp
index 435afa3..6061eec 100644
--- a/gnss/aidl/default/Gnss.cpp
+++ b/gnss/aidl/default/Gnss.cpp
@@ -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::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();
}
diff --git a/gnss/aidl/default/Gnss.h b/gnss/aidl/default/Gnss.h
index bccc7f2..76ebe4d 100644
--- a/gnss/aidl/default/Gnss.h
+++ b/gnss/aidl/default/Gnss.h
@@ -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 @@
std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) override;
std::shared_ptr<GnssConfiguration> mGnssConfiguration;
+ std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;
private:
static std::shared_ptr<IGnssCallback> sGnssCallback;
diff --git a/gnss/aidl/default/GnssHidlHal.cpp b/gnss/aidl/default/GnssHidlHal.cpp
index 9529ec9..263715c 100644
--- a/gnss/aidl/default/GnssHidlHal.cpp
+++ b/gnss/aidl/default/GnssHidlHal.cpp
@@ -31,11 +31,19 @@
} 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 @@
return gnssSvInfoList;
}
+void GnssHidlHal::notePowerConsumption() {
+ mGnssPowerIndicationAidl->notePowerConsumption();
+}
+
} // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/GnssHidlHal.h b/gnss/aidl/default/GnssHidlHal.h
index 93a79a1..5fb4f97 100644
--- a/gnss/aidl/default/GnssHidlHal.h
+++ b/gnss/aidl/default/GnssHidlHal.h
@@ -32,9 +32,11 @@
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
diff --git a/gnss/aidl/default/GnssPowerIndication.cpp b/gnss/aidl/default/GnssPowerIndication.cpp
index 429cc8c..4dec1c6 100644
--- a/gnss/aidl/default/GnssPowerIndication.cpp
+++ b/gnss/aidl/default/GnssPowerIndication.cpp
@@ -50,13 +50,19 @@
};
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
diff --git a/gnss/aidl/default/GnssPowerIndication.h b/gnss/aidl/default/GnssPowerIndication.h
index e32fd72..93ca0b7 100644
--- a/gnss/aidl/default/GnssPowerIndication.h
+++ b/gnss/aidl/default/GnssPowerIndication.h
@@ -26,12 +26,16 @@
const std::shared_ptr<IGnssPowerIndicationCallback>& callback) override;
ndk::ScopedAStatus requestGnssPowerStats() override;
+ void notePowerConsumption();
+
private:
// Guarded by mMutex
static std::shared_ptr<IGnssPowerIndicationCallback> sCallback;
// Synchronization lock for sCallback
mutable std::mutex mMutex;
+
+ int numLocationReported;
};
} // namespace aidl::android::hardware::gnss