Add new proc state constants and delivery.

The activity manager now keeps a new "process state" for
each process, indicating the general execution and memory
state of the process.  This closely follows the out-of-memory
adjustment and scheduling class that it currently tracks,
but roles these together (plus a little more info) into one
more semantically meaningful number.

This value is reported to each process as it changes, so they
can do things like tune the Dalvik garbage collector to match
the current process state.

I think I should also switch to this for process states.  It
will give is more meaningful divisions of time for each process.

Also fix a problem in the activity stack where the previous
process was not being set correctly when moving between
activity stacks.

Change-Id: I598b1667dc46547f8fadae304e210c352cc9d41f
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index 21a6ff0..cb9a76d 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -76,6 +76,8 @@
     int setSchedGroup;          // Last set to background scheduling class
     int trimMemoryLevel;        // Last selected memory trimming level
     int memImportance;          // Importance constant computed from curAdj
+    int curProcState = -1;      // Currently computed process state: ActivityManager.PROCESS_STATE_*
+    int repProcState = -1;      // Last reported process state
     boolean serviceb;           // Process currently is on the service B list
     boolean keeping;            // Actively running code so don't kill due to that?
     boolean setIsForeground;    // Running foreground UI when last set?
@@ -225,6 +227,8 @@
                 pw.print(" setSchedGroup="); pw.print(setSchedGroup);
                 pw.print(" systemNoUi="); pw.print(systemNoUi);
                 pw.print(" trimMemoryLevel="); pw.println(trimMemoryLevel);
+        pw.print(prefix); pw.print("curProcState="); pw.print(curProcState);
+                pw.print(" repProcState="); pw.println(repProcState);
         pw.print(prefix); pw.print("adjSeq="); pw.print(adjSeq);
                 pw.print(" lruSeq="); pw.print(lruSeq);
                 pw.print(" lastPssTime="); pw.println(lastPssTime);
@@ -473,6 +477,12 @@
         return setAdj;
     }
 
+    public void forceProcessStateUpTo(int newState) {
+        if (repProcState > newState) {
+            curProcState = repProcState = newState;
+        }
+    }
+
     public void setProcessTrackerState(ProcessRecord TOP_APP, int memFactor, long now,
             ProcessList plist) {
         int state = this == TOP_APP ? ProcessTracker.STATE_TOP