From 858ca2424b3e02243a731ddacb9eadb1f086481b Mon Sep 17 00:00:00 2001 From: Alan Stokes Date: Tue, 18 Feb 2020 13:25:43 +0000 Subject: [PATCH] Don't kill a new process for the sins of an old process. I have a test which instruments com.android.vending, which contains some content providers. Each test case starts the app and then fairly quickly kills it. I doubt it ever gets to the stage where the content providers are working. When the test runs slowly enough, a new instance of the app gets killed 10s after an old instance was started, which breaks things. That seems like the wrong behavior in general, although it should be rare. This change attempts to prevent that happening by cleaning up any old timeout messages for the app when we restart it. Bug: 149150665 Test: atest FrameworksCoreTests:android.content.ContentResolverTest Change-Id: I1b04eab6b0fd3d24c0a2ee315818d58de4c5915d --- .../java/com/android/server/am/ActivityManagerService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 9082807f6bbca..2dcd37f6f47a4 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -14605,6 +14605,11 @@ public class ActivityManagerService extends IActivityManager.Stub if (index < 0) { ProcessList.remove(app.pid); } + + // Remove provider publish timeout because we will start a new timeout when the + // restarted process is attaching (if the process contains launching providers). + mHandler.removeMessages(CONTENT_PROVIDER_PUBLISH_TIMEOUT_MSG, app); + mProcessList.addProcessNameLocked(app); app.pendingStart = false; mProcessList.startProcessLocked(app,