Remove dead locks in system process when installing packages
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 04bfae6..14c10b9 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -924,6 +924,7 @@
     static final int RESUME_TOP_ACTIVITY_MSG = 19;
     static final int PROC_START_TIMEOUT_MSG = 20;
     static final int DO_PENDING_ACTIVITY_LAUNCHES_MSG = 21;
+    static final int KILL_APPLICATION_MSG = 22;
 
     AlertDialog mUidAlert;
 
@@ -1153,6 +1154,14 @@
                     doPendingActivityLaunchesLocked(true);
                 }
             }
+            case KILL_APPLICATION_MSG: {
+                synchronized (ActivityManagerService.this) {
+                    int uid = msg.arg1;
+                    boolean restart = (msg.arg2 == 1);
+                    String pkg = (String) msg.obj;
+                    uninstallPackageLocked(pkg, uid, restart);
+                }
+            } break;
             }
         }
     };
@@ -4804,7 +4813,12 @@
         int callerUid = Binder.getCallingUid();
         // Only the system server can kill an application
         if (callerUid == Process.SYSTEM_UID) {
-            uninstallPackageLocked(pkg, uid, false);
+            // Post an aysnc message to kill the application
+            Message msg = mHandler.obtainMessage(KILL_APPLICATION_MSG);
+            msg.arg1 = uid;
+            msg.arg2 = 0;
+            msg.obj = pkg;
+            mHandler.dispatchMessage(msg);
         } else {
             throw new SecurityException(callerUid + " cannot kill pkg: " +
                     pkg);