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

Commit 5d4de563 authored by Marcin Oczeretko's avatar Marcin Oczeretko
Browse files

Use different perfetto trigger names for each CUJ

Test: verified build
Bug: 167170986
Change-Id: I87f32358dd06f23da02b7efd8833958646fcc54c
parent 98bb82ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
     * Trigger the prefetto daemon.
     */
    public void triggerPerfetto() {
        InteractionJankMonitor.getInstance().trigger();
        InteractionJankMonitor.getInstance().trigger(mSession);
    }

    /**
+6 −3
Original line number Diff line number Diff line
@@ -319,11 +319,11 @@ public class InteractionJankMonitor {
     * Trigger the perfetto daemon to collect and upload data.
     */
    @VisibleForTesting
    public void trigger() {
    public void trigger(Session session) {
        synchronized (this) {
            if (!mInitialized) return;
            mWorker.getThreadHandler().post(
                    () -> PerfettoTrigger.trigger(PerfettoTrigger.TRIGGER_TYPE_JANK));
                    () -> PerfettoTrigger.trigger(session.getPerfettoTrigger()));
        }
    }

@@ -350,9 +350,12 @@ public class InteractionJankMonitor {
            return getStatsdInteractionType() != NO_STATSD_LOGGING;
        }

        public String getPerfettoTrigger() {
            return String.format("interaction-jank-monitor-%d", mCujType);
        }

        public String getName() {
            return "Cuj<" + getCuj() + ">";
        }
    }

}
+5 −47
Original line number Diff line number Diff line
@@ -17,15 +17,12 @@
//TODO (165884885): Make PerfettoTrigger more generic and move it to another package.
package com.android.internal.jank;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * A trigger implementation with perfetto backend.
@@ -35,23 +32,14 @@ public class PerfettoTrigger {
    private static final String TAG = PerfettoTrigger.class.getSimpleName();
    private static final boolean DEBUG = false;
    private static final String TRIGGER_COMMAND = "/system/bin/trigger_perfetto";
    private static final String[] TRIGGER_TYPE_NAMES = new String[] { "jank-tracker" };
    public static final int TRIGGER_TYPE_JANK = 0;

    /** @hide */
    @IntDef({
            TRIGGER_TYPE_JANK
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface TriggerType {}

    /**
     * @param type the trigger type
     * @param triggerName The name of the trigger. Must match the value defined in the AOT
     *                    Perfetto config.
     */
    public static void trigger(@NonNull @TriggerType int type) {
    public static void trigger(String triggerName) {
        try {
            Token token = new Token(type, TRIGGER_TYPE_NAMES[type]);
            ProcessBuilder pb = new ProcessBuilder(TRIGGER_COMMAND, token.getName());
            ProcessBuilder pb = new ProcessBuilder(TRIGGER_COMMAND, triggerName);
            if (DEBUG) {
                StringBuilder sb = new StringBuilder();
                for (String arg : pb.command()) {
@@ -64,7 +52,7 @@ public class PerfettoTrigger {
                readConsoleOutput(process);
            }
        } catch (IOException | InterruptedException e) {
            Log.w(TAG, "Failed to trigger " + type, e);
            Log.w(TAG, "Failed to trigger " + triggerName, e);
        }
    }

@@ -82,34 +70,4 @@ public class PerfettoTrigger {
            Log.d(TAG, "err message=" + errLine.toString());
        }
    }

    /**
     * Token which is used to trigger perfetto.
     */
    public static class Token {
        private int mType;
        private String mName;

        Token(@TriggerType int type, String name) {
            mType = type;
            mName = name;
        }

        /**
         * Get trigger type.
         * @return trigger type, should be @TriggerType
         */
        public int getType() {
            return mType;
        }

        /**
         * Get name of this token as the argument while triggering perfetto.
         * @return name
         */
        public String getName() {
            return mName;
        }
    }

}