Merge "Fix unit test dependency of WmTests" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-08 17:49:28 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 4 deletions

View File

@@ -17002,6 +17002,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void addPendingTopUid(int uid, int pid) {
final boolean isNewPending = mPendingStartActivityUids.add(uid, pid);
// If the next top activity is in cached and frozen mode, WM should raise its priority
// to unfreeze it. This is done by calling AMS.updateOomAdj that will lower its oom adj.
// However, WM cannot hold the AMS clock here so the updateOomAdj operation is performed
@@ -17009,11 +17010,9 @@ public class ActivityManagerService extends IActivityManager.Stub
// next top activity on time. This race will fail the following binder transactions WM
// sends to the activity. After this race issue between WM/ATMS and AMS is solved, this
// workaround can be removed. (b/213288355)
if (!isPendingTopUid(uid)) {
if (isNewPending && mOomAdjuster != null) { // It can be null in unit test.
mOomAdjuster.mCachedAppOptimizer.unfreezeProcess(pid);
}
mPendingStartActivityUids.add(uid, pid);
}
@Override

View File

@@ -46,10 +46,13 @@ final class PendingStartActivityUids {
mContext = context;
}
synchronized void add(int uid, int pid) {
/** Returns {@code true} if the uid is put to the pending array. Otherwise it existed. */
synchronized boolean add(int uid, int pid) {
if (mPendingUids.get(uid) == null) {
mPendingUids.put(uid, new Pair<>(pid, SystemClock.elapsedRealtime()));
return true;
}
return false;
}
synchronized void delete(int uid) {