Add kernel version to incident report

Bug: 110230810
Test: atest incidentd_test
Change-Id: I502b34f23d61a7346d79ff0dc378add8461d2d27
This commit is contained in:
Yi Jin
2018-06-22 16:51:40 -07:00
parent 6b1c5e923f
commit 908c02f5c1
4 changed files with 30 additions and 11 deletions

View File

@@ -73,7 +73,8 @@ static TextParserBase* selectParser(int section) {
case 2006:
return new BatteryTypeParser();
default:
return NULL;
// Return no op parser when no specific ones are implemented.
return new NoopParser();
}
}

View File

@@ -314,6 +314,19 @@ status_t IncidentService::command(FILE* in, FILE* out, FILE* err, Vector<String8
mThrottler->dump(out);
return NO_ERROR;
}
if (!args[0].compare(String8("section"))) {
int id = atoi(args[1]);
int idx = 0;
while (SECTION_LIST[idx] != NULL) {
const Section* section = SECTION_LIST[idx];
if (section->id == id) {
fprintf(out, "Section[%d] %s\n", id, section->name.string());
break;
}
idx++;
}
return NO_ERROR;
}
}
return cmd_help(out);
}
@@ -321,8 +334,9 @@ status_t IncidentService::command(FILE* in, FILE* out, FILE* err, Vector<String8
status_t IncidentService::cmd_help(FILE* out) {
fprintf(out, "usage: adb shell cmd incident privacy print <section_id>\n");
fprintf(out, "usage: adb shell cmd incident privacy parse <section_id> < proto.txt\n");
fprintf(out, " Prints/parses for the section id.\n");
fprintf(out, "\n");
fprintf(out, " Prints/parses for the section id.\n\n");
fprintf(out, "usage: adb shell cmd incident section <section_id>\n");
fprintf(out, " Prints section id and its name.\n\n");
fprintf(out, "usage: adb shell cmd incident throttler\n");
fprintf(out, " Prints the current throttler state\n");
return NO_ERROR;

View File

@@ -71,6 +71,12 @@ message IncidentProto {
(section).args = "getprop"
];
optional string kernel_version = 1002 [
(section).type = SECTION_FILE,
(section).args = "/proc/version",
(privacy).dest = DEST_AUTOMATIC
];
// Device Logs
optional android.util.EventLogTagMapProto event_log_tag_map = 1100 [
(section).type = SECTION_FILE,

View File

@@ -110,9 +110,7 @@ static bool generateIncidentSectionsCpp(Descriptor const* descriptor)
N = descriptor->field_count();
for (int i=0; i<N; i++) {
const FieldDescriptor* field = descriptor->field(i);
if (field->type() == FieldDescriptor::TYPE_MESSAGE) {
sections[field->name()] = field;
}
sections[field->name()] = field;
}
printf("IncidentSection const INCIDENT_SECTIONS[] = {\n");
@@ -404,7 +402,7 @@ static bool generateSectionListCpp(Descriptor const* descriptor) {
for (int i=0; i<descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i);
if (field->type() != FieldDescriptor::TYPE_MESSAGE) {
if (field->type() != FieldDescriptor::TYPE_MESSAGE && field->type() != FieldDescriptor::TYPE_STRING) {
continue;
}
const SectionFlags s = getSectionFlags(field);
@@ -456,13 +454,13 @@ static bool generateSectionListCpp(Descriptor const* descriptor) {
const FieldDescriptor* field = fieldsInOrder[i];
const string fieldName = getFieldName(field);
const Destination fieldDest = getFieldDest(field);
const string fieldMessageName = getMessageName(field->message_type(), fieldDest);
skip[i] = true;
if (field->type() != FieldDescriptor::TYPE_MESSAGE) {
printPrivacy(fieldName, field, "NULL", fieldDest, "NULL");
continue;
}
skip[i] = true;
const string fieldMessageName = getMessageName(field->message_type(), fieldDest);
// generate privacy flags for each section.
if (generatePrivacyFlags(field->message_type(), fieldDest, variableNames, &parents)) {
printPrivacy(fieldName, field, fieldMessageName, fieldDest, "NULL");