summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java63
1 files changed, 32 insertions, 31 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 4c8f41608f46..4a2ac0431c8b 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -6023,46 +6023,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;
+ }
+ }
}
}