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

Commit 03daee63 authored by Conley Owens's avatar Conley Owens Committed by Android Code Review
Browse files

Merge "frameworks/base: acquire lock on am only when needed"

parents 2f463ef1 68a4e0a3
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -6734,18 +6734,25 @@ public final class ActivityManagerService extends ActivityManagerNative
     * to append various headers to the dropbox log text.
     */
    private void appendDropBoxProcessHeaders(ProcessRecord process, StringBuilder sb) {
        // Watchdog thread ends up invoking this function (with
        // a null ProcessRecord) to add the stack file to dropbox.
        // Do not acquire a lock on this (am) in such cases, as it
        // could cause a potential deadlock, if and when watchdog
        // is invoked due to unavailability of lock on am and it
        // would prevent watchdog from killing system_server.
        if (process == null) {
            sb.append("Process: system_server\n");
            return;
        }
        // Note: ProcessRecord 'process' is guarded by the service
        // instance.  (notably process.pkgList, which could otherwise change
        // concurrently during execution of this method)
        synchronized (this) {
            if (process == null || process.pid == MY_PID) {
            if (process.pid == MY_PID) {
                sb.append("Process: system_server\n");
            } else {
                sb.append("Process: ").append(process.processName).append("\n");
            }
            if (process == null) {
                return;
            }
            int flags = process.info.flags;
            IPackageManager pm = AppGlobals.getPackageManager();
            sb.append("Flags: 0x").append(Integer.toString(flags, 16)).append("\n");