From 59ff6100d84c8bf64311afdf981c531aa03bbbf5 Mon Sep 17 00:00:00 2001 From: Kajetan Puchalski Date: Wed, 2 Aug 2023 16:39:04 +0100 Subject: [PATCH] utils.rendering: Fix activity matching Change the SurfaceFlingerFrameCollector to match activities by prefix instead of looking for an exact match. This will allow to account for activities with variable suffixes. Raise an error if more than one activity matches the provided view. Show a warning if no activities match the provided view in order to avoid silently failing. Suggested-by: Andriani Mappoura Signed-off-by: Kajetan Puchalski --- devlib/utils/rendering.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/devlib/utils/rendering.py b/devlib/utils/rendering.py index e66dd8c..3df82d6 100644 --- a/devlib/utils/rendering.py +++ b/devlib/utils/rendering.py @@ -131,9 +131,18 @@ class SurfaceFlingerFrameCollector(FrameCollector): self.header = header or SurfaceFlingerFrame._fields def collect_frames(self, wfh): - for activity in self.list(): - if activity == self.view: - wfh.write(self.get_latencies(activity).encode('utf-8')) + activities = [a for a in self.list() if a.startswith(self.view)] + + if len(activities) > 1: + raise ValueError( + "More than one activity matching view '{}' was found: {}".format(self.view, activities) + ) + + if not activities: + logger.warning("No activities matching view '{}' were found".format(self.view)) + + for activity in activities: + wfh.write(self.get_latencies(activity).encode('utf-8')) def clear(self): self.target.execute('dumpsys SurfaceFlinger --latency-clear ')