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

Commit 4a0a8322 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

RegisterWithPerfetto only from SystemUI main process

Subprocesses were getting frozen, and this caused perfetto to wait for
them indefinetely (hitting a timeout) when tracing for performance
monitoring began

Fix: 353317355
Test: Boot tests
Flag: NONE fix for perf regression
Change-Id: Icda2bb82a97a897aed5269f5336ea0393f00d9f7
parent 4232c17d
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Process;
@@ -81,7 +80,9 @@ public class SystemUIApplication extends Application implements

    public SystemUIApplication() {
        super();
        if (!isSubprocess()) {
            Trace.registerWithPerfetto();
        }
        Log.v(TAG, "SystemUIApplication constructed.");
        // SysUI may be building without protolog preprocessing in some cases
        ProtoLog.REQUIRE_PROTOLOGTOOL = false;
@@ -182,9 +183,7 @@ public class SystemUIApplication extends Application implements
        } else {
            // We don't need to startServices for sub-process that is doing some tasks.
            // (screenshots, sweetsweetdesserts or tuner ..)
            String processName = ActivityThread.currentProcessName();
            ApplicationInfo info = getApplicationInfo();
            if (processName != null && processName.startsWith(info.processName + ":")) {
            if (isSubprocess()) {
                return;
            }
            // For a secondary user, boot-completed will never be called because it has already
@@ -195,6 +194,12 @@ public class SystemUIApplication extends Application implements
        }
    }

    /** Returns whether this is a subprocess (e.g. com.android.systemui:screenshot) */
    private boolean isSubprocess() {
        String processName = ActivityThread.currentProcessName();
        return processName != null && processName.contains(":");
    }

    /**
     * Makes sure that all the CoreStartables are running. If they are already running, this is a
     * no-op. This is needed to conditionally start all the services, as we only need to have it in