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

Commit cd180980 authored by Jing Ji's avatar Jing Ji
Browse files

Do not use the global AMS lock in AppExitInfoTracker

It could be called with global WMS lock held.

Bug: 150770486
Test: atest FlickerTests
Test: atest ApplicationExitInfoTest
Test: atest CtsAppExitTestCases:ActivityManagerAppExitInfoTest
Change-Id: Ic94fdbf4f8718245f5b0f25c41a2596a16841b0e
parent 7d5b7a6e
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public final class AppExitInfoTracker {
    private final ProcessMap<AppExitInfoContainer> mData;

    /** A pool of raw {@link android.app.ApplicationExitInfo} records. */
    @GuardedBy("mService")
    @GuardedBy("mLock")
    private final SynchronizedPool<ApplicationExitInfo> mRawRecordsPool;

    /**
@@ -204,8 +204,7 @@ public final class AppExitInfoTracker {
        });
    }

    @GuardedBy("mService")
    void scheduleNoteProcessDiedLocked(final ProcessRecord app) {
    void scheduleNoteProcessDied(final ProcessRecord app) {
        if (app == null || app.info == null) {
            return;
        }
@@ -214,12 +213,10 @@ public final class AppExitInfoTracker {
            if (!mAppExitInfoLoaded) {
                return;
            }
        }
        // The current thread is holding the global lock, let's extract the info from it
        // and schedule the info note task in the kill handler.
            mKillHandler.obtainMessage(KillHandler.MSG_PROC_DIED, obtainRawRecordLocked(app))
                    .sendToTarget();
        }
    }

    void scheduleNoteAppKill(final ProcessRecord app, final @Reason int reason,
            final @SubReason int subReason, final String msg) {
@@ -227,8 +224,6 @@ public final class AppExitInfoTracker {
            if (!mAppExitInfoLoaded) {
                return;
            }
        }
        synchronized (mService) {
            if (app == null || app.info == null) {
                return;
            }
@@ -247,8 +242,6 @@ public final class AppExitInfoTracker {
            if (!mAppExitInfoLoaded) {
                return;
            }
        }
        synchronized (mService) {
            ProcessRecord app;
            synchronized (mService.mPidsSelfLocked) {
                app = mService.mPidsSelfLocked.get(pid);
@@ -823,7 +816,7 @@ public final class AppExitInfoTracker {
    }

    @VisibleForTesting
    @GuardedBy("mService")
    @GuardedBy("mLock")
    ApplicationExitInfo obtainRawRecordLocked(ProcessRecord app) {
        ApplicationExitInfo info = mRawRecordsPool.acquire();
        if (info == null) {
@@ -850,7 +843,7 @@ public final class AppExitInfoTracker {
    }

    @VisibleForTesting
    @GuardedBy("mService")
    @GuardedBy("mLock")
    void recycleRawRecordLocked(ApplicationExitInfo info) {
        info.setProcessName(null);
        info.setDescription(null);
@@ -1135,8 +1128,6 @@ public final class AppExitInfoTracker {
                    ApplicationExitInfo raw = (ApplicationExitInfo) msg.obj;
                    synchronized (mLock) {
                        handleNoteProcessDiedLocked(raw);
                    }
                    synchronized (mService) {
                        recycleRawRecordLocked(raw);
                    }
                }
@@ -1145,8 +1136,6 @@ public final class AppExitInfoTracker {
                    ApplicationExitInfo raw = (ApplicationExitInfo) msg.obj;
                    synchronized (mLock) {
                        handleNoteAppKillLocked(raw);
                    }
                    synchronized (mService) {
                        recycleRawRecordLocked(raw);
                    }
                }
+1 −1
Original line number Diff line number Diff line
@@ -3773,7 +3773,7 @@ public final class ProcessList {
        }

        Watchdog.getInstance().processDied(app.processName, app.pid);
        mAppExitInfoTracker.scheduleNoteProcessDiedLocked(app);
        mAppExitInfoTracker.scheduleNoteProcessDied(app);
    }

    /**