Merge "Do not kill process bound with WAIVE_PRIORITY / ALLOW_OOM_MANAGEMENT" into sc-dev am: 35b2d00e79 am: 682f1a9f91

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14766840

Change-Id: I88f5d51dff39a139b8afb57aabb66afe3788ee84
This commit is contained in:
Jing Ji
2021-06-04 10:41:06 +00:00
committed by Automerger Merge Worker
3 changed files with 25 additions and 0 deletions

View File

@@ -1573,6 +1573,7 @@ public class OomAdjuster {
state.setAdjTarget(null);
state.setEmpty(false);
state.setCached(false);
state.setNoKillOnForcedAppStandbyAndIdle(false);
state.resetAllowStartFgsState();
app.mOptRecord.setShouldNotFreeze(false);
@@ -2061,6 +2062,9 @@ public class OomAdjuster {
// Similar to BIND_WAIVE_PRIORITY, keep it unfrozen.
if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
app.mOptRecord.setShouldNotFreeze(true);
// Similarly, we shouldn't kill it when it's in forced-app-standby
// mode and cached & idle state.
app.mState.setNoKillOnForcedAppStandbyAndIdle(true);
}
// Not doing bind OOM management, so treat
// this guy more like a started service.
@@ -2265,6 +2269,9 @@ public class OomAdjuster {
// unfrozen.
if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
app.mOptRecord.setShouldNotFreeze(true);
// Similarly, we shouldn't kill it when it's in forced-app-standby
// mode and cached & idle state.
app.mState.setNoKillOnForcedAppStandbyAndIdle(true);
}
}
if ((cr.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {

View File

@@ -5043,6 +5043,7 @@ public final class ProcessList {
final UidRecord uidRec = app.getUidRecord();
if (mService.mConstants.mKillForceAppStandByAndCachedIdle
&& uidRec != null && uidRec.isIdle()
&& !app.mState.shouldNotKillOnForcedAppStandbyAndIdle()
&& app.isCached() && app.mState.isForcedAppStandby()) {
app.killLocked("cached idle & forced-app-standby",
ApplicationExitInfo.REASON_OTHER,

View File

@@ -363,6 +363,13 @@ final class ProcessStateRecord {
@ElapsedRealtimeLong
private long mLastInvisibleTime;
/**
* Whether or not this process could be killed when it's in forced-app-standby mode
* and cached &amp; idle state.
*/
@GuardedBy("mService")
private boolean mNoKillOnForcedAppStandbyAndIdle;
// Below are the cached task info for OomAdjuster only
private static final int VALUE_INVALID = -1;
private static final int VALUE_FALSE = 0;
@@ -1143,6 +1150,16 @@ final class ProcessStateRecord {
return mLastInvisibleTime;
}
@GuardedBy("mService")
void setNoKillOnForcedAppStandbyAndIdle(boolean shouldNotKill) {
mNoKillOnForcedAppStandbyAndIdle = shouldNotKill;
}
@GuardedBy("mService")
boolean shouldNotKillOnForcedAppStandbyAndIdle() {
return mNoKillOnForcedAppStandbyAndIdle;
}
@GuardedBy({"mService", "mProcLock"})
void dump(PrintWriter pw, String prefix, long nowUptime) {
if (mReportedInteraction || mFgInteractionTime != 0) {