Add kernel version to incident report

Bug: 110230810
Test: atest incidentd_test
Change-Id: I502b34f23d61a7346d79ff0dc378add8461d2d27
diff --git a/cmds/incident_helper/src/main.cpp b/cmds/incident_helper/src/main.cpp
index 418dc3f..5b6ac7af 100644
--- a/cmds/incident_helper/src/main.cpp
+++ b/cmds/incident_helper/src/main.cpp
@@ -73,7 +73,8 @@
         case 2006:
             return new BatteryTypeParser();
         default:
-            return NULL;
+            // Return no op parser when no specific ones are implemented.
+            return new NoopParser();
     }
 }
 
diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp
index e305b54..e92cf94 100644
--- a/cmds/incidentd/src/IncidentService.cpp
+++ b/cmds/incidentd/src/IncidentService.cpp
@@ -314,6 +314,19 @@
             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::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;
diff --git a/core/proto/android/os/incident.proto b/core/proto/android/os/incident.proto
index 1d299f5..5f6b6cc 100644
--- a/core/proto/android/os/incident.proto
+++ b/core/proto/android/os/incident.proto
@@ -71,6 +71,12 @@
         (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,
diff --git a/tools/incident_section_gen/main.cpp b/tools/incident_section_gen/main.cpp
index 1f77719..639f980 100644
--- a/tools/incident_section_gen/main.cpp
+++ b/tools/incident_section_gen/main.cpp
@@ -110,9 +110,7 @@
     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 @@
     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 @@
         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");