Skip to content
Snippets Groups Projects
Commit 2dc7b8b3 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge "Reduce the scope of holding the mPidsSelfLocked lock" into main

parents 6b9e304f 7ba146d5
No related branches found
No related tags found
No related merge requests found
......@@ -6025,46 +6025,47 @@ public class ActivityManagerService extends IActivityManager.Stub
}
 
synchronized (mProcLock) {
synchronized (mPidsSelfLocked) {
int newestTimeIndex = -1;
long newestTime = Long.MIN_VALUE;
for (int i = 0; i < pids.length; i++) {
ProcessRecord pr = mPidsSelfLocked.get(pids[i]);
if (pr != null) {
final long pendingTopTime =
mPendingStartActivityUids.getPendingTopPidTime(pr.uid, pids[i]);
if (pendingTopTime != PendingStartActivityUids.INVALID_TIME) {
// The uid in mPendingStartActivityUids gets the TOP process state.
states[i] = PROCESS_STATE_TOP;
if (scores != null) {
// The uid in mPendingStartActivityUids gets a better score.
scores[i] = ProcessList.FOREGROUND_APP_ADJ - 1;
}
if (pendingTopTime > newestTime) {
newestTimeIndex = i;
newestTime = pendingTopTime;
}
} else {
states[i] = pr.mState.getCurProcState();
if (scores != null) {
scores[i] = pr.mState.getCurAdj();
}
int newestTimeIndex = -1;
long newestTime = Long.MIN_VALUE;
for (int i = 0; i < pids.length; i++) {
final ProcessRecord pr;
synchronized (mPidsSelfLocked) {
pr = mPidsSelfLocked.get(pids[i]);
}
if (pr != null) {
final long pendingTopTime =
mPendingStartActivityUids.getPendingTopPidTime(pr.uid, pids[i]);
if (pendingTopTime != PendingStartActivityUids.INVALID_TIME) {
// The uid in mPendingStartActivityUids gets the TOP process state.
states[i] = PROCESS_STATE_TOP;
if (scores != null) {
// The uid in mPendingStartActivityUids gets a better score.
scores[i] = ProcessList.FOREGROUND_APP_ADJ - 1;
}
if (pendingTopTime > newestTime) {
newestTimeIndex = i;
newestTime = pendingTopTime;
}
} else {
states[i] = PROCESS_STATE_NONEXISTENT;
states[i] = pr.mState.getCurProcState();
if (scores != null) {
scores[i] = ProcessList.INVALID_ADJ;
scores[i] = pr.mState.getCurAdj();
}
}
}
// The uid with the newest timestamp in mPendingStartActivityUids gets the best
// score.
if (newestTimeIndex != -1) {
} else {
states[i] = PROCESS_STATE_NONEXISTENT;
if (scores != null) {
scores[newestTimeIndex] = ProcessList.FOREGROUND_APP_ADJ - 2;
scores[i] = ProcessList.INVALID_ADJ;
}
}
}
// The uid with the newest timestamp in mPendingStartActivityUids gets the best
// score.
if (newestTimeIndex != -1) {
if (scores != null) {
scores[newestTimeIndex] = ProcessList.FOREGROUND_APP_ADJ - 2;
}
}
}
}
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment