"libplatformprotos",
],
+ product_variables: {
+ debuggable: {
+ cflags: ["-DALLOW_RESTRICTED_SECTIONS=1"],
+ },
+ },
+
+
init_rc: ["incidentd.rc"],
}
#include "section_list.h"
#include <android-base/file.h>
-#include <android-base/properties.h>
#include <android/os/DropBoxManager.h>
#include <android/util/protobuf.h>
#include <android/util/ProtoOutputStream.h>
IncidentMetadata metadata;
int persistedPrivacyPolicy = PRIVACY_POLICY_UNSET;
- std::string buildType = android::base::GetProperty("ro.build.type", "");
- const bool isUserdebugOrEng = buildType == "userdebug" || buildType == "eng";
(*reportByteSize) = 0;
for (const Section** section = SECTION_LIST; *section; section++) {
const int sectionId = (*section)->id;
- // If this section is too private for user builds, skip it.
- if ((*section)->userdebugAndEngOnly && !isUserdebugOrEng) {
- VLOG("Skipping incident report section %d '%s' because it's limited to userdebug/eng",
- sectionId, (*section)->name.string());
- continue;
- }
-
// If nobody wants this section, skip it.
if (!mBatch->containsSection(sectionId)) {
continue;
#include <set>
#include <android-base/file.h>
+#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android/util/protobuf.h>
#include <android/util/ProtoOutputStream.h>
}
// ================================================================================
-Section::Section(int i, int64_t timeoutMs, bool userdebugAndEngOnly)
+Section::Section(int i, int64_t timeoutMs)
: id(i),
- timeoutMs(timeoutMs),
- userdebugAndEngOnly(userdebugAndEngOnly) {}
+ timeoutMs(timeoutMs) {
+}
Section::~Section() {}
static inline bool isSysfs(const char* filename) { return strncmp(filename, "/sys/", 5) == 0; }
FileSection::FileSection(int id, const char* filename, const int64_t timeoutMs)
- : Section(id, timeoutMs, false), mFilename(filename) {
+ : Section(id, timeoutMs), mFilename(filename) {
name = "file ";
name += filename;
mIsSysfs = isSysfs(filename);
WorkerThreadData::~WorkerThreadData() {}
// ================================================================================
-WorkerThreadSection::WorkerThreadSection(int id, const int64_t timeoutMs, bool userdebugAndEngOnly)
- : Section(id, timeoutMs, userdebugAndEngOnly) {}
+WorkerThreadSection::WorkerThreadSection(int id, const int64_t timeoutMs)
+ : Section(id, timeoutMs) {}
WorkerThreadSection::~WorkerThreadSection() {}
}
// ================================================================================
-DumpsysSection::DumpsysSection(int id, bool userdebugAndEngOnly, const char* service, ...)
- : WorkerThreadSection(id, REMOTE_CALL_TIMEOUT_MS, userdebugAndEngOnly), mService(service) {
+DumpsysSection::DumpsysSection(int id, const char* service, ...)
+ : WorkerThreadSection(id, REMOTE_CALL_TIMEOUT_MS), mService(service) {
name = "dumpsys ";
name += service;
public:
const int id;
const int64_t timeoutMs; // each section must have a timeout
- const bool userdebugAndEngOnly;
String8 name;
- Section(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS, bool userdebugAndEngOnly = false);
+ Section(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS);
virtual ~Section();
virtual status_t Execute(ReportWriter* writer) const = 0;
*/
class WorkerThreadSection : public Section {
public:
- WorkerThreadSection(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS,
- bool userdebugAndEngOnly = false);
+ WorkerThreadSection(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS);
virtual ~WorkerThreadSection();
virtual status_t Execute(ReportWriter* writer) const;
*/
class DumpsysSection : public WorkerThreadSection {
public:
- DumpsysSection(int id, bool userdebugAndEngOnly, const char* service, ...);
+ DumpsysSection(int id, const char* service, ...);
virtual ~DumpsysSection();
virtual status_t BlockingCall(int pipeWriteFd) const;
};
/**
+ * Section that calls dumpsys on a system service.
+ */
+class SystemPropertyDumpsysSection : public WorkerThreadSection {
+public:
+ SystemPropertyDumpsysSection(int id, const char* service, ...);
+ virtual ~SystemPropertyDumpsysSection();
+
+ virtual status_t BlockingCall(int pipeWriteFd) const;
+
+private:
+ String16 mService;
+ Vector<String16> mArgs;
+};
+
+/**
* Section that reads from logd.
*/
class LogSection : public WorkerThreadSection {
for (int i=0; i<descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i);
- if (field->type() != FieldDescriptor::TYPE_MESSAGE && field->type() != FieldDescriptor::TYPE_STRING) {
+ if (field->type() != FieldDescriptor::TYPE_MESSAGE
+ && field->type() != FieldDescriptor::TYPE_STRING) {
continue;
}
+
const SectionFlags s = getSectionFlags(field);
+ if (s.userdebug_and_eng_only()) {
+ printf("#if ALLOW_RESTRICTED_SECTIONS\n");
+ }
+
switch (s.type()) {
case SECTION_NONE:
continue;
printf(" NULL),\n");
break;
case SECTION_DUMPSYS:
- printf(" new DumpsysSection(%d, %s,", field->number(),
- s.userdebug_and_eng_only() ? "true" : "false");
+ printf(" new DumpsysSection(%d, ", field->number());
splitAndPrint(s.args());
printf(" NULL),\n");
break;
printf(" NULL),\n");
break;
case SECTION_TOMBSTONE:
- printf(" new TombstoneSection(%d, \"%s\"),\n", field->number(), s.args().c_str());
+ printf(" new TombstoneSection(%d, \"%s\"),\n", field->number(),
+ s.args().c_str());
break;
}
+ if (s.userdebug_and_eng_only()) {
+ printf("#endif\n");
+ }
}
printf(" NULL };\n");