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

Commit 4567c1a1 authored by Mathieu Chartier's avatar Mathieu Chartier Committed by Android (Google) Code Review
Browse files

Merge "Enable profiling for system server for userdebug|eng" into oc-dev

parents af336394 b3eecebd
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -26,7 +26,9 @@ import android.icu.text.DecimalFormatSymbols;
import android.icu.util.ULocale;
import android.net.LocalServerSocket;
import android.opengl.EGL14;
import android.os.Build;
import android.os.IInstalld;
import android.os.Environment;
import android.os.Process;
import android.os.RemoteException;
import android.os.Seccomp;
@@ -60,6 +62,7 @@ import dalvik.system.ZygoteHooks;
import libcore.io.IoUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -457,6 +460,23 @@ public class ZygoteInit {
        final String systemServerClasspath = Os.getenv("SYSTEMSERVERCLASSPATH");
        if (systemServerClasspath != null) {
            performSystemServerDexOpt(systemServerClasspath);
            // Capturing profiles is only supported for debug or eng builds since selinux normally
            // prevents it.
            boolean profileSystemServer = SystemProperties.getBoolean(
                    "dalvik.vm.profilesystemserver", false);
            if (profileSystemServer && (Build.IS_USERDEBUG || Build.IS_ENG)) {
                try {
                    File profileDir = Environment.getDataProfilesDePackageDirectory(
                            Process.SYSTEM_UID, "system_server");
                    File profile = new File(profileDir, "primary.prof");
                    profile.getParentFile().mkdirs();
                    profile.createNewFile();
                    String[] codePaths = systemServerClasspath.split(":");
                    VMRuntime.registerAppInfo(profile.getPath(), codePaths);
                } catch (Exception e) {
                    Log.wtf(TAG, "Failed to set up system server profile", e);
                }
            }
        }

        if (parsedArgs.invokeWith != null) {