From d9d2576017fadcf47589b54e8ee198f48cc19352 Mon Sep 17 00:00:00 2001 From: Suchi Amalapurapu Date: Mon, 17 Aug 2009 16:57:03 -0700 Subject: [PATCH] Remove dead locks in system process when installing packages --- .../server/am/ActivityManagerService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 04bfae6152a81..14c10b94dcf74 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -924,6 +924,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen 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 @@ public final class ActivityManagerService extends ActivityManagerNative implemen 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 @@ public final class ActivityManagerService extends ActivityManagerNative implemen 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);