Ensure out of sequence call on ProtoResultReporter doesn't crash

Avoid NPE if called out of sequence, handle it gracefully.

Test: unit tests
Bug: 159850199
Change-Id: I2a237173d7695570792f4b3877243c51f81bcdcb
diff --git a/src/com/android/tradefed/result/proto/ProtoResultReporter.java b/src/com/android/tradefed/result/proto/ProtoResultReporter.java
index f7119f3..5e70f63 100644
--- a/src/com/android/tradefed/result/proto/ProtoResultReporter.java
+++ b/src/com/android/tradefed/result/proto/ProtoResultReporter.java
@@ -483,6 +483,10 @@
 
     @Override
     public final void logAssociation(String dataName, LogFile logFile) {
+        if (mLatestChild == null || mLatestChild.isEmpty()) {
+            CLog.w("Skip logging '%s' logAssociation called out of sequence.", dataName);
+            return;
+        }
         TestRecord.Builder current = mLatestChild.peek();
         Map<String, Any> fullmap = new HashMap<>();
         fullmap.putAll(current.getArtifactsMap());