incidentd can now handle multiple callers asking it for incident reports
Test: bit incident_test:* GtsIncidentManagerTestCases:*
Bug: 123543706
Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index a6699e7..286e76e 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -407,12 +407,12 @@
outData->clear();
outData->resize(proto.size());
size_t pos = 0;
- auto iter = proto.data();
- while (iter.readBuffer() != NULL) {
- size_t toRead = iter.currentToRead();
- std::memcpy(&((*outData)[pos]), iter.readBuffer(), toRead);
+ sp<android::util::ProtoReader> reader = proto.data();
+ while (reader->readBuffer() != NULL) {
+ size_t toRead = reader->currentToRead();
+ std::memcpy(&((*outData)[pos]), reader->readBuffer(), toRead);
pos += toRead;
- iter.rp()->move(toRead);
+ reader->move(toRead);
}
}
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index f78ae38..52ecdc8 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -50,6 +50,7 @@
using android::util::FIELD_COUNT_REPEATED;
using android::util::FIELD_TYPE_INT64;
using android::util::FIELD_TYPE_MESSAGE;
+using android::util::ProtoReader;
namespace android {
namespace os {
@@ -1220,12 +1221,12 @@
experimentIdsProtoBuffer.resize(proto.size());
size_t pos = 0;
- auto iter = proto.data();
- while (iter.readBuffer() != NULL) {
- size_t toRead = iter.currentToRead();
- std::memcpy(&(experimentIdsProtoBuffer[pos]), iter.readBuffer(), toRead);
+ sp<ProtoReader> reader = proto.data();
+ while (reader->readBuffer() != NULL) {
+ size_t toRead = reader->currentToRead();
+ std::memcpy(&(experimentIdsProtoBuffer[pos]), reader->readBuffer(), toRead);
pos += toRead;
- iter.rp()->move(toRead);
+ reader->move(toRead);
}
}
diff --git a/cmds/statsd/src/external/GpuStatsPuller.cpp b/cmds/statsd/src/external/GpuStatsPuller.cpp
index 130bd85..3fa932f 100644
--- a/cmds/statsd/src/external/GpuStatsPuller.cpp
+++ b/cmds/statsd/src/external/GpuStatsPuller.cpp
@@ -29,6 +29,8 @@
namespace os {
namespace statsd {
+using android::util::ProtoReader;
+
GpuStatsPuller::GpuStatsPuller(const int tagId) : StatsPuller(tagId) {
}
@@ -116,11 +118,11 @@
if (!proto.size()) return "";
std::string byteString;
- auto iter = proto.data();
- while (iter.readBuffer() != nullptr) {
- const size_t toRead = iter.currentToRead();
- byteString.append((char*)iter.readBuffer(), toRead);
- iter.rp()->move(toRead);
+ sp<ProtoReader> reader = proto.data();
+ while (reader->readBuffer() != nullptr) {
+ const size_t toRead = reader->currentToRead();
+ byteString.append((char*)reader->readBuffer(), toRead);
+ reader->move(toRead);
}
if (byteString.size() != proto.size()) return "";
diff --git a/cmds/statsd/src/guardrail/StatsdStats.cpp b/cmds/statsd/src/guardrail/StatsdStats.cpp
index 9a00637..24408fc 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.cpp
+++ b/cmds/statsd/src/guardrail/StatsdStats.cpp
@@ -904,12 +904,12 @@
output->resize(bufferSize);
size_t pos = 0;
- auto it = proto.data();
- while (it.readBuffer() != NULL) {
- size_t toRead = it.currentToRead();
- std::memcpy(&((*output)[pos]), it.readBuffer(), toRead);
+ sp<android::util::ProtoReader> reader = proto.data();
+ while (reader->readBuffer() != NULL) {
+ size_t toRead = reader->currentToRead();
+ std::memcpy(&((*output)[pos]), reader->readBuffer(), toRead);
pos += toRead;
- it.rp()->move(toRead);
+ reader->move(toRead);
}
if (reset) {
diff --git a/cmds/statsd/src/metrics/EventMetricProducer.cpp b/cmds/statsd/src/metrics/EventMetricProducer.cpp
index 5435c84..69816cb 100644
--- a/cmds/statsd/src/metrics/EventMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/EventMetricProducer.cpp
@@ -90,12 +90,12 @@
std::unique_ptr<std::vector<uint8_t>> buffer(new std::vector<uint8_t>(bufferSize));
size_t pos = 0;
- auto it = protoOutput.data();
- while (it.readBuffer() != NULL) {
- size_t toRead = it.currentToRead();
- std::memcpy(&((*buffer)[pos]), it.readBuffer(), toRead);
+ sp<android::util::ProtoReader> reader = protoOutput.data();
+ while (reader->readBuffer() != NULL) {
+ size_t toRead = reader->currentToRead();
+ std::memcpy(&((*buffer)[pos]), reader->readBuffer(), toRead);
pos += toRead;
- it.rp()->move(toRead);
+ reader->move(toRead);
}
return buffer;
diff --git a/cmds/statsd/src/stats_log_util.h b/cmds/statsd/src/stats_log_util.h
index 59d4865..cdef874 100644
--- a/cmds/statsd/src/stats_log_util.h
+++ b/cmds/statsd/src/stats_log_util.h
@@ -80,11 +80,11 @@
template<class T>
bool parseProtoOutputStream(util::ProtoOutputStream& protoOutput, T* message) {
std::string pbBytes;
- auto iter = protoOutput.data();
- while (iter.readBuffer() != NULL) {
- size_t toRead = iter.currentToRead();
- pbBytes.append(reinterpret_cast<const char*>(iter.readBuffer()), toRead);
- iter.rp()->move(toRead);
+ sp<android::util::ProtoReader> reader = protoOutput.data();
+ while (reader->readBuffer() != NULL) {
+ size_t toRead = reader->currentToRead();
+ pbBytes.append(reinterpret_cast<const char*>(reader->readBuffer()), toRead);
+ reader->move(toRead);
}
return message->ParseFromArray(pbBytes.c_str(), pbBytes.size());
}
diff --git a/cmds/statsd/src/subscriber/IncidentdReporter.cpp b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
index 7c2d242..ff1cb4f 100644
--- a/cmds/statsd/src/subscriber/IncidentdReporter.cpp
+++ b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
@@ -120,12 +120,12 @@
protoData->resize(headerProto.size());
size_t pos = 0;
- auto iter = headerProto.data();
- while (iter.readBuffer() != NULL) {
- size_t toRead = iter.currentToRead();
- std::memcpy(&((*protoData)[pos]), iter.readBuffer(), toRead);
+ sp<android::util::ProtoReader> reader = headerProto.data();
+ while (reader->readBuffer() != NULL) {
+ size_t toRead = reader->currentToRead();
+ std::memcpy(&((*protoData)[pos]), reader->readBuffer(), toRead);
pos += toRead;
- iter.rp()->move(toRead);
+ reader->move(toRead);
}
}
} // namespace
@@ -152,15 +152,15 @@
uint8_t dest;
switch (config.dest()) {
case IncidentdDetails_Destination_AUTOMATIC:
- dest = android::os::DEST_AUTOMATIC;
+ dest = android::os::PRIVACY_POLICY_AUTOMATIC;
break;
case IncidentdDetails_Destination_EXPLICIT:
- dest = android::os::DEST_EXPLICIT;
+ dest = android::os::PRIVACY_POLICY_EXPLICIT;
break;
default:
- dest = android::os::DEST_AUTOMATIC;
+ dest = android::os::PRIVACY_POLICY_AUTOMATIC;
}
- incidentReport.setDest(dest);
+ incidentReport.setPrivacyPolicy(dest);
incidentReport.setReceiverPkg(config.receiver_pkg());