Merge "Deprecate and remove ProcessStateRecord.mAllowStartFgsState field." into tm-dev

This commit is contained in:
TreeHugger Robot
2022-05-03 04:00:56 +00:00
committed by Android (Google) Code Review
4 changed files with 6 additions and 40 deletions

View File

@@ -6621,8 +6621,8 @@ public final class ActiveServices {
final Integer allowedType = mAm.mProcessList.searchEachLruProcessesLOSP(false, app -> { final Integer allowedType = mAm.mProcessList.searchEachLruProcessesLOSP(false, app -> {
if (app.uid == callingUid) { if (app.uid == callingUid) {
final ProcessStateRecord state = app.mState; final ProcessStateRecord state = app.mState;
if (state.isAllowedStartFgsState()) { if (state.isAllowedStartFgs()) {
return getReasonCodeFromProcState(state.getAllowStartFgsState()); return getReasonCodeFromProcState(state.getCurProcState());
} else { } else {
final ActiveInstrumentation instr = app.getActiveInstrumentation(); final ActiveInstrumentation instr = app.getActiveInstrumentation();
if (instr != null if (instr != null

View File

@@ -1478,7 +1478,6 @@ public class OomAdjuster {
state.setAdjTarget(null); state.setAdjTarget(null);
state.setEmpty(false); state.setEmpty(false);
state.setCached(false); state.setCached(false);
state.resetAllowStartFgsState();
if (!cycleReEval) { if (!cycleReEval) {
// Don't reset this flag when doing cycles re-evaluation. // Don't reset this flag when doing cycles re-evaluation.
state.setNoKillOnBgRestrictedAndIdle(false); state.setNoKillOnBgRestrictedAndIdle(false);
@@ -1537,7 +1536,6 @@ public class OomAdjuster {
state.setCurRawProcState(state.getCurProcState()); state.setCurRawProcState(state.getCurProcState());
state.setCurAdj(state.getMaxAdj()); state.setCurAdj(state.getMaxAdj());
state.setCompletedAdjSeq(state.getAdjSeq()); state.setCompletedAdjSeq(state.getAdjSeq());
state.bumpAllowStartFgsState(state.getCurProcState());
// if curAdj is less than prevAppAdj, then this process was promoted // if curAdj is less than prevAppAdj, then this process was promoted
return state.getCurAdj() < prevAppAdj || state.getCurProcState() < prevProcState; return state.getCurAdj() < prevAppAdj || state.getCurProcState() < prevProcState;
} }
@@ -1563,7 +1561,6 @@ public class OomAdjuster {
foregroundActivities = true; foregroundActivities = true;
hasVisibleActivities = true; hasVisibleActivities = true;
procState = PROCESS_STATE_CUR_TOP; procState = PROCESS_STATE_CUR_TOP;
state.bumpAllowStartFgsState(PROCESS_STATE_TOP);
if (DEBUG_OOM_ADJ_REASON || logUid == appUid) { if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
reportOomAdjMessageLocked(TAG_OOM_ADJ, "Making top: " + app); reportOomAdjMessageLocked(TAG_OOM_ADJ, "Making top: " + app);
} }
@@ -1661,7 +1658,6 @@ public class OomAdjuster {
// The user is aware of this app, so make it visible. // The user is aware of this app, so make it visible.
adj = ProcessList.PERCEPTIBLE_APP_ADJ; adj = ProcessList.PERCEPTIBLE_APP_ADJ;
procState = PROCESS_STATE_FOREGROUND_SERVICE; procState = PROCESS_STATE_FOREGROUND_SERVICE;
state.bumpAllowStartFgsState(PROCESS_STATE_FOREGROUND_SERVICE);
state.setAdjType("fg-service"); state.setAdjType("fg-service");
state.setCached(false); state.setCached(false);
schedGroup = ProcessList.SCHED_GROUP_DEFAULT; schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
@@ -2103,8 +2099,6 @@ public class OomAdjuster {
// give them the best bound state after that. // give them the best bound state after that.
if (cr.hasFlag(Context.BIND_FOREGROUND_SERVICE)) { if (cr.hasFlag(Context.BIND_FOREGROUND_SERVICE)) {
clientProcState = PROCESS_STATE_BOUND_FOREGROUND_SERVICE; clientProcState = PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
state.bumpAllowStartFgsState(
PROCESS_STATE_BOUND_FOREGROUND_SERVICE);
} else if (mService.mWakefulness.get() } else if (mService.mWakefulness.get()
== PowerManagerInternal.WAKEFULNESS_AWAKE == PowerManagerInternal.WAKEFULNESS_AWAKE
&& (cr.flags & Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE) && (cr.flags & Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE)
@@ -2118,7 +2112,6 @@ public class OomAdjuster {
// Go at most to BOUND_TOP, unless requested to elevate // Go at most to BOUND_TOP, unless requested to elevate
// to client's state. // to client's state.
clientProcState = PROCESS_STATE_BOUND_TOP; clientProcState = PROCESS_STATE_BOUND_TOP;
state.bumpAllowStartFgsState(PROCESS_STATE_BOUND_TOP);
final boolean enabled = cstate.getCachedCompatChange( final boolean enabled = cstate.getCachedCompatChange(
CACHED_COMPAT_CHANGE_PROCESS_CAPABILITY); CACHED_COMPAT_CHANGE_PROCESS_CAPABILITY);
if (enabled) { if (enabled) {

View File

@@ -295,13 +295,6 @@ final class ProcessStateRecord {
@GuardedBy("mService") @GuardedBy("mService")
private boolean mSystemNoUi; private boolean mSystemNoUi;
/**
* If the proc state is PROCESS_STATE_BOUND_FOREGROUND_SERVICE or above, it can start FGS.
* It must obtain the proc state from a persistent/top process or FGS, not transitive.
*/
@GuardedBy("mService")
private int mAllowStartFgsState = PROCESS_STATE_NONEXISTENT;
/** /**
* Whether or not the app is background restricted (OP_RUN_ANY_IN_BACKGROUND is NOT allowed). * Whether or not the app is background restricted (OP_RUN_ANY_IN_BACKGROUND is NOT allowed).
*/ */
@@ -1165,33 +1158,15 @@ final class ProcessStateRecord {
mCurRawAdj = mSetRawAdj = mCurAdj = mSetAdj = mVerifiedAdj = ProcessList.INVALID_ADJ; mCurRawAdj = mSetRawAdj = mCurAdj = mSetAdj = mVerifiedAdj = ProcessList.INVALID_ADJ;
mCurCapability = mSetCapability = PROCESS_CAPABILITY_NONE; mCurCapability = mSetCapability = PROCESS_CAPABILITY_NONE;
mCurSchedGroup = mSetSchedGroup = ProcessList.SCHED_GROUP_BACKGROUND; mCurSchedGroup = mSetSchedGroup = ProcessList.SCHED_GROUP_BACKGROUND;
mCurProcState = mCurRawProcState = mSetProcState = mAllowStartFgsState = mCurProcState = mCurRawProcState = mSetProcState = PROCESS_STATE_NONEXISTENT;
PROCESS_STATE_NONEXISTENT;
for (int i = 0; i < mCachedCompatChanges.length; i++) { for (int i = 0; i < mCachedCompatChanges.length; i++) {
mCachedCompatChanges[i] = VALUE_INVALID; mCachedCompatChanges[i] = VALUE_INVALID;
} }
} }
@GuardedBy("mService") @GuardedBy("mService")
void resetAllowStartFgsState() { boolean isAllowedStartFgs() {
mAllowStartFgsState = PROCESS_STATE_NONEXISTENT; return mCurProcState <= PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
}
@GuardedBy("mService")
void bumpAllowStartFgsState(int newProcState) {
if (newProcState < mAllowStartFgsState) {
mAllowStartFgsState = newProcState;
}
}
@GuardedBy("mService")
int getAllowStartFgsState() {
return mAllowStartFgsState;
}
@GuardedBy("mService")
boolean isAllowedStartFgsState() {
return mAllowStartFgsState <= PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
} }
@GuardedBy("mService") @GuardedBy("mService")
@@ -1331,8 +1306,6 @@ final class ProcessStateRecord {
pw.print(" setCapability="); pw.print(" setCapability=");
ActivityManager.printCapabilitiesFull(pw, mSetCapability); ActivityManager.printCapabilitiesFull(pw, mSetCapability);
pw.println(); pw.println();
pw.print(prefix); pw.print("allowStartFgsState=");
pw.print(mAllowStartFgsState);
if (mBackgroundRestricted) { if (mBackgroundRestricted) {
pw.print(" backgroundRestricted="); pw.print(" backgroundRestricted=");
pw.print(mBackgroundRestricted); pw.print(mBackgroundRestricted);

View File

@@ -488,7 +488,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
pw.print(prefix); pw.print("recentCallingUid="); pw.print(prefix); pw.print("recentCallingUid=");
pw.println(mRecentCallingUid); pw.println(mRecentCallingUid);
pw.print(prefix); pw.print("allowStartForeground="); pw.print(prefix); pw.print("allowStartForeground=");
pw.println(mAllowStartForeground); pw.println(PowerExemptionManager.reasonCodeToString(mAllowStartForeground));
pw.print(prefix); pw.print("startForegroundCount="); pw.print(prefix); pw.print("startForegroundCount=");
pw.println(mStartForegroundCount); pw.println(mStartForegroundCount);
pw.print(prefix); pw.print("infoAllowStartForeground="); pw.print(prefix); pw.print("infoAllowStartForeground=");