From 4502ce2d498e6173f69b5af88cb2b81b76de990f Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 13 May 2016 14:50:23 -0700 Subject: [PATCH] Fix issue #28728838 java.lang.ClassCastException: android.os.BinderProxy... ...cannot be cast to LocalBinder after a crash Turns out, if you called removeProcessLocked() with an old ProcessRecord, we could get in to a bad state -- if we had a new process with that same name already running, we would kind-of blow it away as a process name, but not as much else. So the next time we wanted to run a new thing in the process, we would start a new second process and the two could get mixed together. Change-Id: I05e0463bd55f57f5e07f0b804ed9fd8c4f98a5a5 --- .../com/android/server/am/ActivityManagerService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 313ca9a95415c..ded65569c3951 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -6167,6 +6167,12 @@ public final class ActivityManagerService extends ActivityManagerNative if (DEBUG_PROCESSES) Slog.d(TAG_PROCESSES, "Force removing proc " + app.toShortString() + " (" + name + "/" + uid + ")"); + ProcessRecord old = mProcessNames.get(name, uid); + if (old != app) { + // This process is no longer active, so nothing to do. + Slog.w(TAG, "Ignoring remove of inactive process: " + app); + return false; + } removeProcessNameLocked(name, uid); if (mHeavyWeightProcess == app) { mHandler.sendMessage(mHandler.obtainMessage(CANCEL_HEAVY_NOTIFICATION_MSG, @@ -20467,7 +20473,7 @@ public final class ActivityManagerService extends ActivityManagerNative && app.curReceiver == null && app.services.size() == 0) { Slog.i( TAG, "Exiting empty application process " - + app.processName + " (" + + app.toShortString() + " (" + (app.thread != null ? app.thread.asBinder() : null) + ")\n"); if (app.pid > 0 && app.pid != MY_PID) {