Fix issue #10876433: java.lang.IllegalStateException in...

...ActivityManagerService.updateLruProcessInternalLocked on bluetooth

Don't try to move process records associated with dead service
connections.

Technically we should probably be clearing the binding/service's
app entry so we don't get into this case, but the least intrusive
change for now is this check.

Change-Id: I6683e692eb5a8fa4f8ec1fa31bd63ec3d7f878ef
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ee329fc..808bf88 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2241,8 +2241,9 @@
 
         int lrui = mLruProcesses.lastIndexOf(app);
         if (lrui < 0) {
-            throw new IllegalStateException("Adding dependent process " + app
-                    + " not on LRU list: " + what + obj + " from " + srcApp);
+            Log.wtf(TAG, "Adding dependent process " + app + " not on LRU list: "
+                    + what + " " + obj + " from " + srcApp);
+            return index;
         }
 
         if (lrui >= mLruProcessActivityStart) {
@@ -2307,7 +2308,7 @@
         // bump those processes as well.
         for (int j=app.connections.size()-1; j>=0; j--) {
             ConnectionRecord cr = app.connections.valueAt(j);
-            if (cr.binding != null && cr.binding.service != null
+            if (cr.binding != null && !cr.serviceDead && cr.binding.service != null
                     && cr.binding.service.app != null
                     && cr.binding.service.app.lruSeq != mLruSeq) {
                 nextIndex = updateLruProcessInternalLocked(cr.binding.service.app, now, nextIndex,