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

Commit c07948e5 authored by PODISHETTY KUMAR's avatar PODISHETTY KUMAR Committed by Android (Google) Code Review
Browse files

Merge "Revert "trace-ipc: Don't hold procLock while calling out."" into main

parents 6f501626 2caf6f9f
Loading
Loading
Loading
Loading
+29 −41
Original line number Diff line number Diff line
@@ -18368,34 +18368,21 @@ public class ActivityManagerService extends IActivityManager.Stub
        boolean closeFd = true;
        try {
            Objects.requireNonNull(fd);
            record ProcessToDump(String processName, IApplicationThread thread) { }
            synchronized (mProcLock) {
                if (fd == null) {
                    throw new IllegalArgumentException("null fd");
                }
                mBinderTransactionTrackingEnabled = false;
                PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor()));
                pw.println("Binder transaction traces for all processes.\n");
            final ArrayList<ProcessToDump> processes = new ArrayList<>();
            synchronized (mProcLock) {
                // Since dumping binder transactions is a long-running operation, we can't do it
                // with mProcLock held. Do the initial verification here, and save the processes
                // to dump later outside the lock.
                final ArrayList<ProcessRecord> unverifiedProcesses =
                        new ArrayList<>(mProcessList.getLruProcessesLOSP());
                for (int i = 0, size = unverifiedProcesses.size(); i < size; i++) {
                    ProcessRecord process = unverifiedProcesses.get(i);
                mProcessList.forEachLruProcessesLOSP(true, process -> {
                    final IApplicationThread thread = process.getThread();
                    if (!processSanityChecksLPr(process, thread)) {
                        continue;
                    }
                    processes.add(new ProcessToDump(process.processName, process.getThread()));
                }
                mBinderTransactionTrackingEnabled = false;
                        return;
                    }
            for (int i = 0, size = processes.size(); i < size; i++) {
                final String processName = processes.get(i).processName();
                final IApplicationThread thread = processes.get(i).thread();
                pw.println("Traces for process: " + processName);
                    pw.println("Traces for process: " + process.processName);
                    pw.flush();
                    try {
                        TransferPipe tp = new TransferPipe();
@@ -18406,17 +18393,18 @@ public class ActivityManagerService extends IActivityManager.Stub
                            tp.kill();
                        }
                    } catch (IOException e) {
                    pw.println("Failure while dumping IPC traces from " + processName +
                        pw.println("Failure while dumping IPC traces from " + process +
                                ".  Exception: " + e);
                        pw.flush();
                    } catch (RemoteException e) {
                        pw.println("Got a RemoteException while dumping IPC traces from " +
                            processName + ".  Exception: " + e);
                                process + ".  Exception: " + e);
                        pw.flush();
                    }
            }
                });
                closeFd = false;
                return true;
            }
        } finally {
            if (fd != null && closeFd) {
                try {