Check if app's ntwk state will be changed before updating procstate.

We check previous set procstate and the current procstate in the
UidRecord to see if the app's network access state is going to be
changed and so it needs to be done before we change the setProcstate
in the UidRecord.

Bug: 224438257
Bug: 218308105

Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I0f3a4ca18cd889f49e3e3651799c3c14f9c2e218
This commit is contained in:
Sudheer Shanka
2022-03-17 16:49:35 +00:00
parent 391556b01c
commit 39da7d1c23

View File

@@ -547,7 +547,6 @@ public class OomAdjuster {
uids.clear();
uids.put(uidRec.getUid(), uidRec);
updateUidsLSP(uids, SystemClock.elapsedRealtime());
mProcessList.incrementProcStateSeqAndNotifyAppsLOSP(uids);
}
}
@@ -1268,8 +1267,6 @@ public class OomAdjuster {
}
}
mProcessList.incrementProcStateSeqAndNotifyAppsLOSP(activeUids);
return mService.mAppProfiler.updateLowMemStateLSP(numCached, numEmpty, numTrimming);
}
@@ -1304,6 +1301,11 @@ public class OomAdjuster {
@GuardedBy({"mService", "mProcLock"})
private void updateUidsLSP(ActiveUids activeUids, final long nowElapsed) {
// This compares previously set procstate to the current procstate in regards to whether
// or not the app's network access will be blocked. So, this needs to be called before
// we update the UidRecord's procstate by calling {@link UidRecord#setSetProcState}.
mProcessList.incrementProcStateSeqAndNotifyAppsLOSP(activeUids);
ArrayList<UidRecord> becameIdle = mTmpBecameIdle;
becameIdle.clear();