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
This commit is contained in:
Jing Ji
2020-01-31 14:16:07 -08:00
parent 291d7350e5
commit 37693445bc
2 changed files with 8 additions and 3 deletions

View File

@@ -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(

View File

@@ -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());
}
}