Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99853d95 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Ensure we always de-duplicate groups on ProtoLog init

Flag: EXEMPT minor fix
Test: atest TracingTests
Change-Id: Ib69c7e0f8796cf1bdeff365b5021951daa5cc7a7
parent 1ef32e9b
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -70,16 +70,16 @@ public class ProtoLog {
        // directly to the generated tracing implementations.
        if (android.tracing.Flags.perfettoProtologTracing()) {
            synchronized (sInitLock) {
                final var allGroups = new HashSet<>(Arrays.stream(groups).toList());
                if (sProtoLogInstance != null) {
                    // The ProtoLog instance has already been initialized in this process
                    final var alreadyRegisteredGroups = sProtoLogInstance.getRegisteredGroups();
                    final var allGroups = new HashSet<>(alreadyRegisteredGroups);
                    allGroups.addAll(Arrays.stream(groups).toList());
                    groups = allGroups.toArray(new IProtoLogGroup[0]);
                    allGroups.addAll(alreadyRegisteredGroups);
                }

                try {
                    sProtoLogInstance = new UnprocessedPerfettoProtoLogImpl(groups);
                    sProtoLogInstance = new UnprocessedPerfettoProtoLogImpl(
                            allGroups.toArray(new IProtoLogGroup[0]));
                } catch (ServiceManager.ServiceNotFoundException e) {
                    throw new RuntimeException(e);
                }