summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2013-08-09 17:12:11 -0700
committerDianne Hackborn <hackbod@google.com>2013-08-09 17:21:53 -0700
commitd9545a913da2ac705dde33a196576d37fe760796 (patch)
treed70b36f74ae136c1a54035c3e670bd83bc541f0c /services/java/com
parentb0037316c4bbaf9d5b3ee8af563caf2539def564 (diff)
downloadframeworks_base-d9545a913da2ac705dde33a196576d37fe760796.zip
frameworks_base-d9545a913da2ac705dde33a196576d37fe760796.tar.gz
frameworks_base-d9545a913da2ac705dde33a196576d37fe760796.tar.bz2
Allow bound processes to go PROCESS_STATE_TOP.
For process state, if a top process is making use of another process, we should probably count the second process as top as well (instead of IMPORTANT_FOREGROUND). Specially, when chrome binds to render processes we want those render processes to be TOP. Otherwise, they end up in the important foreground state and it looks like they are running for some other reason in the background. Change-Id: Id115dbb65dc2b403ffa4bbe4e7837564eb3b9cb5
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java38
1 files changed, 29 insertions, 9 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9dba2ed..4fe2384 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -13830,7 +13830,7 @@ public final class ActivityManagerService extends ActivityManagerNative
for (int is = app.services.size()-1;
is >= 0 && (adj > ProcessList.FOREGROUND_APP_ADJ
|| schedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE
- || procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
+ || procState > ActivityManager.PROCESS_STATE_TOP);
is--) {
ServiceRecord s = app.services.valueAt(is);
if (s.startRequested) {
@@ -13871,13 +13871,13 @@ public final class ActivityManagerService extends ActivityManagerNative
for (int conni = s.connections.size()-1;
conni >= 0 && (adj > ProcessList.FOREGROUND_APP_ADJ
|| schedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE
- || procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
+ || procState > ActivityManager.PROCESS_STATE_TOP);
conni--) {
ArrayList<ConnectionRecord> clist = s.connections.valueAt(conni);
for (int i = 0;
i < clist.size() && (adj > ProcessList.FOREGROUND_APP_ADJ
|| schedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE
- || procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
+ || procState > ActivityManager.PROCESS_STATE_TOP);
i++) {
// XXX should compute this based on the max of
// all connected clients.
@@ -13987,8 +13987,16 @@ public final class ActivityManagerService extends ActivityManagerNative
if (client.curSchedGroup == Process.THREAD_GROUP_DEFAULT) {
schedGroup = Process.THREAD_GROUP_DEFAULT;
}
- if (clientProcState <
- ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
+ if (clientProcState <=
+ ActivityManager.PROCESS_STATE_PERSISTENT_UI &&
+ clientProcState >=
+ ActivityManager.PROCESS_STATE_PERSISTENT) {
+ // Persistent processes don't allow us to become top.
+ // However the top process DOES allow us to become top,
+ // because in that case we are running because the current
+ // top process wants us, so we should be counted as part
+ // of the top set and not just running for some random
+ // unknown reason in the background.
clientProcState =
ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
}
@@ -14040,13 +14048,13 @@ public final class ActivityManagerService extends ActivityManagerNative
for (int provi = app.pubProviders.size()-1;
provi >= 0 && (adj > ProcessList.FOREGROUND_APP_ADJ
|| schedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE
- || procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
+ || procState > ActivityManager.PROCESS_STATE_TOP);
provi--) {
ContentProviderRecord cpr = app.pubProviders.valueAt(provi);
for (int i = cpr.connections.size()-1;
i >= 0 && (adj > ProcessList.FOREGROUND_APP_ADJ
|| schedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE
- || procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
+ || procState > ActivityManager.PROCESS_STATE_TOP);
i--) {
ContentProviderConnection conn = cpr.connections.get(i);
ProcessRecord client = conn.client;
@@ -14078,9 +14086,21 @@ public final class ActivityManagerService extends ActivityManagerNative
app.adjSourceOom = clientAdj;
app.adjTarget = cpr.name;
}
+ if (clientProcState <=
+ ActivityManager.PROCESS_STATE_PERSISTENT_UI &&
+ clientProcState >=
+ ActivityManager.PROCESS_STATE_PERSISTENT) {
+ // Persistent processes don't allow us to become top.
+ // However the top process DOES allow us to become top,
+ // because in that case we are running because the current
+ // top process wants us, so we should be counted as part
+ // of the top set and not just running for some random
+ // unknown reason in the background.
+ clientProcState =
+ ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
+ }
if (procState > clientProcState) {
- procState = clientProcState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND
- ? clientProcState : ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
+ procState = clientProcState;
}
if (client.curSchedGroup == Process.THREAD_GROUP_DEFAULT) {
schedGroup = Process.THREAD_GROUP_DEFAULT;