Hopefully fix issue #2662536: Why is launcher being killed?

It looks like there was a subtle bug where Process.setOomAdj() could
return false just because the given process doesn't exist, even though
it is documented to only return false if OOM killing is not supported
at all.  This would cause the activity manager to fall into its code
path of trying to clean up processes itself, which it does a much
poorer problem at.  I am thinking we may be seeing this problem more
now that the activity manager is killing background processes itself
when there are too many of them.

In addition, this change cleans up and reduces some of the logging
around killing processes.

Finally, try to improve process LRU management a bit by taking
into account process dependencies.  Any dependent processes are
pulled up in the LRU list with the processes that is actually
moving.  Also, we bring a process up if someone accesses its content
provider.

Change-Id: I34ea161f839679345578ffe681e8d9c5d26ab948
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index 7620468..f49a182 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -66,7 +66,8 @@
     boolean bad;                // True if disabled in the bad process list
     boolean killedBackground;   // True when proc has been killed due to too many bg
     IBinder forcingToForeground;// Token that is forcing this process to be foreground
-    int adjSeq;                 // Sequence id for identifying repeated trav
+    int adjSeq;                 // Sequence id for identifying oom_adj assignment cycles
+    int lruSeq;                 // Sequence id for identifying LRU update cycles
     ComponentName instrumentationClass;// class installed to instrument app
     ApplicationInfo instrumentationInfo; // the application being instrumented
     String instrumentationProfileFile; // where to save profiling
@@ -175,6 +176,8 @@
         pw.print(prefix); pw.print("persistent="); pw.print(persistent);
                 pw.print(" removed="); pw.print(removed);
                 pw.print(" persistentActivities="); pw.println(persistentActivities);
+        pw.print(prefix); pw.print("adjSeq="); pw.print(adjSeq);
+                pw.print(" lruSeq="); pw.println(lruSeq);
         if (killedBackground) {
             pw.print(prefix); pw.print("killedBackground="); pw.println(killedBackground);
         }