Work around incorrect dump at max count on RVC.

Bug: 185114787
Change-Id: I8b72e10089054e4954aceac23cab6d613af2c5a9
diff --git a/src/trace_processor/importers/proto/heap_profile_tracker.cc b/src/trace_processor/importers/proto/heap_profile_tracker.cc
index 8c86c85..951bb8c 100644
--- a/src/trace_processor/importers/proto/heap_profile_tracker.cc
+++ b/src/trace_processor/importers/proto/heap_profile_tracker.cc
@@ -177,9 +177,14 @@
     uint32_t merged_idx =
         callsite_to_merged_callsite[*callsites_tbl.id().IndexOf(
             CallsiteId(static_cast<uint32_t>(callsite_id)))];
-    if (count > 0) {
+    // On Android R, the count field is incorrectly set. As such, we cannot
+    // depend on count == 0 to imply size == 0, so we check for both of them
+    // separately. TODO(fmayer): Hide count on R builds.
+    if (size > 0) {
       tbl->mutable_alloc_size()->Set(merged_idx,
                                      tbl->alloc_size()[merged_idx] + size);
+    }
+    if (count > 0) {
       tbl->mutable_alloc_count()->Set(merged_idx,
                                       tbl->alloc_count()[merged_idx] + count);
     }