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

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

Move the app exit handler to a new thread

Previously the handler was sharing the same thread with LmkdConnection
which takes care of receiving incoming data from lmkd; in case there
is any lock contention, the lmkd communication would get wedged.

Bug: 148387160
Test: atest ApplicationExitInfoTest
Test: atest CtsAppExitTestCases:ActivityManagerAppExitInfoTest
Change-Id: Ifc0aacec0e64e1d920ae61e65eef94ea9e3b1828
parent 291d7350
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.am;

import static android.app.ActivityManager.RunningAppProcessInfo.procStateToImportance;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;

import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROCESSES;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
@@ -52,6 +53,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ProcessMap;
import com.android.server.IoThread;
import com.android.server.ServiceThread;
import com.android.server.SystemServiceManager;

import java.io.File;
@@ -179,9 +181,12 @@ public final class AppExitInfoTracker {
        mRawRecordsPool = new SynchronizedPool<ApplicationExitInfo>(APP_EXIT_RAW_INFO_POOL_SIZE);
    }

    void init(ActivityManagerService service, Looper looper) {
    void init(ActivityManagerService service) {
        mService = service;
        mKillHandler = new KillHandler(looper);
        ServiceThread thread = new ServiceThread(TAG + ":killHandler",
                THREAD_PRIORITY_BACKGROUND, true /* allowIo */);
        thread.start();
        mKillHandler = new KillHandler(thread.getLooper());
        mProcExitInfoFile = new File(SystemServiceManager.ensureSystemDir(), APP_EXIT_INFO_FILE);

        mAppExitInfoHistoryListSize = service.mContext.getResources().getInteger(
+1 −1
Original line number Diff line number Diff line
@@ -739,7 +739,7 @@ public final class ProcessList {
                        mSystemServerSocketForZygote.getFileDescriptor(),
                        EVENT_INPUT, this::handleZygoteMessages);
            }
            mAppExitInfoTracker.init(mService, sKillThread.getLooper());
            mAppExitInfoTracker.init(mService);
            mImperceptibleKillRunner = new ImperceptibleKillRunner(sKillThread.getLooper());
        }
    }