Add code to convert a CarDiagnosticEvent into Diagnostic Json

Test: runtest -x packages/services/Car/tests/carservice_test/src/com/android/car/test/CarDiagnosticManagerTest.java
      runtest -x packages/services/Car/tests/obd2_test/src/com/android/car/obd2/test/Obd2LiveFrameGeneratorTest.java
Change-Id: I3e20ed08566161763933aa6c35b1f7aa7c2feca2
diff --git a/vehicle-hal-support-lib/src/com/android/car/vehiclehal/DiagnosticJson.java b/vehicle-hal-support-lib/src/com/android/car/vehiclehal/DiagnosticJson.java
index 25fdfdf..6936f22 100644
--- a/vehicle-hal-support-lib/src/com/android/car/vehiclehal/DiagnosticJson.java
+++ b/vehicle-hal-support-lib/src/com/android/car/vehiclehal/DiagnosticJson.java
@@ -26,14 +26,14 @@
 import java.util.Optional;
 
 public class DiagnosticJson {
-    public final int type;
+    public final String type;
     public final long timestamp;
     public final SparseArray<Integer> intValues;
     public final SparseArray<Float> floatValues;
     public final String dtc;
 
     DiagnosticJson(
-            int type,
+            String type,
             long timestamp,
             SparseArray<Integer> intValues,
             SparseArray<Float> floatValues,
@@ -81,7 +81,7 @@
             }
         }
 
-        final WriteOnce<Integer> mType = new WriteOnce<>();
+        final WriteOnce<String> mType = new WriteOnce<>();
         final WriteOnce<Long> mTimestamp = new WriteOnce<>();
         final SparseArray<Integer> mIntValues = new SparseArray<>();
         final SparseArray<Float> mFloatValues = new SparseArray<>();
@@ -119,12 +119,11 @@
 
         Builder(JsonReader jsonReader) throws IOException {
             jsonReader.beginObject();
-            long timestamp = 0;
             while (jsonReader.hasNext()) {
                 String name = jsonReader.nextName();
                 switch (name) {
                     case "type":
-                        mType.write(jsonReader.nextInt());
+                        mType.write(jsonReader.nextString());
                         break;
                     case "timestamp":
                         mTimestamp.write(jsonReader.nextLong());
@@ -153,9 +152,9 @@
             return new DiagnosticJson(
                     mType.get(), mTimestamp.get(), mIntValues, mFloatValues, mDtc.get(null));
         }
+    }
 
-        public static DiagnosticJson build(JsonReader jsonReader) throws IOException {
-            return new Builder(jsonReader).build();
-        }
+    public static DiagnosticJson build(JsonReader jsonReader) throws IOException {
+        return new Builder(jsonReader).build();
     }
 }