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

Commit 82cde3ea authored by Chris Wailes's avatar Chris Wailes
Browse files

Change USAP name to application name as soon as possible.

This patch changes the location where the process's name is changed to
that of the application being launched.  It also attempts to use the
package name if the "nice name" is missing.

Test: m & flash & boot
Bug: 146614089
Change-Id: Id3a3d0b2b66d31c48274f8a986e86e9ed1d28f34
Merged-In: Id3a3d0b2b66d31c48274f8a986e86e9ed1d28f34
parent a32fcb74
Loading
Loading
Loading
Loading
+32 −25
Original line number Diff line number Diff line
@@ -568,6 +568,7 @@ public final class Zygote {
        try {
            // SIGTERM is blocked on loop exit.  This prevents a USAP that is specializing from
            // being killed during a pool flush.
            setAppProcessName(args, "USAP");

            applyUidSecurityPolicy(args, peerCredentials);
            applyDebuggerSystemProperty(args);
@@ -634,10 +635,6 @@ public final class Zygote {

            disableExecuteOnly(args.mTargetSdkVersion);

            if (args.mNiceName != null) {
                Process.setArgV0(args.mNiceName);
            }

            // End of the postFork event.
            Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

@@ -663,6 +660,16 @@ public final class Zygote {

    private static native void nativeUnblockSigTerm();

    static void setAppProcessName(ZygoteArguments args, String loggingTag) {
        if (args.mNiceName != null) {
            Process.setArgV0(args.mNiceName);
        } else if (args.mPackageName != null) {
            Process.setArgV0(args.mPackageName);
        } else {
            Log.w(loggingTag, "Unable to set package name.");
        }
    }

    private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: ";

    /**
+1 −3
Original line number Diff line number Diff line
@@ -485,9 +485,7 @@ class ZygoteConnection {

        closeSocket();

        if (parsedArgs.mNiceName != null) {
            Process.setArgV0(parsedArgs.mNiceName);
        }
        Zygote.setAppProcessName(parsedArgs, TAG);

        // End of the postFork event.
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);