From 39422271a9f431e06296d9914b3aadf6dfa8040e Mon Sep 17 00:00:00 2001 From: Michal Karpinski Date: Wed, 22 May 2019 15:42:52 +0100 Subject: Remember the process that token was added for also for the services that are already running Previously we'd only save the process in setProcess(), which doesn't get called if the service already has a process attached. Bug: 133309421 Test: manual (with the app on the bug) Change-Id: I383d2ba9e0fd0bcda218c61dba4ef61ccd658691 --- services/core/java/com/android/server/am/ServiceRecord.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'services') diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java index 2f1b22ec9a67..446b12833096 100644 --- a/services/core/java/com/android/server/am/ServiceRecord.java +++ b/services/core/java/com/android/server/am/ServiceRecord.java @@ -551,12 +551,10 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN .removeAllowBackgroundActivityStartsToken(this); ams.mHandler.removeCallbacks(mStartedWhitelistingBgActivityStartsCleanUp); } - mAppForStartedWhitelistingBgActivityStarts = null; - } - if (mHasStartedWhitelistingBgActivityStarts) { - // Make sure the cleanup callback knows about the new process. - mAppForStartedWhitelistingBgActivityStarts = _proc; } + // Make sure the cleanup callback knows about the new process. + mAppForStartedWhitelistingBgActivityStarts = mHasStartedWhitelistingBgActivityStarts + ? _proc : null; if (mHasStartedWhitelistingBgActivityStarts || mHasBindingWhitelistingBgActivityStarts) { _proc.addAllowBackgroundActivityStartsToken(this); @@ -656,6 +654,9 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN */ void whitelistBgActivityStartsOnServiceStart() { setHasStartedWhitelistingBgActivityStarts(true); + if (app != null) { + mAppForStartedWhitelistingBgActivityStarts = app; + } // This callback is stateless, so we create it once when we first need it. if (mStartedWhitelistingBgActivityStartsCleanUp == null) { -- cgit v1.2.3-59-g8ed1b