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

Commit 74e8d3be authored by Alex Light's avatar Alex Light Committed by Android (Google) Code Review
Browse files

Merge "Add agent startup-attach"

parents 099615b9 330e8be6
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -191,6 +191,8 @@ import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -6435,6 +6437,26 @@ public final class ActivityThread extends ClientTransactionHandler {
        NetworkSecurityConfigProvider.install(appContext);
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);


        if (isAppDebuggable) {
            try {
                // Load all the agents in the code_cache/startup_agents directory.
                // We pass the absolute path to the data_dir as an argument.
                Path startup_path = appContext.getCodeCacheDir().toPath().resolve("startup_agents");
                if (Files.exists(startup_path)) {
                    for (Path p : Files.newDirectoryStream(startup_path)) {
                        handleAttachAgent(
                                p.toAbsolutePath().toString()
                                + "="
                                + appContext.getDataDir().toPath().toAbsolutePath().toString(),
                                data.info);
                    }
                }
            } catch (Exception e) {
                // Ignored.
            }
        }

        // Continue loading instrumentation.
        if (ii != null) {
            ApplicationInfo instrApp;