Handle missing device serial in CtsXmlResultReporter.

Change-Id: Ie45a538d25717e822ac9612bbba7528e48277e1a
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index e8a3da8..3ae1f06 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -126,7 +126,8 @@
         mReportDir = new File(mReportDir, TimeUtil.getResultTimestamp());
         mReportDir.mkdirs();
         mStartTime = getTimestamp();
-        mDeviceSerial = buildInfo.getDeviceSerial();
+        mDeviceSerial = buildInfo.getDeviceSerial() == null ? "unknown_device" :
+                buildInfo.getDeviceSerial();
         logResult("Created result dir %s", mReportDir.getName());
     }
 
@@ -306,7 +307,7 @@
         for (Map.Entry<String, String> metricEntry : metricsCopy.entrySet()) {
             serializer.attribute(ns, metricEntry.getKey(), metricEntry.getValue());
         }
-        serializer.attribute(ns, "deviceID", getBuildInfo().getDeviceSerial());
+        serializer.attribute(ns, "deviceID", mDeviceSerial);
         serializer.endTag(ns, "BuildInfo");
 
         serializeFeatureInfo(serializer, featureData);