If the ServiceRecord already has a ProcessRecord attached
in startServiceLocked(), whitelist the process at that point (previously we'd just set the valiable to true, and not add the token) If the process was already attached, realStartServiceLocked() wouldn't run. Also, don't remove bg actvity starts token as soon as the service is stopped in stopServiceLocked() - instead only remove the token in the timeout callback. Bug: 131240614 Bug: 130810805 Test: manual (for the quoted bugs) Change-Id: I0e704e7b6e8cbafb026c90533fbe4a193a47c883
This commit is contained in:
committed by
Alan Stokes
parent
1e09d0e489
commit
7d3a33f353
@@ -634,7 +634,7 @@ public final class ActiveServices {
|
||||
}
|
||||
|
||||
if (allowBackgroundActivityStarts) {
|
||||
r.hasStartedWhitelistingBgActivityStarts = true;
|
||||
r.setHasStartedWhitelistingBgActivityStarts(true);
|
||||
scheduleCleanUpHasStartedWhitelistingBgActivityStartsLocked(r);
|
||||
}
|
||||
|
||||
@@ -761,11 +761,6 @@ public final class ActiveServices {
|
||||
}
|
||||
service.callStart = false;
|
||||
|
||||
// the service will not necessarily be brought down, so only clear the whitelisting state
|
||||
// for start-based bg activity starts now, and drop any existing future cleanup callback
|
||||
service.setHasStartedWhitelistingBgActivityStarts(false);
|
||||
mAm.mHandler.removeCallbacks(service.startedWhitelistingBgActivityStartsCleanUp);
|
||||
|
||||
bringDownServiceIfNeededLocked(service, false, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,10 +131,10 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
int pendingConnectionImportance; // To be filled in to ProcessRecord once it connects
|
||||
|
||||
// any current binding to this service has BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS flag?
|
||||
private boolean hasBindingWhitelistingBgActivityStarts;
|
||||
private boolean mHasBindingWhitelistingBgActivityStarts;
|
||||
// is this service currently whitelisted to start activities from background by providing
|
||||
// allowBackgroundActivityStarts=true to startServiceLocked()?
|
||||
boolean hasStartedWhitelistingBgActivityStarts;
|
||||
private boolean mHasStartedWhitelistingBgActivityStarts;
|
||||
// used to clean up the state of hasStartedWhitelistingBgActivityStarts after a timeout
|
||||
Runnable startedWhitelistingBgActivityStartsCleanUp;
|
||||
|
||||
@@ -384,13 +384,13 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
if (whitelistManager) {
|
||||
pw.print(prefix); pw.print("whitelistManager="); pw.println(whitelistManager);
|
||||
}
|
||||
if (hasBindingWhitelistingBgActivityStarts) {
|
||||
if (mHasBindingWhitelistingBgActivityStarts) {
|
||||
pw.print(prefix); pw.print("hasBindingWhitelistingBgActivityStarts=");
|
||||
pw.println(hasBindingWhitelistingBgActivityStarts);
|
||||
pw.println(mHasBindingWhitelistingBgActivityStarts);
|
||||
}
|
||||
if (hasStartedWhitelistingBgActivityStarts) {
|
||||
if (mHasStartedWhitelistingBgActivityStarts) {
|
||||
pw.print(prefix); pw.print("hasStartedWhitelistingBgActivityStarts=");
|
||||
pw.println(hasStartedWhitelistingBgActivityStarts);
|
||||
pw.println(mHasStartedWhitelistingBgActivityStarts);
|
||||
}
|
||||
if (delayed) {
|
||||
pw.print(prefix); pw.print("delayed="); pw.println(delayed);
|
||||
@@ -542,7 +542,8 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
|
||||
public void setProcess(ProcessRecord _proc) {
|
||||
if (_proc != null) {
|
||||
if (hasStartedWhitelistingBgActivityStarts || hasBindingWhitelistingBgActivityStarts) {
|
||||
if (mHasStartedWhitelistingBgActivityStarts
|
||||
|| mHasBindingWhitelistingBgActivityStarts) {
|
||||
_proc.addAllowBackgroundActivityStartsToken(this);
|
||||
} else {
|
||||
_proc.removeAllowBackgroundActivityStartsToken(this);
|
||||
@@ -614,22 +615,22 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasBindingWhitelistingBgActivityStarts != hasWhitelistingBinding) {
|
||||
hasBindingWhitelistingBgActivityStarts = hasWhitelistingBinding;
|
||||
if (mHasBindingWhitelistingBgActivityStarts != hasWhitelistingBinding) {
|
||||
mHasBindingWhitelistingBgActivityStarts = hasWhitelistingBinding;
|
||||
updateParentProcessBgActivityStartsWhitelistingToken();
|
||||
}
|
||||
}
|
||||
|
||||
void setHasBindingWhitelistingBgActivityStarts(boolean newValue) {
|
||||
if (hasBindingWhitelistingBgActivityStarts != newValue) {
|
||||
hasBindingWhitelistingBgActivityStarts = newValue;
|
||||
if (mHasBindingWhitelistingBgActivityStarts != newValue) {
|
||||
mHasBindingWhitelistingBgActivityStarts = newValue;
|
||||
updateParentProcessBgActivityStartsWhitelistingToken();
|
||||
}
|
||||
}
|
||||
|
||||
void setHasStartedWhitelistingBgActivityStarts(boolean newValue) {
|
||||
if (hasStartedWhitelistingBgActivityStarts != newValue) {
|
||||
hasStartedWhitelistingBgActivityStarts = newValue;
|
||||
if (mHasStartedWhitelistingBgActivityStarts != newValue) {
|
||||
mHasStartedWhitelistingBgActivityStarts = newValue;
|
||||
updateParentProcessBgActivityStartsWhitelistingToken();
|
||||
}
|
||||
}
|
||||
@@ -647,7 +648,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
if (app == null) {
|
||||
return;
|
||||
}
|
||||
if (hasStartedWhitelistingBgActivityStarts || hasBindingWhitelistingBgActivityStarts) {
|
||||
if (mHasStartedWhitelistingBgActivityStarts || mHasBindingWhitelistingBgActivityStarts) {
|
||||
// if the token is already there it's safe to "re-add it" - we're deadling with
|
||||
// a set of Binder objects
|
||||
app.addAllowBackgroundActivityStartsToken(this);
|
||||
|
||||
Reference in New Issue
Block a user