From b15506f95e7b00d9a5b89a0c732689fcad2a12ff Mon Sep 17 00:00:00 2001 From: riddle_hsu Date: Wed, 4 Feb 2015 20:52:03 +0800 Subject: [PATCH] Check caller status precisely when registering receiver. Fine tune commit 9ac9609f. Because process may reuse same process record to restart. It is better to check below conditions to skip: 1. Simple dead and has been cleaned. => .thread will be null 2.The process has restarted with new pid but has not attached yet. => .thread will be null 3.The process has restarted and attached. => The IBinder will be different Change-Id: Ic052f5025558ca93e1a6ab11bca61fe995126bb9 --- .../java/com/android/server/am/ActivityManagerService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 91736f38aba18..10593ae8b0b18 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -15262,8 +15262,9 @@ public final class ActivityManagerService extends ActivityManagerNative } synchronized (this) { - if (callerApp != null && callerApp.pid == 0) { - // Caller already died + if (callerApp != null && (callerApp.thread == null + || callerApp.thread.asBinder() != caller.asBinder())) { + // Original caller already died return null; } ReceiverList rl