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

Commit d73113e9 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Handle case where viewer config file is not found

In some tests this file isn't found we need to handle this. This is a temporary fix until we can properly handle reading these files from roboelectric.

Bug: 352290057

Bug: 353530422

Flag: EXEMPT bug fix
Change-Id: I370040117389f8b0a1c95ffd9fc7a1c797bf9b36
parent 305b2874
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.internal.protolog.common.IProtoLogGroup;
import com.android.internal.protolog.common.LogDataType;
import com.android.internal.protolog.common.LogLevel;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -100,6 +101,7 @@ public class PerfettoProtoLogImpl implements IProtoLog {
    );
    @Nullable
    private final ProtoLogViewerConfigReader mViewerConfigReader;
    @Nullable
    private final ViewerConfigInputStreamProvider mViewerConfigInputStreamProvider;
    private final TreeMap<String, IProtoLogGroup> mLogGroups = new TreeMap<>();
    private final Runnable mCacheUpdater;
+10 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.internal.protolog.common.IProtoLogGroup;
import com.android.internal.protolog.common.LogLevel;
import com.android.internal.protolog.common.ProtoLogToolInjected;

import java.io.File;
import java.util.TreeMap;

/**
@@ -105,7 +106,15 @@ public class ProtoLogImpl {
    public static synchronized IProtoLog getSingleInstance() {
        if (sServiceInstance == null) {
            if (android.tracing.Flags.perfettoProtologTracing()) {
                File f = new File(sViewerConfigPath);
                if (!ProtoLog.REQUIRE_PROTOLOGTOOL && !f.exists()) {
                    // TODO(b/353530422): Remove - temporary fix to unblock b/352290057
                    // In so tests the viewer config file might not exist in which we don't
                    // want to provide config path to the user
                    sServiceInstance = new PerfettoProtoLogImpl(null, null, sCacheUpdater);
                } else {
                    sServiceInstance = new PerfettoProtoLogImpl(sViewerConfigPath, sCacheUpdater);
                }
            } else {
                sServiceInstance = new LegacyProtoLogImpl(
                        sLegacyOutputFilePath, sLegacyViewerConfigPath, sCacheUpdater);