perf: Reduce NMEA traffic over client IPC
Improve hal daemon performance by reducing number of NMEA callbacks on IPC. Position and sv NMEA sentences, generated during one TBF will be concatenated by hal and sent over one IPC, then client lib disassemble it into multiple sentences. Change-Id: I522e293d7e26fb8a25edb6ed931c4d69186223e8 CRs-Fixed: 2299008
This commit is contained in:
parent
837f245997
commit
5b53be1d9e
3 changed files with 37 additions and 16 deletions
|
@ -469,13 +469,20 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
|
|||
mMutex.unlock();
|
||||
|
||||
if (gnssCbIface != nullptr) {
|
||||
android::hardware::hidl_string nmeaString;
|
||||
nmeaString.setToExternal(gnssNmeaNotification.nmea, gnssNmeaNotification.length);
|
||||
auto r = gnssCbIface->gnssNmeaCb(
|
||||
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
|
||||
if (!r.isOk()) {
|
||||
LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__,
|
||||
gnssNmeaNotification.nmea, gnssNmeaNotification.length, r.description().c_str());
|
||||
const std::string s(gnssNmeaNotification.nmea);
|
||||
std::stringstream ss(s);
|
||||
std::string each;
|
||||
while(std::getline(ss, each, '\n')) {
|
||||
each += '\n';
|
||||
android::hardware::hidl_string nmeaString;
|
||||
nmeaString.setToExternal(each.c_str(), each.length());
|
||||
auto r = gnssCbIface->gnssNmeaCb(
|
||||
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
|
||||
if (!r.isOk()) {
|
||||
LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__,
|
||||
gnssNmeaNotification.nmea, gnssNmeaNotification.length,
|
||||
r.description().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -469,13 +469,20 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
|
|||
mMutex.unlock();
|
||||
|
||||
if (gnssCbIface != nullptr) {
|
||||
android::hardware::hidl_string nmeaString;
|
||||
nmeaString.setToExternal(gnssNmeaNotification.nmea, gnssNmeaNotification.length);
|
||||
auto r = gnssCbIface->gnssNmeaCb(
|
||||
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
|
||||
if (!r.isOk()) {
|
||||
LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__,
|
||||
gnssNmeaNotification.nmea, gnssNmeaNotification.length, r.description().c_str());
|
||||
const std::string s(gnssNmeaNotification.nmea);
|
||||
std::stringstream ss(s);
|
||||
std::string each;
|
||||
while(std::getline(ss, each, '\n')) {
|
||||
each += '\n';
|
||||
android::hardware::hidl_string nmeaString;
|
||||
nmeaString.setToExternal(each.c_str(), each.length());
|
||||
auto r = gnssCbIface->gnssNmeaCb(
|
||||
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
|
||||
if (!r.isOk()) {
|
||||
LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__,
|
||||
gnssNmeaNotification.nmea, gnssNmeaNotification.length,
|
||||
r.description().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <netdb.h>
|
||||
#include <GnssAdapter.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <loc_log.h>
|
||||
#include <loc_nmea.h>
|
||||
#include <Agps.h>
|
||||
|
@ -2976,9 +2977,12 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
|
|||
uint8_t generate_nmea = (reported && status != LOC_SESS_FAILURE && !blank_fix);
|
||||
std::vector<std::string> nmeaArraystr;
|
||||
loc_nmea_generate_pos(ulpLocation, locationExtended, generate_nmea, nmeaArraystr);
|
||||
stringstream ss;
|
||||
for (auto sentence : nmeaArraystr) {
|
||||
reportNmea(sentence.c_str(), sentence.length());
|
||||
ss << sentence;
|
||||
}
|
||||
string s = ss.str();
|
||||
reportNmea(s.c_str(), s.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3069,9 +3073,12 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
|
|||
if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) {
|
||||
std::vector<std::string> nmeaArraystr;
|
||||
loc_nmea_generate_sv(svNotify, nmeaArraystr);
|
||||
stringstream ss;
|
||||
for (auto sentence : nmeaArraystr) {
|
||||
reportNmea(sentence.c_str(), sentence.length());
|
||||
ss << sentence;
|
||||
}
|
||||
string s = ss.str();
|
||||
reportNmea(s.c_str(), s.length());
|
||||
}
|
||||
|
||||
mGnssSvIdUsedInPosAvail = false;
|
||||
|
|
Loading…
Reference in a new issue